React to Options and Hosting changes
This commit is contained in:
parent
6965a66f18
commit
84dfcf5258
|
|
@ -9,7 +9,7 @@ namespace CookieSample
|
|||
{
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UsePerRequestServices(services => { });
|
||||
app.UseServices(services => { });
|
||||
app.UseCookieAuthentication(options =>
|
||||
{
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace CookieSessionSample
|
|||
{
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UsePerRequestServices(services => { });
|
||||
app.UseServices(services => { });
|
||||
app.UseCookieAuthentication(options =>
|
||||
{
|
||||
options.SessionStore = new MemoryCacheSessionStore();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace CookieSample
|
|||
{
|
||||
app.UseErrorPage();
|
||||
|
||||
app.UsePerRequestServices(services =>
|
||||
app.UseServices(services =>
|
||||
{
|
||||
services.ConfigureOptions<ExternalAuthenticationOptions>(options =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder
|
|||
{
|
||||
public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<CookieAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Builder
|
|||
public static IApplicationBuilder UseCookieAuthentication([NotNull] this IApplicationBuilder app, Action<CookieAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<CookieAuthenticationMiddleware>(
|
||||
new OptionsAction<CookieAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
new ConfigureOptions<CookieAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
{
|
||||
Name = optionsName
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ namespace Microsoft.AspNet.Security.Cookies
|
|||
public CookieAuthenticationMiddleware(RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsAccessor<CookieAuthenticationOptions> options,
|
||||
IOptionsAction<CookieAuthenticationOptions> configureOptions)
|
||||
IOptions<CookieAuthenticationOptions> options,
|
||||
ConfigureOptions<CookieAuthenticationOptions> configureOptions)
|
||||
: base(next, options, configureOptions)
|
||||
{
|
||||
if (Options.Notifications == null)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder
|
|||
{
|
||||
public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<FacebookAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Builder
|
|||
public static IApplicationBuilder UseFacebookAuthentication([NotNull] this IApplicationBuilder app, Action<FacebookAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<FacebookAuthenticationMiddleware>(
|
||||
new OptionsAction<FacebookAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
new ConfigureOptions<FacebookAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
{
|
||||
Name = optionsName
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ namespace Microsoft.AspNet.Security.Facebook
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsAccessor<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptionsAccessor<FacebookAuthenticationOptions> options,
|
||||
IOptionsAction<FacebookAuthenticationOptions> configureOptions = null)
|
||||
IOptions<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptions<FacebookAuthenticationOptions> options,
|
||||
ConfigureOptions<FacebookAuthenticationOptions> configureOptions = null)
|
||||
: base(next, dataProtectionProvider, loggerFactory, externalOptions, options, configureOptions)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Options.AppId))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder
|
|||
{
|
||||
public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<GoogleAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Builder
|
|||
public static IApplicationBuilder UseGoogleAuthentication([NotNull] this IApplicationBuilder app, Action<GoogleAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<GoogleAuthenticationMiddleware>(
|
||||
new OptionsAction<GoogleAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
new ConfigureOptions<GoogleAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
{
|
||||
Name = optionsName
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ namespace Microsoft.AspNet.Security.Google
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsAccessor<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptionsAccessor<GoogleAuthenticationOptions> options,
|
||||
IOptionsAction<GoogleAuthenticationOptions> configureOptions = null)
|
||||
IOptions<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptions<GoogleAuthenticationOptions> options,
|
||||
ConfigureOptions<GoogleAuthenticationOptions> configureOptions = null)
|
||||
: base(next, dataProtectionProvider, loggerFactory, externalOptions, options, configureOptions)
|
||||
{
|
||||
if (Options.Notifications == null)
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ namespace Microsoft.AspNet.Builder
|
|||
{
|
||||
public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<MicrosoftAccountAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
public static IApplicationBuilder UseMicrosoftAccountAuthentication([NotNull] this IApplicationBuilder app, Action<MicrosoftAccountAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<MicrosoftAccountAuthenticationMiddleware>(
|
||||
new OptionsAction<MicrosoftAccountAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
new ConfigureOptions<MicrosoftAccountAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
{
|
||||
Name = optionsName
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ namespace Microsoft.AspNet.Security.MicrosoftAccount
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsAccessor<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptionsAccessor<MicrosoftAccountAuthenticationOptions> options,
|
||||
IOptionsAction<MicrosoftAccountAuthenticationOptions> configureOptions = null)
|
||||
IOptions<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptions<MicrosoftAccountAuthenticationOptions> options,
|
||||
ConfigureOptions<MicrosoftAccountAuthenticationOptions> configureOptions = null)
|
||||
: base(next, dataProtectionProvider, loggerFactory, externalOptions, options, configureOptions)
|
||||
{
|
||||
if (Options.Notifications == null)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Builder
|
|||
public static IApplicationBuilder UseOAuthAuthentication([NotNull] this IApplicationBuilder app, [NotNull] string authenticationType, Action<OAuthAuthenticationOptions<IOAuthAuthenticationNotifications>> configureOptions = null)
|
||||
{
|
||||
return app.UseMiddleware<OAuthAuthenticationMiddleware<OAuthAuthenticationOptions<IOAuthAuthenticationNotifications>, IOAuthAuthenticationNotifications>>(
|
||||
new OptionsAction<OAuthAuthenticationOptions<IOAuthAuthenticationNotifications>>(options =>
|
||||
new ConfigureOptions<OAuthAuthenticationOptions<IOAuthAuthenticationNotifications>>(options =>
|
||||
{
|
||||
options.AuthenticationType = authenticationType;
|
||||
options.Caption = authenticationType;
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ namespace Microsoft.AspNet.Security.OAuth
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsAccessor<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptionsAccessor<TOptions> options,
|
||||
IOptionsAction<TOptions> configureOptions = null)
|
||||
IOptions<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptions<TOptions> options,
|
||||
ConfigureOptions<TOptions> configureOptions = null)
|
||||
: base(next, options, configureOptions)
|
||||
{
|
||||
// todo: review error handling
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Builder
|
|||
public static IApplicationBuilder UseOAuthBearerAuthentication([NotNull] this IApplicationBuilder app, Action<OAuthBearerAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<OAuthBearerAuthenticationMiddleware>(
|
||||
new OptionsAction<OAuthBearerAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
new ConfigureOptions<OAuthBearerAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
{
|
||||
Name = optionsName
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ namespace Microsoft.AspNet.Security.OAuth
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsAccessor<OAuthBearerAuthenticationOptions> options,
|
||||
IOptionsAction<OAuthBearerAuthenticationOptions> configureOptions)
|
||||
IOptions<OAuthBearerAuthenticationOptions> options,
|
||||
ConfigureOptions<OAuthBearerAuthenticationOptions> configureOptions)
|
||||
: base(next, options, configureOptions)
|
||||
{
|
||||
_logger = loggerFactory.Create<OAuthBearerAuthenticationMiddleware>();
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ namespace Microsoft.AspNet.Builder
|
|||
{
|
||||
public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] Action<TwitterAuthenticationOptions> configure)
|
||||
{
|
||||
return services.ConfigureOptions(configure);
|
||||
return services.Configure(configure);
|
||||
}
|
||||
|
||||
public static IApplicationBuilder UseTwitterAuthentication([NotNull] this IApplicationBuilder app, Action<TwitterAuthenticationOptions> configureOptions = null, string optionsName = "")
|
||||
{
|
||||
return app.UseMiddleware<TwitterAuthenticationMiddleware>(
|
||||
new OptionsAction<TwitterAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
new ConfigureOptions<TwitterAuthenticationOptions>(configureOptions ?? (o => { }))
|
||||
{
|
||||
Name = optionsName
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ namespace Microsoft.AspNet.Security.Twitter
|
|||
RequestDelegate next,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsAccessor<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptionsAccessor<TwitterAuthenticationOptions> options,
|
||||
IOptionsAction<TwitterAuthenticationOptions> configureOptions = null)
|
||||
IOptions<ExternalAuthenticationOptions> externalOptions,
|
||||
IOptions<TwitterAuthenticationOptions> options,
|
||||
ConfigureOptions<TwitterAuthenticationOptions> configureOptions = null)
|
||||
: base(next, options, configureOptions)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Options.ConsumerSecret))
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ namespace Microsoft.AspNet.Security.Infrastructure
|
|||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
protected AuthenticationMiddleware([NotNull] RequestDelegate next, [NotNull] IOptionsAccessor<TOptions> options, IOptionsAction<TOptions> configureOptions)
|
||||
protected AuthenticationMiddleware([NotNull] RequestDelegate next, [NotNull] IOptions<TOptions> options, ConfigureOptions<TOptions> configureOptions)
|
||||
{
|
||||
if (configureOptions != null)
|
||||
{
|
||||
Options = options.GetNamedOptions(configureOptions.Name);
|
||||
configureOptions.Invoke(Options);
|
||||
configureOptions.Configure(Options, configureOptions.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ namespace Microsoft.AspNet.Security.Cookies
|
|||
{
|
||||
return TestServer.Create(app =>
|
||||
{
|
||||
app.UsePerRequestServices(services => { });
|
||||
app.UseServices(services => { });
|
||||
app.UseCookieAuthentication(configureOptions);
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Security.Facebook
|
|||
var server = CreateServer(
|
||||
app =>
|
||||
{
|
||||
app.UsePerRequestServices(services =>
|
||||
app.UseServices(services =>
|
||||
{
|
||||
services.ConfigureFacebookAuthentication(options =>
|
||||
{
|
||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Security.Facebook
|
|||
{
|
||||
options.AuthenticationType = "External";
|
||||
});
|
||||
services.ConfigureOptions<ExternalAuthenticationOptions>(options =>
|
||||
services.Configure<ExternalAuthenticationOptions>(options =>
|
||||
{
|
||||
options.SignInAsAuthenticationType = "External";
|
||||
});
|
||||
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Security.Facebook
|
|||
var server = CreateServer(
|
||||
app =>
|
||||
{
|
||||
app.UsePerRequestServices(services =>
|
||||
app.UseServices(services =>
|
||||
{
|
||||
services.ConfigureFacebookAuthentication(options =>
|
||||
{
|
||||
|
|
@ -81,7 +81,7 @@ namespace Microsoft.AspNet.Security.Facebook
|
|||
{
|
||||
options.AuthenticationType = "External";
|
||||
});
|
||||
services.ConfigureOptions<ExternalAuthenticationOptions>(options =>
|
||||
services.Configure<ExternalAuthenticationOptions>(options =>
|
||||
{
|
||||
options.SignInAsAuthenticationType = "External";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -465,9 +465,9 @@ namespace Microsoft.AspNet.Security.Google
|
|||
{
|
||||
return TestServer.Create(app =>
|
||||
{
|
||||
app.UsePerRequestServices(services =>
|
||||
app.UseServices(services =>
|
||||
{
|
||||
services.ConfigureOptions<ExternalAuthenticationOptions>(options =>
|
||||
services.Configure<ExternalAuthenticationOptions>(options =>
|
||||
{
|
||||
options.SignInAsAuthenticationType = CookieAuthenticationType;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -163,9 +163,9 @@ namespace Microsoft.AspNet.Security.Tests.MicrosoftAccount
|
|||
{
|
||||
return TestServer.Create(app =>
|
||||
{
|
||||
app.UsePerRequestServices(services =>
|
||||
app.UseServices(services =>
|
||||
{
|
||||
services.ConfigureOptions<ExternalAuthenticationOptions>(options =>
|
||||
services.Configure<ExternalAuthenticationOptions>(options =>
|
||||
{
|
||||
options.SignInAsAuthenticationType = "External";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -109,9 +109,9 @@ namespace Microsoft.AspNet.Security.Twitter
|
|||
{
|
||||
return TestServer.Create(app =>
|
||||
{
|
||||
app.UsePerRequestServices(services =>
|
||||
app.UseServices(services =>
|
||||
{
|
||||
services.ConfigureOptions<ExternalAuthenticationOptions>(options =>
|
||||
services.Configure<ExternalAuthenticationOptions>(options =>
|
||||
{
|
||||
options.SignInAsAuthenticationType = "External";
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue