Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureTokenAuthentication"/> class.
        /// </summary>
        /// <param name="servicePrincipleAuth">The service principle authentication.</param>
        /// <param name="azureAppRegistrationAuthority">Optionally specify an Azure App Registration to authenticate against. Defaults to "https://management.azure.com/"</param>
        public AzureTokenAuthentication(ServicePrincipleAuth servicePrincipleAuth, string azureAppRegistrationAuthority = null)
        {
            // Validate the certificate.
            servicePrincipleAuth.ThrowIfInvalid();

            _spAuth = servicePrincipleAuth;
            _azureAppRegistrationAuthority = azureAppRegistrationAuthority;
            Name = servicePrincipleAuth.AppId;
        }
Beispiel #2
0
 /// <summary>
 /// Add an instance of IAuthentication for service principle authentication.
 /// </summary>
 /// <param name="services">The services to extend.</param>
 /// <param name="config">The service principle authentication configuration to initialise with.</param>
 /// <param name="appRegistrationUrl">Optional parameter for an app registration url to authenticate against.</param>
 /// <returns>IServiceCollection.</returns>
 public static IServiceCollection AddAzureAuthSingleton(this IServiceCollection services, ServicePrincipleAuth config, string appRegistrationUrl = null)
 {
     services.AddSingleton <IAuthentication>(new AzureTokenAuthentication(config, appRegistrationUrl));
     AddFactoryIfNotAdded(services);
     return(services);
 }