This repository was archived by the owner on Nov 20, 2018. It is now read-only.
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
Update AuthenticationManager.AuthenticateAsync to return an AuthenticationTicket #572
Closed
Description
In June, the AuthenticateAsync
method was updated to return a ClaimsPrincipal
instead of an AuthenticationResult
(a type similar to AuthenticationTicket
). As a consequence, retrieving the authentication properties is much harder, and can only be done using the rather unusual overload taking an AuthenticateContext
parameter:
@HaoK's main argument was that retrieving authentication properties was not really frequent. Sadly, I don't think it's true, as retrieving the expiration date from the ticket is quite popular: http://stackoverflow.com/a/34535003/542757
If you really think having a method returning a ClaimsPrincipal
is important, why not adding an extension method?
public static async Task<ClaimsPrincipal> GetPrincipalAsync(this AuthenticationManager manager, string scheme) {
if (manager == null) {
throw new ArgumentNullException(nameof(manager));
}
return (await manager.AuthenticateAsync(scheme))?.Principal;
}