Remove AddXyzAuth extension methods
This commit is contained in:
parent
a7bf561b1c
commit
1c30f33c92
|
|
@ -25,20 +25,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
|
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
|
||||||
return builder.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, configureOptions);
|
return builder.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// REMOVE below once callers have been updated
|
|
||||||
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme);
|
|
||||||
|
|
||||||
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme) => services.AddCookieAuthentication(authenticationScheme, configureOptions: null);
|
|
||||||
|
|
||||||
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, Action<CookieAuthenticationOptions> configureOptions) =>
|
|
||||||
services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions);
|
|
||||||
|
|
||||||
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action<CookieAuthenticationOptions> configureOptions)
|
|
||||||
{
|
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
|
|
||||||
return services.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action<FacebookOptions> configureOptions)
|
public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action<FacebookOptions> configureOptions)
|
||||||
=> builder.AddOAuth<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
|
=> builder.AddOAuth<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
|
||||||
|
|
||||||
|
|
||||||
// REMOVE below once callers have been updated
|
|
||||||
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services)
|
|
||||||
=> services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { });
|
|
||||||
|
|
||||||
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action<FacebookOptions> configureOptions)
|
|
||||||
=> services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions);
|
|
||||||
|
|
||||||
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action<FacebookOptions> configureOptions)
|
|
||||||
=> services.AddOAuthAuthentication<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action<GoogleOptions> configureOptions)
|
public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action<GoogleOptions> configureOptions)
|
||||||
=> builder.AddOAuth<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
|
=> builder.AddOAuth<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
|
||||||
|
|
||||||
|
|
||||||
// REMOVE below once callers have been updated
|
|
||||||
|
|
||||||
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services)
|
|
||||||
=> services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { });
|
|
||||||
|
|
||||||
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, Action<GoogleOptions> configureOptions)
|
|
||||||
=> services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions);
|
|
||||||
|
|
||||||
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action<GoogleOptions> configureOptions)
|
|
||||||
=> services.AddOAuthAuthentication<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
|
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
|
||||||
return builder.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
|
return builder.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// REMOVE once callers updated
|
|
||||||
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services)
|
|
||||||
=> services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { });
|
|
||||||
|
|
||||||
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action<JwtBearerOptions> configureOptions)
|
|
||||||
=> services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, configureOptions);
|
|
||||||
|
|
||||||
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action<JwtBearerOptions> configureOptions)
|
|
||||||
{
|
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
|
|
||||||
return services.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
|
public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
|
||||||
=> builder.AddOAuth<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
|
=> builder.AddOAuth<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
|
||||||
|
|
||||||
|
|
||||||
// REMOVE below once callers have been updated
|
|
||||||
|
|
||||||
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services)
|
|
||||||
=> services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { });
|
|
||||||
|
|
||||||
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action<MicrosoftAccountOptions> configureOptions)
|
|
||||||
=> services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions);
|
|
||||||
|
|
||||||
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
|
|
||||||
=> services.AddOAuthAuthentication<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,19 +21,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OAuthPostConfigureOptions<TOptions, THandler>>());
|
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OAuthPostConfigureOptions<TOptions, THandler>>());
|
||||||
return builder.AddRemoteScheme<TOptions, THandler>(authenticationScheme, authenticationScheme, configureOptions);
|
return builder.AddRemoteScheme<TOptions, THandler>(authenticationScheme, authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// REMOVE below once callers have been updated
|
|
||||||
public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action<OAuthOptions> configureOptions)
|
|
||||||
{
|
|
||||||
return services.AddOAuthAuthentication<OAuthOptions, OAuthHandler<OAuthOptions>>(authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IServiceCollection AddOAuthAuthentication<TOptions, THandler>(this IServiceCollection services, string authenticationScheme, Action<TOptions> configureOptions)
|
|
||||||
where TOptions : OAuthOptions, new()
|
|
||||||
where THandler : OAuthHandler<TOptions>
|
|
||||||
{
|
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OAuthPostConfigureOptions<TOptions, THandler>>());
|
|
||||||
return services.AddRemoteScheme<TOptions, THandler>(authenticationScheme, authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
|
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
|
||||||
return builder.AddRemoteScheme<OpenIdConnectOptions, OpenIdConnectHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
return builder.AddRemoteScheme<OpenIdConnectOptions, OpenIdConnectHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// REMOVE once callers have been updated
|
|
||||||
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services)
|
|
||||||
=> services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { });
|
|
||||||
|
|
||||||
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, Action<OpenIdConnectOptions> configureOptions)
|
|
||||||
=> services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, configureOptions);
|
|
||||||
|
|
||||||
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action<OpenIdConnectOptions> configureOptions)
|
|
||||||
{
|
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
|
|
||||||
return services.AddRemoteScheme<OpenIdConnectOptions, OpenIdConnectHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,5 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
|
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
|
||||||
return builder.AddRemoteScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
return builder.AddRemoteScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// REMOVE below once callers have been updated.
|
|
||||||
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services)
|
|
||||||
=> services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { });
|
|
||||||
|
|
||||||
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action<TwitterOptions> configureOptions)
|
|
||||||
=> services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions);
|
|
||||||
|
|
||||||
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action<TwitterOptions> configureOptions)
|
|
||||||
{
|
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
|
|
||||||
return services.AddRemoteScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@ namespace Microsoft.AspNetCore.Authentication
|
||||||
OriginalPathBase = context.Request.PathBase
|
OriginalPathBase = context.Request.PathBase
|
||||||
});
|
});
|
||||||
|
|
||||||
// REVIEW: alternatively could depend on a routing middleware to do this
|
|
||||||
|
|
||||||
// Give any IAuthenticationRequestHandler schemes a chance to handle the request
|
// Give any IAuthenticationRequestHandler schemes a chance to handle the request
|
||||||
var handlers = context.RequestServices.GetRequiredService<IAuthenticationHandlerProvider>();
|
var handlers = context.RequestServices.GetRequiredService<IAuthenticationHandlerProvider>();
|
||||||
foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync())
|
foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync())
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
|
@ -16,10 +15,8 @@ using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.TestHost;
|
using Microsoft.AspNetCore.TestHost;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -30,7 +27,8 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task VerifySchemeDefaults()
|
public async Task VerifySchemeDefaults()
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
|
var services = new ServiceCollection();
|
||||||
|
services.AddAuthentication().AddFacebook();
|
||||||
var sp = services.BuildServiceProvider();
|
var sp = services.BuildServiceProvider();
|
||||||
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
||||||
var scheme = await schemeProvider.GetSchemeAsync(FacebookDefaults.AuthenticationScheme);
|
var scheme = await schemeProvider.GetSchemeAsync(FacebookDefaults.AuthenticationScheme);
|
||||||
|
|
@ -44,7 +42,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
services => services.AddFacebookAuthentication(o => o.SignInScheme = "Whatever"),
|
services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = "Whatever"),
|
||||||
context =>
|
context =>
|
||||||
{
|
{
|
||||||
// REVIEW: Gross.
|
// REVIEW: Gross.
|
||||||
|
|
@ -60,7 +58,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
services => services.AddFacebookAuthentication(o => o.AppId = "Whatever"),
|
services => services.AddAuthentication().AddFacebook(o => o.AppId = "Whatever"),
|
||||||
context =>
|
context =>
|
||||||
{
|
{
|
||||||
// REVIEW: Gross.
|
// REVIEW: Gross.
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ namespace Microsoft.AspNetCore.Authentication.Google
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task VerifySchemeDefaults()
|
public async Task VerifySchemeDefaults()
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
|
var services = new ServiceCollection();
|
||||||
|
services.AddAuthentication().AddGoogle();
|
||||||
var sp = services.BuildServiceProvider();
|
var sp = services.BuildServiceProvider();
|
||||||
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
||||||
var scheme = await schemeProvider.GetSchemeAsync(GoogleDefaults.AuthenticationScheme);
|
var scheme = await schemeProvider.GetSchemeAsync(GoogleDefaults.AuthenticationScheme);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task VerifySchemeDefaults()
|
public async Task VerifySchemeDefaults()
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
|
var services = new ServiceCollection();
|
||||||
|
services.AddAuthentication().AddJwtBearer();
|
||||||
var sp = services.BuildServiceProvider();
|
var sp = services.BuildServiceProvider();
|
||||||
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
||||||
var scheme = await schemeProvider.GetSchemeAsync(JwtBearerDefaults.AuthenticationScheme);
|
var scheme = await schemeProvider.GetSchemeAsync(JwtBearerDefaults.AuthenticationScheme);
|
||||||
|
|
@ -747,7 +748,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.ConfigureServices(services => services.AddJwtBearerAuthentication(options));
|
.ConfigureServices(services => services.AddAuthentication().AddJwtBearer(options));
|
||||||
|
|
||||||
return new TestServer(builder);
|
return new TestServer(builder);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task VerifySchemeDefaults()
|
public async Task VerifySchemeDefaults()
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
|
var services = new ServiceCollection();
|
||||||
|
services.AddAuthentication().AddMicrosoftAccount();
|
||||||
var sp = services.BuildServiceProvider();
|
var sp = services.BuildServiceProvider();
|
||||||
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
||||||
var scheme = await schemeProvider.GetSchemeAsync(MicrosoftAccountDefaults.AuthenticationScheme);
|
var scheme = await schemeProvider.GetSchemeAsync(MicrosoftAccountDefaults.AuthenticationScheme);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task VerifySchemeDefaults()
|
public async Task VerifySchemeDefaults()
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection().AddOAuthAuthentication("oauth", o => { });
|
var services = new ServiceCollection();
|
||||||
|
services.AddAuthentication().AddOAuth("oauth", o => { });
|
||||||
var sp = services.BuildServiceProvider();
|
var sp = services.BuildServiceProvider();
|
||||||
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
||||||
var scheme = await schemeProvider.GetSchemeAsync("oauth");
|
var scheme = await schemeProvider.GetSchemeAsync("oauth");
|
||||||
|
|
@ -33,7 +34,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
services => services.AddOAuthAuthentication("weeblie", o =>
|
services => services.AddAuthentication().AddOAuth("weeblie", o =>
|
||||||
{
|
{
|
||||||
o.SignInScheme = "whatever";
|
o.SignInScheme = "whatever";
|
||||||
o.CallbackPath = "/";
|
o.CallbackPath = "/";
|
||||||
|
|
@ -56,7 +57,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
services => services.AddOAuthAuthentication("weeblie", o =>
|
services => services.AddAuthentication().AddOAuth("weeblie", o =>
|
||||||
{
|
{
|
||||||
o.SignInScheme = "whatever";
|
o.SignInScheme = "whatever";
|
||||||
o.ClientId = "Whatever;";
|
o.ClientId = "Whatever;";
|
||||||
|
|
@ -79,7 +80,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
services => services.AddOAuthAuthentication("weeblie", o =>
|
services => services.AddAuthentication().AddOAuth("weeblie", o =>
|
||||||
{
|
{
|
||||||
o.ClientId = "Whatever;";
|
o.ClientId = "Whatever;";
|
||||||
o.ClientSecret = "Whatever;";
|
o.ClientSecret = "Whatever;";
|
||||||
|
|
@ -102,7 +103,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
services => services.AddOAuthAuthentication("weeblie", o =>
|
services => services.AddAuthentication().AddOAuth("weeblie", o =>
|
||||||
{
|
{
|
||||||
o.ClientId = "Whatever;";
|
o.ClientId = "Whatever;";
|
||||||
o.ClientSecret = "Whatever;";
|
o.ClientSecret = "Whatever;";
|
||||||
|
|
@ -125,7 +126,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
services => services.AddOAuthAuthentication("weeblie", o =>
|
services => services.AddAuthentication().AddOAuth("weeblie", o =>
|
||||||
{
|
{
|
||||||
o.ClientId = "Whatever;";
|
o.ClientId = "Whatever;";
|
||||||
o.ClientSecret = "Whatever;";
|
o.ClientSecret = "Whatever;";
|
||||||
|
|
@ -148,7 +149,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
s => s.AddOAuthAuthentication(
|
s => s.AddAuthentication().AddOAuth(
|
||||||
"Weblie",
|
"Weblie",
|
||||||
opt =>
|
opt =>
|
||||||
{
|
{
|
||||||
|
|
@ -180,7 +181,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
|
||||||
{
|
{
|
||||||
var server = CreateServer(
|
var server = CreateServer(
|
||||||
app => { },
|
app => { },
|
||||||
s => s.AddOAuthAuthentication(
|
s => s.AddAuthentication().AddOAuth(
|
||||||
"Weblie",
|
"Weblie",
|
||||||
opt =>
|
opt =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.TestHost;
|
using Microsoft.AspNetCore.TestHost;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -21,7 +20,8 @@ namespace Microsoft.AspNetCore.Authentication.Twitter
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task VerifySchemeDefaults()
|
public async Task VerifySchemeDefaults()
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
|
var services = new ServiceCollection();
|
||||||
|
services.AddAuthentication().AddTwitter();
|
||||||
var sp = services.BuildServiceProvider();
|
var sp = services.BuildServiceProvider();
|
||||||
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
|
||||||
var scheme = await schemeProvider.GetSchemeAsync(TwitterDefaults.AuthenticationScheme);
|
var scheme = await schemeProvider.GetSchemeAsync(TwitterDefaults.AuthenticationScheme);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue