Add AddAuthentication(defaultScheme) overload

This commit is contained in:
Hao Kung 2017-07-07 12:04:32 -07:00 committed by Hao Kung
parent 38d33cfbf2
commit df325deaf3
6 changed files with 9 additions and 20 deletions

View File

@ -27,6 +27,9 @@ namespace Microsoft.Extensions.DependencyInjection
return new AuthenticationBuilder(services);
}
public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, string defaultScheme)
=> services.AddAuthentication(o => o.DefaultScheme = defaultScheme);
public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, Action<AuthenticationOptions> configureOptions) {
if (services == null)
{

View File

@ -1247,7 +1247,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
=> CreateServerWithServices(s =>
{
s.AddSingleton<ISystemClock>(_clock);
s.AddAuthentication(o => o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions);
s.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions);
s.AddSingleton<IClaimsTransformation, ClaimsTransformer>();
}, testpath, baseAddress);

View File

@ -79,10 +79,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
},
services =>
{
services.AddAuthentication(options =>
{
options.DefaultScheme = "External";
})
services.AddAuthentication("External")
.AddCookie("External", o => { })
.AddFacebook(o =>
{
@ -218,10 +215,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
app => app.UseAuthentication(),
services =>
{
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie()
.AddFacebook(o =>
{

View File

@ -748,7 +748,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer
}
});
})
.ConfigureServices(services => services.AddAuthentication(o => o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options));
.ConfigureServices(services => services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options));
return new TestServer(builder);
}

View File

@ -224,11 +224,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount
})
.ConfigureServices(services =>
{
services.AddAuthentication(o =>
{
o.DefaultScheme = TestExtensions.CookieAuthenticationScheme;
});
services.AddAuthentication()
services.AddAuthentication(TestExtensions.CookieAuthenticationScheme)
.AddCookie(TestExtensions.CookieAuthenticationScheme, o => { })
.AddMicrosoftAccount(configureOptions);
});

View File

@ -109,11 +109,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect
})
.ConfigureServices(services =>
{
services.AddAuthentication(o =>
{
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});
services.AddAuthentication()
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie()
.AddOpenIdConnect(options);
});