TryAuthenticate Method
Definition
- Namespace
- Cuemon.AspNetCore.Authentication
- Assemblies
- Cuemon.AspNetCore.Authentication.dll
TryAuthenticate<T>(HttpContext, bool, Func<HttpContext, string, T>, TesterFunc<HttpContext, T, ConditionalValue<ClaimsPrincipal>, bool>, out ConditionalValue<ClaimsPrincipal>)
Provides a generic way to make authentication requests using the specified context.
public static bool TryAuthenticate<T>(HttpContext context, bool requireSecureConnection, Func<HttpContext, string, T> authorizationParser, TesterFunc<HttpContext, T, ConditionalValue<ClaimsPrincipal>, bool> principalParser, out ConditionalValue<ClaimsPrincipal> principal)
Parameters
contextHttpContextThe context of the ASP.NET application.
requireSecureConnectionboolWhen
true, the HTTP connection is required to use secure sockets (that is, HTTPS); whenfalseno requirement is enforced.authorizationParserFunc<HttpContext, string, T>The function delegate that will parse the authorization header of a web request and return the credentials of
T.principalParserTesterFunc<HttpContext, T, ConditionalValue<ClaimsPrincipal>, bool>The function delegate that will parse the credentials of
Treturned fromauthorizationParserand if successful returns a ClaimsPrincipal object.principalConditionalValue<ClaimsPrincipal>The ClaimsPrincipal of the authenticated user if the authentication was successful.
Returns
- bool
trueif the specified parameters triggers a successful authentication; otherwise,false.
Type Parameters
TThe type of the credentials returned from
authorizationParserand passed toprincipalParser.