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

Commit e77b175

Browse files
committed
Restore AuthenticateAsync for now
1 parent e56658c commit e77b175

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Microsoft.AspNetCore.Http.Abstractions/Authentication/AuthenticationManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public abstract class AuthenticationManager
2222

2323
public abstract Task<AuthenticateInfo> GetAuthenticateInfoAsync(string authenticationScheme);
2424

25+
// Will remove once callees have been updated
26+
public abstract Task AuthenticateAsync(AuthenticateContext context);
27+
2528
public virtual async Task<ClaimsPrincipal> AuthenticateAsync(string authenticationScheme)
2629
{
2730
return (await GetAuthenticateInfoAsync(authenticationScheme))?.Principal;

src/Microsoft.AspNetCore.Http/Authentication/DefaultAuthenticationManager.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ public override IEnumerable<AuthenticationDescription> GetAuthenticationSchemes(
5050
return describeContext.Results.Select(description => new AuthenticationDescription(description));
5151
}
5252

53+
// Remove once callers have been switched to GetAuthenticateInfoAsync
54+
public override async Task AuthenticateAsync(AuthenticateContext context)
55+
{
56+
if (context == null)
57+
{
58+
throw new ArgumentNullException(nameof(context));
59+
}
60+
61+
var handler = HttpAuthenticationFeature.Handler;
62+
if (handler != null)
63+
{
64+
await handler.AuthenticateAsync(context);
65+
}
66+
67+
if (!context.Accepted)
68+
{
69+
throw new InvalidOperationException($"No authentication handler is configured to authenticate for the scheme: {context.AuthenticationScheme}");
70+
}
71+
}
72+
5373
public override async Task<AuthenticateInfo> GetAuthenticateInfoAsync(string authenticationScheme)
5474
{
5575
if (authenticationScheme == null)

0 commit comments

Comments
 (0)