Skip to content

Commit 697b397

Browse files
authored
Revert AuthenticationAddXyz overload changes (#24253)
1 parent 6f37e8a commit 697b397

File tree

14 files changed

+28
-437
lines changed

14 files changed

+28
-437
lines changed

src/Identity/Core/src/IdentityServiceCollectionExtensions.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,6 @@ public static IdentityBuilder AddIdentity<TUser, TRole>(
110110
public static IServiceCollection ConfigureApplicationCookie(this IServiceCollection services, Action<CookieAuthenticationOptions> configure)
111111
=> services.Configure(IdentityConstants.ApplicationScheme, configure);
112112

113-
/// <summary>
114-
/// Configures the application cookie.
115-
/// </summary>
116-
/// <typeparam name="TService">TService: A service resolved from the IServiceProvider for use when configuring this authentication provider. If you need multiple services then specify IServiceProvider and resolve them directly.</typeparam>
117-
/// <param name="services">The services available in the application.</param>
118-
/// <param name="configure">An action to configure the <see cref="CookieAuthenticationOptions"/>.</param>
119-
/// <returns>The services.</returns>
120-
public static IServiceCollection ConfigureApplicationCookie<TService>(this IServiceCollection services, Action<CookieAuthenticationOptions, TService> configure) where TService : class
121-
{
122-
services.AddOptions<CookieAuthenticationOptions>(IdentityConstants.ApplicationScheme)
123-
.Configure(configure);
124-
125-
return services;
126-
}
127-
128113
/// <summary>
129114
/// Configure the external cookie.
130115
/// </summary>
@@ -133,20 +118,5 @@ public static IServiceCollection ConfigureApplicationCookie<TService>(this IServ
133118
/// <returns>The services.</returns>
134119
public static IServiceCollection ConfigureExternalCookie(this IServiceCollection services, Action<CookieAuthenticationOptions> configure)
135120
=> services.Configure(IdentityConstants.ExternalScheme, configure);
136-
137-
/// <summary>
138-
/// Configure the external cookie.
139-
/// </summary>
140-
/// <typeparam name="TService">TService: A service resolved from the IServiceProvider for use when configuring this authentication provider. If you need multiple services then specify IServiceProvider and resolve them directly.</typeparam>
141-
/// <param name="services">The services available in the application.</param>
142-
/// <param name="configure">An action to configure the <see cref="CookieAuthenticationOptions"/>.</param>
143-
/// <returns>The services.</returns>
144-
public static IServiceCollection ConfigureExternalCookie<TService>(this IServiceCollection services, Action<CookieAuthenticationOptions, TService> configure) where TService : class
145-
{
146-
services.AddOptions<CookieAuthenticationOptions>(IdentityConstants.ExternalScheme)
147-
.Configure(configure);
148-
149-
return services;
150-
}
151121
}
152122
}

src/Security/Authentication/Certificate/src/CertificateAuthenticationExtensions.cs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static AuthenticationBuilder AddCertificate(this AuthenticationBuilder bu
2828
/// <param name="authenticationScheme"></param>
2929
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
3030
public static AuthenticationBuilder AddCertificate(this AuthenticationBuilder builder, string authenticationScheme)
31-
=> builder.AddCertificate(authenticationScheme, configureOptions: (Action<CertificateAuthenticationOptions, IServiceProvider>)null);
31+
=> builder.AddCertificate(authenticationScheme, configureOptions: null);
3232

3333
/// <summary>
3434
/// Adds certificate authentication.
@@ -39,16 +39,6 @@ public static AuthenticationBuilder AddCertificate(this AuthenticationBuilder bu
3939
public static AuthenticationBuilder AddCertificate(this AuthenticationBuilder builder, Action<CertificateAuthenticationOptions> configureOptions)
4040
=> builder.AddCertificate(CertificateAuthenticationDefaults.AuthenticationScheme, configureOptions);
4141

42-
/// <summary>
43-
/// Adds certificate authentication.
44-
/// </summary>
45-
/// <typeparam name="TService">TService: A service resolved from the IServiceProvider for use when configuring this authentication provider. If you need multiple services then specify IServiceProvider and resolve them directly.</typeparam>
46-
/// <param name="builder">The <see cref="AuthenticationBuilder"/>.</param>
47-
/// <param name="configureOptions"></param>
48-
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
49-
public static AuthenticationBuilder AddCertificate<TService>(this AuthenticationBuilder builder, Action<CertificateAuthenticationOptions, TService> configureOptions) where TService : class
50-
=> builder.AddCertificate(CertificateAuthenticationDefaults.AuthenticationScheme, configureOptions);
51-
5242
/// <summary>
5343
/// Adds certificate authentication.
5444
/// </summary>
@@ -60,33 +50,7 @@ public static AuthenticationBuilder AddCertificate(
6050
this AuthenticationBuilder builder,
6151
string authenticationScheme,
6252
Action<CertificateAuthenticationOptions> configureOptions)
63-
{
64-
Action<CertificateAuthenticationOptions, IServiceProvider> configureOptionsWithServices;
65-
if (configureOptions == null)
66-
{
67-
configureOptionsWithServices = null;
68-
}
69-
else
70-
{
71-
configureOptionsWithServices = (options, _) => configureOptions(options);
72-
}
73-
74-
return builder.AddCertificate(authenticationScheme, configureOptionsWithServices);
75-
}
76-
77-
/// <summary>
78-
/// Adds certificate authentication.
79-
/// </summary>
80-
/// <typeparam name="TService">TService: A service resolved from the IServiceProvider for use when configuring this authentication provider. If you need multiple services then specify IServiceProvider and resolve them directly.</typeparam>
81-
/// <param name="builder">The <see cref="AuthenticationBuilder"/>.</param>
82-
/// <param name="authenticationScheme"></param>
83-
/// <param name="configureOptions"></param>
84-
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
85-
public static AuthenticationBuilder AddCertificate<TService>(
86-
this AuthenticationBuilder builder,
87-
string authenticationScheme,
88-
Action<CertificateAuthenticationOptions, TService> configureOptions) where TService : class
89-
=> builder.AddScheme<CertificateAuthenticationOptions, CertificateAuthenticationHandler, TService>(authenticationScheme, configureOptions);
53+
=> builder.AddScheme<CertificateAuthenticationOptions, CertificateAuthenticationHandler>(authenticationScheme, configureOptions);
9054

9155
/// <summary>
9256
/// Adds certificate authentication.

src/Security/Authentication/Cookies/samples/CookieSessionSample/Startup.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ public class Startup
1414
{
1515
public void ConfigureServices(IServiceCollection services)
1616
{
17-
services.AddSingleton<MemoryCacheTicketStore>();
18-
1917
// This can be removed after https://github.com/aspnet/IISIntegration/issues/371
2018
services.AddAuthentication(options =>
2119
{
2220
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
2321
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
24-
}).AddCookie<MemoryCacheTicketStore>((o, ticketStore) => o.SessionStore = ticketStore);
22+
}).AddCookie();
23+
24+
services.AddOptions<CookieAuthenticationOptions>(CookieAuthenticationDefaults.AuthenticationScheme)
25+
.Configure<MemoryCacheTicketStore>((o, ticketStore) => o.SessionStore = ticketStore);
2526
}
2627

2728
public void Configure(IApplicationBuilder app)

src/Security/Authentication/Cookies/src/CookieExtensions.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,19 @@ public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder
1515
=> builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme);
1616

1717
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme)
18-
=> builder.AddCookie(authenticationScheme, configureOptions: (Action<CookieAuthenticationOptions, IServiceProvider>)null);
18+
=> builder.AddCookie(authenticationScheme, configureOptions: null);
1919

20-
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, Action<CookieAuthenticationOptions> configureOptions)
21-
=> builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions);
22-
23-
public static AuthenticationBuilder AddCookie<TService>(this AuthenticationBuilder builder, Action<CookieAuthenticationOptions, TService> configureOptions) where TService : class
20+
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, Action<CookieAuthenticationOptions> configureOptions)
2421
=> builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions);
2522

2623
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action<CookieAuthenticationOptions> configureOptions)
2724
=> builder.AddCookie(authenticationScheme, displayName: null, configureOptions: configureOptions);
2825

29-
public static AuthenticationBuilder AddCookie<TService>(this AuthenticationBuilder builder, string authenticationScheme, Action<CookieAuthenticationOptions, TService> configureOptions) where TService : class
30-
=> builder.AddCookie(authenticationScheme, displayName: null, configureOptions: configureOptions);
31-
3226
public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<CookieAuthenticationOptions> configureOptions)
33-
{
34-
Action<CookieAuthenticationOptions, IServiceProvider> configureOptionsWithServices;
35-
if (configureOptions == null)
36-
{
37-
configureOptionsWithServices = null;
38-
}
39-
else
40-
{
41-
configureOptionsWithServices = (options, _) => configureOptions(options);
42-
}
43-
44-
return builder.AddCookie(authenticationScheme, displayName, configureOptionsWithServices);
45-
}
46-
47-
public static AuthenticationBuilder AddCookie<TService>(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<CookieAuthenticationOptions, TService> configureOptions) where TService : class
4827
{
4928
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
5029
builder.Services.AddOptions<CookieAuthenticationOptions>(authenticationScheme).Validate(o => o.Cookie.Expiration == null, "Cookie.Expiration is ignored, use ExpireTimeSpan instead.");
51-
return builder.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler, TService>(authenticationScheme, displayName, configureOptions);
30+
return builder.AddScheme<CookieAuthenticationOptions, CookieAuthenticationHandler>(authenticationScheme, displayName, configureOptions);
5231
}
5332
}
5433
}

0 commit comments

Comments
 (0)