public static void AddMicrosoftAuthentication(this IServiceCollection services, IConfiguration configuration) { var authentication = new AzureAdOption(); configuration.Bind("AzureAd", authentication); services.Configure <AzureAdOption>(configuration.GetSection("AzureAd")); services.Configure <AzureAdOption>(option => { option.CallbackPath = authentication.CallbackPath; option.ClientId = authentication.ClientId; option.Domain = authentication.Domain; option.Instance = authentication.Instance; option.TenantId = authentication.TenantId; }).AddSingleton <IConfigureOptions <OpenIdConnectOptions>, ConfigureAzureOptions>(); services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }).AddOpenIdConnect().AddCookie(); }
public ConfigureAzureOptions(IOptions <AzureAdOption> azureOptions) { _azureOptions = azureOptions.Value; }