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

Commit b1f92fb

Browse files
committed
Forbid + obsolete context.Authentication
1 parent 9428d17 commit b1f92fb

File tree

18 files changed

+91
-251
lines changed

18 files changed

+91
-251
lines changed

src/Microsoft.AspNetCore.Authentication.Abstractions/AuthenticationHttpContextExtensions.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,7 @@ public static Task ChallengeAsync(this HttpContext context, AuthenticationProper
6464
/// <param name="properties">The <see cref="AuthenticationProperties"/> properties.</param>
6565
/// <returns>The task.</returns>
6666
public static Task ChallengeAsync(this HttpContext context, string scheme, AuthenticationProperties properties) =>
67-
context.ChallengeAsync(scheme, properties: properties, behavior: ChallengeBehavior.Automatic);
68-
69-
/// <summary>
70-
/// Extension method for Challenge.
71-
/// </summary>
72-
/// <param name="context">The <see cref="HttpContext"/> context.</param>
73-
/// <param name="scheme">The name of the authentication scheme.</param>
74-
/// <param name="properties">The <see cref="AuthenticationProperties"/> properties.</param>
75-
/// <param name="behavior">The <see cref="ChallengeBehavior"/> behavior.</param>
76-
/// <returns>The task.</returns>
77-
public static Task ChallengeAsync(this HttpContext context, string scheme, AuthenticationProperties properties, ChallengeBehavior behavior) =>
78-
context.RequestServices.GetRequiredService<IAuthenticationService>().ChallengeAsync(context, scheme, properties, behavior);
67+
context.RequestServices.GetRequiredService<IAuthenticationService>().ChallengeAsync(context, scheme, properties);
7968

8069
/// <summary>
8170
/// Extension method for Forbid.
@@ -111,7 +100,7 @@ public static Task ForbidAsync(this HttpContext context, AuthenticationPropertie
111100
/// <param name="properties">The <see cref="AuthenticationProperties"/> properties.</param>
112101
/// <returns>The task.</returns>
113102
public static Task ForbidAsync(this HttpContext context, string scheme, AuthenticationProperties properties) =>
114-
context.RequestServices.GetRequiredService<IAuthenticationService>().ChallengeAsync(context, scheme, properties, ChallengeBehavior.Forbidden);
103+
context.RequestServices.GetRequiredService<IAuthenticationService>().ForbidAsync(context, scheme, properties);
115104

116105
/// <summary>
117106
/// Extension method for SignIn.

src/Microsoft.AspNetCore.Authentication.Abstractions/AuthenticationOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void AddScheme(string name, Action<AuthenticationSchemeBuilder> configure
5858
public string DefaultSignInScheme { get; set; }
5959

6060
/// <summary>
61-
/// Used by as the default scheme by <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties, ChallengeBehavior)"/>.
61+
/// Used by as the default scheme by <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties)"/>.
6262
/// </summary>
6363
public string DefaultChallengeScheme { get; set; }
6464
}

src/Microsoft.AspNetCore.Authentication.Abstractions/BaseAuthenticationContext.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/Microsoft.AspNetCore.Authentication.Abstractions/BaseContext.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Microsoft.AspNetCore.Authentication.Abstractions/ChallengeBehavior.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Microsoft.AspNetCore.Authentication.Abstractions/ChallengeContext.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/Microsoft.AspNetCore.Authentication.Abstractions/IAuthenticationHandler.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System.Security.Claims;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Http;
67

@@ -28,22 +29,30 @@ public interface IAuthenticationHandler
2829
/// <summary>
2930
/// Challenge behavior.
3031
/// </summary>
31-
/// <param name="context">The <see cref="ChallengeContext"/> context.</param>
32+
/// <param name="properties">The <see cref="AuthenticationProperties"/> that contains the extra meta-data arriving with the authentication.</param>
3233
/// <returns>A task.</returns>
33-
Task ChallengeAsync(ChallengeContext context);
34+
Task ChallengeAsync(AuthenticationProperties properties);
35+
36+
/// <summary>
37+
/// Forbid behavior.
38+
/// </summary>
39+
/// <param name="properties">The <see cref="AuthenticationProperties"/> that contains the extra meta-data arriving with the authentication.</param>
40+
/// <returns>A task.</returns>
41+
Task ForbidAsync(AuthenticationProperties properties);
3442

3543
/// <summary>
3644
/// Handle sign in.
3745
/// </summary>
38-
/// <param name="context">The <see cref="SignInContext"/> context.</param>
46+
/// <param name="user">The <see cref="ClaimsPrincipal"/> user.</param>
47+
/// <param name="properties">The <see cref="AuthenticationProperties"/> that contains the extra meta-data arriving with the authentication.</param>
3948
/// <returns>A task.</returns>
40-
Task SignInAsync(SignInContext context);
49+
Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties);
4150

4251
/// <summary>
4352
/// Signout behavior.
4453
/// </summary>
45-
/// <param name="context">The <see cref="SignOutContext"/> context.</param>
54+
/// <param name="properties">The <see cref="AuthenticationProperties"/> that contains the extra meta-data arriving with the authentication.</param>
4655
/// <returns>A task.</returns>
47-
Task SignOutAsync(SignOutContext context);
56+
Task SignOutAsync(AuthenticationProperties properties);
4857
}
4958
}

src/Microsoft.AspNetCore.Authentication.Abstractions/IAuthenticationSchemeProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public interface IAuthenticationSchemeProvider
3434
Task<AuthenticationScheme> GetDefaultAuthenticateSchemeAsync();
3535

3636
/// <summary>
37-
/// Returns the scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties, ChallengeBehavior)"/>.
37+
/// Returns the scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties)"/>.
3838
/// This is typically specified via <see cref="AuthenticationOptions.DefaultChallengeScheme"/>.
3939
/// Otherwise, if only a single scheme exists, that will be used, if more than one exists, null will be returned.
4040
/// </summary>
41-
/// <returns>The scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties, ChallengeBehavior)"/>.</returns>
41+
/// <returns>The scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties)"/>.</returns>
4242
Task<AuthenticationScheme> GetDefaultChallengeSchemeAsync();
4343

4444
/// <summary>

src/Microsoft.AspNetCore.Authentication.Abstractions/IAuthenticationService.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ public interface IAuthenticationService
2626
/// <param name="context">The <see cref="HttpContext"/>.</param>
2727
/// <param name="scheme">The name of the authentication scheme.</param>
2828
/// <param name="properties">The <see cref="AuthenticationProperties"/>.</param>
29-
/// <param name="behavior">The <see cref="ChallengeBehavior"/>.</param>
3029
/// <returns>A task.</returns>
31-
Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties, ChallengeBehavior behavior);
30+
Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties);
31+
32+
/// <summary>
33+
/// Forbids the specified authentication scheme.
34+
/// </summary>
35+
/// <param name="context">The <see cref="HttpContext"/>.</param>
36+
/// <param name="scheme">The name of the authentication scheme.</param>
37+
/// <param name="properties">The <see cref="AuthenticationProperties"/>.</param>
38+
/// <returns>A task.</returns>
39+
Task ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties);
3240

3341
/// <summary>
3442
/// Sign a principal in for the specified authentication scheme.

src/Microsoft.AspNetCore.Authentication.Abstractions/SignInContext.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Microsoft.AspNetCore.Authentication.Abstractions/SignOutContext.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Microsoft.AspNetCore.Authentication.Core/AuthenticationSchemeProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public Task<AuthenticationScheme> GetDefaultAuthenticateSchemeAsync()
5757
}
5858

5959
/// <summary>
60-
/// Returns the scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties, ChallengeBehavior)"/>.
60+
/// Returns the scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties)"/>.
6161
/// This is typically specified via <see cref="AuthenticationOptions.DefaultChallengeScheme"/>.
6262
/// Otherwise, if only a single scheme exists, that will be used, if more than one exists, null will be returned.
6363
/// </summary>
64-
/// <returns>The scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties, ChallengeBehavior)"/>.</returns>
64+
/// <returns>The scheme that will be used by default for <see cref="IAuthenticationService.ChallengeAsync(HttpContext, string, AuthenticationProperties)"/>.</returns>
6565
public Task<AuthenticationScheme> GetDefaultChallengeSchemeAsync()
6666
{
6767
if (_options.DefaultChallengeScheme != null)

0 commit comments

Comments
 (0)