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.

0 commit comments

Comments
 (0)