Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 1c30f33

Browse files
committed
Remove AddXyzAuth extension methods
1 parent a7bf561 commit 1c30f33

File tree

15 files changed

+22
-126
lines changed

15 files changed

+22
-126
lines changed

src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,5 @@ public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder
2525
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
2626
return builder.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, configureOptions);
2727
}
28-
29-
30-
// REMOVE below once callers have been updated
31-
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme);
32-
33-
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme) => services.AddCookieAuthentication(authenticationScheme, configureOptions: null);
34-
35-
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, Action<CookieAuthenticationOptions> configureOptions) =>
36-
services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions);
37-
38-
public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action<CookieAuthenticationOptions> configureOptions)
39-
{
40-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
41-
return services.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, configureOptions);
42-
}
4328
}
4429
}

src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,5 @@ public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder build
1717

1818
public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action<FacebookOptions> configureOptions)
1919
=> builder.AddOAuth<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
20-
21-
22-
// REMOVE below once callers have been updated
23-
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services)
24-
=> services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { });
25-
26-
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action<FacebookOptions> configureOptions)
27-
=> services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions);
28-
29-
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action<FacebookOptions> configureOptions)
30-
=> services.AddOAuthAuthentication<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
3120
}
3221
}

src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,5 @@ public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder
1717

1818
public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action<GoogleOptions> configureOptions)
1919
=> builder.AddOAuth<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
20-
21-
22-
// REMOVE below once callers have been updated
23-
24-
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services)
25-
=> services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { });
26-
27-
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, Action<GoogleOptions> configureOptions)
28-
=> services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions);
29-
30-
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action<GoogleOptions> configureOptions)
31-
=> services.AddOAuthAuthentication<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
3220
}
3321
}

src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,5 @@ public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder buil
2222
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
2323
return builder.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
2424
}
25-
26-
27-
// REMOVE once callers updated
28-
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services)
29-
=> services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { });
30-
31-
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action<JwtBearerOptions> configureOptions)
32-
=> services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, configureOptions);
33-
34-
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action<JwtBearerOptions> configureOptions)
35-
{
36-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
37-
return services.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
38-
}
3925
}
4026
}

src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,5 @@ public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuild
1717

1818
public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
1919
=> builder.AddOAuth<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
20-
21-
22-
// REMOVE below once callers have been updated
23-
24-
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services)
25-
=> services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { });
26-
27-
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action<MicrosoftAccountOptions> configureOptions)
28-
=> services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions);
29-
30-
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
31-
=> services.AddOAuthAuthentication<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
3220
}
3321
}

src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,5 @@ public static AuthenticationBuilder AddOAuth<TOptions, THandler>(this Authentica
2121
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OAuthPostConfigureOptions<TOptions, THandler>>());
2222
return builder.AddRemoteScheme<TOptions, THandler>(authenticationScheme, authenticationScheme, configureOptions);
2323
}
24-
25-
// REMOVE below once callers have been updated
26-
public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action<OAuthOptions> configureOptions)
27-
{
28-
return services.AddOAuthAuthentication<OAuthOptions, OAuthHandler<OAuthOptions>>(authenticationScheme, configureOptions);
29-
}
30-
31-
public static IServiceCollection AddOAuthAuthentication<TOptions, THandler>(this IServiceCollection services, string authenticationScheme, Action<TOptions> configureOptions)
32-
where TOptions : OAuthOptions, new()
33-
where THandler : OAuthHandler<TOptions>
34-
{
35-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TOptions>, OAuthPostConfigureOptions<TOptions, THandler>>());
36-
return services.AddRemoteScheme<TOptions, THandler>(authenticationScheme, authenticationScheme, configureOptions);
37-
}
3824
}
3925
}

src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,5 @@ public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder
2222
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
2323
return builder.AddRemoteScheme<OpenIdConnectOptions, OpenIdConnectHandler>(authenticationScheme, authenticationScheme, configureOptions);
2424
}
25-
26-
// REMOVE once callers have been updated
27-
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services)
28-
=> services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { });
29-
30-
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, Action<OpenIdConnectOptions> configureOptions)
31-
=> services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, configureOptions);
32-
33-
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action<OpenIdConnectOptions> configureOptions)
34-
{
35-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
36-
return services.AddRemoteScheme<OpenIdConnectOptions, OpenIdConnectHandler>(authenticationScheme, authenticationScheme, configureOptions);
37-
}
3825
}
3926
}

src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,5 @@ public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builde
2222
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
2323
return builder.AddRemoteScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
2424
}
25-
26-
// REMOVE below once callers have been updated.
27-
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services)
28-
=> services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { });
29-
30-
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action<TwitterOptions> configureOptions)
31-
=> services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions);
32-
33-
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action<TwitterOptions> configureOptions)
34-
{
35-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
36-
return services.AddRemoteScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
37-
}
3825
}
3926
}

src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public async Task Invoke(HttpContext context)
3737
OriginalPathBase = context.Request.PathBase
3838
});
3939

40-
// REVIEW: alternatively could depend on a routing middleware to do this
41-
4240
// Give any IAuthenticationRequestHandler schemes a chance to handle the request
4341
var handlers = context.RequestServices.GetRequiredService<IAuthenticationHandlerProvider>();
4442
foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync())

test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
65
using System.Linq;
76
using System.Net;
87
using System.Net.Http;
@@ -16,10 +15,8 @@
1615
using Microsoft.AspNetCore.Hosting;
1716
using Microsoft.AspNetCore.Http;
1817
using Microsoft.AspNetCore.TestHost;
19-
using Microsoft.Extensions.Configuration;
2018
using Microsoft.Extensions.DependencyInjection;
2119
using Microsoft.Extensions.Logging.Abstractions;
22-
using Microsoft.Extensions.Options;
2320
using Newtonsoft.Json;
2421
using Xunit;
2522

@@ -30,7 +27,8 @@ public class FacebookTests
3027
[Fact]
3128
public async Task VerifySchemeDefaults()
3229
{
33-
var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
30+
var services = new ServiceCollection();
31+
services.AddAuthentication().AddFacebook();
3432
var sp = services.BuildServiceProvider();
3533
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
3634
var scheme = await schemeProvider.GetSchemeAsync(FacebookDefaults.AuthenticationScheme);
@@ -44,7 +42,7 @@ public async Task ThrowsIfAppIdMissing()
4442
{
4543
var server = CreateServer(
4644
app => { },
47-
services => services.AddFacebookAuthentication(o => o.SignInScheme = "Whatever"),
45+
services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = "Whatever"),
4846
context =>
4947
{
5048
// REVIEW: Gross.
@@ -60,7 +58,7 @@ public async Task ThrowsIfAppSecretMissing()
6058
{
6159
var server = CreateServer(
6260
app => { },
63-
services => services.AddFacebookAuthentication(o => o.AppId = "Whatever"),
61+
services => services.AddAuthentication().AddFacebook(o => o.AppId = "Whatever"),
6462
context =>
6563
{
6664
// REVIEW: Gross.

test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public class GoogleTests
2929
[Fact]
3030
public async Task VerifySchemeDefaults()
3131
{
32-
var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
32+
var services = new ServiceCollection();
33+
services.AddAuthentication().AddGoogle();
3334
var sp = services.BuildServiceProvider();
3435
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
3536
var scheme = await schemeProvider.GetSchemeAsync(GoogleDefaults.AuthenticationScheme);

test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public class JwtBearerTests
2929
[Fact]
3030
public async Task VerifySchemeDefaults()
3131
{
32-
var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
32+
var services = new ServiceCollection();
33+
services.AddAuthentication().AddJwtBearer();
3334
var sp = services.BuildServiceProvider();
3435
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
3536
var scheme = await schemeProvider.GetSchemeAsync(JwtBearerDefaults.AuthenticationScheme);
@@ -747,7 +748,7 @@ private static TestServer CreateServer(Action<JwtBearerOptions> options = null,
747748
}
748749
});
749750
})
750-
.ConfigureServices(services => services.AddJwtBearerAuthentication(options));
751+
.ConfigureServices(services => services.AddAuthentication().AddJwtBearer(options));
751752

752753
return new TestServer(builder);
753754
}

test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public class MicrosoftAccountTests
3030
[Fact]
3131
public async Task VerifySchemeDefaults()
3232
{
33-
var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
33+
var services = new ServiceCollection();
34+
services.AddAuthentication().AddMicrosoftAccount();
3435
var sp = services.BuildServiceProvider();
3536
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
3637
var scheme = await schemeProvider.GetSchemeAsync(MicrosoftAccountDefaults.AuthenticationScheme);

test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class OAuthTests
1919
[Fact]
2020
public async Task VerifySchemeDefaults()
2121
{
22-
var services = new ServiceCollection().AddOAuthAuthentication("oauth", o => { });
22+
var services = new ServiceCollection();
23+
services.AddAuthentication().AddOAuth("oauth", o => { });
2324
var sp = services.BuildServiceProvider();
2425
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
2526
var scheme = await schemeProvider.GetSchemeAsync("oauth");
@@ -33,7 +34,7 @@ public async Task ThrowsIfClientIdMissing()
3334
{
3435
var server = CreateServer(
3536
app => { },
36-
services => services.AddOAuthAuthentication("weeblie", o =>
37+
services => services.AddAuthentication().AddOAuth("weeblie", o =>
3738
{
3839
o.SignInScheme = "whatever";
3940
o.CallbackPath = "/";
@@ -56,7 +57,7 @@ public async Task ThrowsIfClientSecretMissing()
5657
{
5758
var server = CreateServer(
5859
app => { },
59-
services => services.AddOAuthAuthentication("weeblie", o =>
60+
services => services.AddAuthentication().AddOAuth("weeblie", o =>
6061
{
6162
o.SignInScheme = "whatever";
6263
o.ClientId = "Whatever;";
@@ -79,7 +80,7 @@ public async Task ThrowsIfCallbackPathMissing()
7980
{
8081
var server = CreateServer(
8182
app => { },
82-
services => services.AddOAuthAuthentication("weeblie", o =>
83+
services => services.AddAuthentication().AddOAuth("weeblie", o =>
8384
{
8485
o.ClientId = "Whatever;";
8586
o.ClientSecret = "Whatever;";
@@ -102,7 +103,7 @@ public async Task ThrowsIfTokenEndpointMissing()
102103
{
103104
var server = CreateServer(
104105
app => { },
105-
services => services.AddOAuthAuthentication("weeblie", o =>
106+
services => services.AddAuthentication().AddOAuth("weeblie", o =>
106107
{
107108
o.ClientId = "Whatever;";
108109
o.ClientSecret = "Whatever;";
@@ -125,7 +126,7 @@ public async Task ThrowsIfAuthorizationEndpointMissing()
125126
{
126127
var server = CreateServer(
127128
app => { },
128-
services => services.AddOAuthAuthentication("weeblie", o =>
129+
services => services.AddAuthentication().AddOAuth("weeblie", o =>
129130
{
130131
o.ClientId = "Whatever;";
131132
o.ClientSecret = "Whatever;";
@@ -148,7 +149,7 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB
148149
{
149150
var server = CreateServer(
150151
app => { },
151-
s => s.AddOAuthAuthentication(
152+
s => s.AddAuthentication().AddOAuth(
152153
"Weblie",
153154
opt =>
154155
{
@@ -180,7 +181,7 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv
180181
{
181182
var server = CreateServer(
182183
app => { },
183-
s => s.AddOAuthAuthentication(
184+
s => s.AddAuthentication().AddOAuth(
184185
"Weblie",
185186
opt =>
186187
{

test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Microsoft.AspNetCore.Hosting;
1111
using Microsoft.AspNetCore.Http;
1212
using Microsoft.AspNetCore.TestHost;
13-
using Microsoft.Extensions.Configuration;
1413
using Microsoft.Extensions.DependencyInjection;
1514
using Xunit;
1615

@@ -21,7 +20,8 @@ public class TwitterTests
2120
[Fact]
2221
public async Task VerifySchemeDefaults()
2322
{
24-
var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
23+
var services = new ServiceCollection();
24+
services.AddAuthentication().AddTwitter();
2525
var sp = services.BuildServiceProvider();
2626
var schemeProvider = sp.GetRequiredService<IAuthenticationSchemeProvider>();
2727
var scheme = await schemeProvider.GetSchemeAsync(TwitterDefaults.AuthenticationScheme);

0 commit comments

Comments
 (0)