Class AuthenticationUtility
Provides a set of generic ways to work with HTTP based authentication.
Inheritance
Namespace: Cuemon.AspNetCore.Authentication
Assembly: Cuemon.AspNetCore.Authentication.dll
Syntax
public static class AuthenticationUtility
Fields
| Improve this DocBasicAuthenticationCredentialSeparator
The value of the header credential separator of a HTTP Basic access authentication.
Declaration
public const char BasicAuthenticationCredentialSeparator = ':'
Field Value
Type | Description |
---|---|
System.Char |
DigestAuthenticationCredentialSeparator
The value of the header credential separator of a HTTP Digest access authentication.
Declaration
public const char DigestAuthenticationCredentialSeparator = ','
Field Value
Type | Description |
---|---|
System.Char |
HttpNotAuthorizedStatus
The value of the status description associated with HttpNotAuthorizedStatusCode.
Declaration
public const string HttpNotAuthorizedStatus = "401 Unauthorized"
Field Value
Type | Description |
---|---|
System.String |
HttpNotAuthorizedStatusCode
Equivalent to HTTP status 401. Unauthorized indicates that the requested resource requires authentication.
Declaration
public const int HttpNotAuthorizedStatusCode = 401
Field Value
Type | Description |
---|---|
System.Int32 |
JwtAuthenticationCredentialSeparator
The value of the header credential separator of a HTTP JSON Web Token authentication.
Declaration
public const char JwtAuthenticationCredentialSeparator = '.'
Field Value
Type | Description |
---|---|
System.Char |
Methods
| Improve this DocAuthenticate<T>(HttpContext, Boolean, Func<HttpContext, String, T>, TesterFunc<HttpContext, T, ClaimsPrincipal, Boolean>)
Provides a generic way to make authentication requests using the specified context
.
Declaration
public static void Authenticate<T>(HttpContext context, bool requireSecureConnection, Func<HttpContext, string, T> authorizationParser, TesterFunc<HttpContext, T, ClaimsPrincipal, bool> principalParser)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Http.HttpContext | context | The context of the ASP.NET application. |
System.Boolean | requireSecureConnection | When |
System.Func<Microsoft.AspNetCore.Http.HttpContext, System.String, T> | authorizationParser | The function delegate that will parse the authorization header of a web request and return the credentials of |
TesterFunc<Microsoft.AspNetCore.Http.HttpContext, T, System.Security.Claims.ClaimsPrincipal, System.Boolean> | principalParser | The function delegate that will parse the credentials of |
Type Parameters
Name | Description |
---|---|
T | The type of the credentials returned from |
Exceptions
Type | Condition |
---|---|
System.Security.SecurityException | Authorized failed for the request. |
TryAuthenticate<T>(HttpContext, Boolean, Func<HttpContext, String, T>, TesterFunc<HttpContext, T, ClaimsPrincipal, Boolean>)
Provides a generic way to make authentication requests using the specified context
.
Declaration
public static bool TryAuthenticate<T>(HttpContext context, bool requireSecureConnection, Func<HttpContext, string, T> authorizationParser, TesterFunc<HttpContext, T, ClaimsPrincipal, bool> principalParser)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Http.HttpContext | context | The context of the ASP.NET application. |
System.Boolean | requireSecureConnection | When |
System.Func<Microsoft.AspNetCore.Http.HttpContext, System.String, T> | authorizationParser | The function delegate that will parse the authorization header of a web request and return the credentials of |
TesterFunc<Microsoft.AspNetCore.Http.HttpContext, T, System.Security.Claims.ClaimsPrincipal, System.Boolean> | principalParser | The function delegate that will parse the credentials of |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of the credentials returned from |