-
Notifications
You must be signed in to change notification settings - Fork 191
Switch to GetAuthenticationInfoAsync #616
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Security.Claims; | ||
|
||
namespace Microsoft.AspNetCore.Http.Authentication | ||
{ | ||
/// <summary> | ||
/// Used to store the results of an Authenticate call. | ||
/// </summary> | ||
public class AuthenticateInfo | ||
{ | ||
/// <summary> | ||
/// The <see cref="ClaimsPrincipal"/>. | ||
/// </summary> | ||
public ClaimsPrincipal Principal { get; set; } | ||
|
||
/// <summary> | ||
/// The <see cref="AuthenticationProperties"/>. | ||
/// </summary> | ||
public AuthenticationProperties Properties { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,18 +20,14 @@ public abstract class AuthenticationManager | |
|
||
public abstract IEnumerable<AuthenticationDescription> GetAuthenticationSchemes(); | ||
|
||
public abstract Task<AuthenticateInfo> GetAuthenticateInfoAsync(string authenticationScheme); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, since this is the main "API", this one should probably be named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switching the names would be a major break that we want to avoid. Not nearly as many people will use this version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, TBH, how many people are using passive authentication these days? 5%? 10%? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah so of that 5/10%, I'd say only another 5/10% of those passive calls will want the AuthenticationProperties, most will only want the Principal... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's why I think a simpler name like Anyway, as long as the odd There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (oh, and |
||
|
||
// Will remove once callees have been updated | ||
public abstract Task AuthenticateAsync(AuthenticateContext context); | ||
|
||
public virtual async Task<ClaimsPrincipal> AuthenticateAsync(string authenticationScheme) | ||
{ | ||
if (authenticationScheme == null) | ||
{ | ||
throw new ArgumentNullException(nameof(authenticationScheme)); | ||
} | ||
|
||
var context = new AuthenticateContext(authenticationScheme); | ||
await AuthenticateAsync(context); | ||
return context.Principal; | ||
return (await GetAuthenticateInfoAsync(authenticationScheme))?.Principal; | ||
} | ||
|
||
public virtual Task ChallengeAsync() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: is there any particular reason to use publicly settable properties instead of get-only properties + public constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason, if you guys feel strongly this should be readonly ctor properties, easy enough change.