public static IServiceCollection AddAuthProxy(this IServiceCollection collection, Action <AuthProxyOptions> proxyOptions, Action <AadAuthenticationOptions> authOptions)
        {
            collection.Configure(proxyOptions);
            collection.Configure(authOptions);

            var aadSettings = new AadAuthenticationOptions();

            authOptions(aadSettings);

            collection.AddAuthentication(o =>
            {
                o.DefaultScheme          = CookieAuthenticationDefaults.AuthenticationScheme;
                o.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
            })
            .AddAzureAdBearer(authOptions)
            .AddOpenIdConnect(options =>
            {
                options.Authority    = $"https://login.microsoftonline.com/{aadSettings.Tenant}";
                options.ClientId     = aadSettings.ClientId;
                options.ResponseType = OpenIdConnectResponseType.IdToken;
                options.CallbackPath = aadSettings.CallbackPath;
                options.SaveTokens   = true;
            })
            .AddCookie();

            return(collection);
        }
 public ConfigureAzureOptions(IOptions <AadAuthenticationOptions> azureOptions)
 {
     _azureOptions = azureOptions.Value;
 }