Class AuthExtensions
a set of auth related extensions
Inheritance
AuthExtensions
Assembly: FastEndpoints.Security.dll
Syntax
public static class AuthExtensions
Methods
Add(List<Claim>, params Claim[])
adds multiple Claims to the list.
Declaration
public static void Add(this List<Claim> list, params Claim[] claims)
Parameters
Add(List<Claim>, params (string claimType, string claimValue)[])
adds multiple Claims to the list.
Declaration
public static void Add(this List<Claim> list, params (string claimType, string claimValue)[] claims)
Parameters
Add(List<string>, params string[])
adds multiple strings to a list.
Declaration
public static void Add(this List<string> list, params string[] values)
Parameters
Type |
Name |
Description |
List<string> |
list |
|
string[] |
values |
the strings to append to the list.
|
AddAuthenticationCookie(IServiceCollection, TimeSpan, Action<CookieAuthenticationOptions>?)
configure and enable cookie based authentication
Declaration
public static IServiceCollection AddAuthenticationCookie(this IServiceCollection services, TimeSpan validFor, Action<CookieAuthenticationOptions>? options = null)
Parameters
Returns
AddAuthenticationJwtBearer(IServiceCollection, Action<JwtSigningOptions>, Action<JwtBearerOptions>?)
configure and enable jwt bearer authentication
Declaration
public static IServiceCollection AddAuthenticationJwtBearer(this IServiceCollection services, Action<JwtSigningOptions> signingOptions, Action<JwtBearerOptions>? bearerOptions = null)
Parameters
Returns
Exceptions
AddCookieAuth(IServiceCollection, TimeSpan, Action<CookieAuthenticationOptions>?)
Declaration
[Obsolete("Use AddAuthenticationCookie() method.")]
public static IServiceCollection AddCookieAuth(this IServiceCollection services, TimeSpan validFor, Action<CookieAuthenticationOptions>? options = null)
Parameters
Returns
AddJWTBearerAuth(IServiceCollection, string, TokenSigningStyle, Action<JwtBearerOptions>?)
Declaration
[Obsolete("Use AddAuthenticationJwtBearer() method.")]
public static IServiceCollection AddJWTBearerAuth(this IServiceCollection services, string tokenSigningKey, TokenSigningStyle tokenSigningStyle, Action<JwtBearerOptions>? jwtOptions = null)
Parameters
Returns
AddJWTBearerAuth(IServiceCollection, string, TokenSigningStyle, Action<TokenValidationParameters>?, Action<JwtBearerEvents>?)
Declaration
[Obsolete("Use AddAuthenticationJwtBearer() method.")]
public static IServiceCollection AddJWTBearerAuth(this IServiceCollection services, string tokenSigningKey, TokenSigningStyle tokenSigningStyle = TokenSigningStyle.Symmetric, Action<TokenValidationParameters>? tokenValidation = null, Action<JwtBearerEvents>? bearerEvents = null)
Parameters
Returns
AddJWTBearerAuth(IServiceCollection, string, Action<JwtBearerOptions>)
Declaration
[Obsolete("Use AddAuthenticationJwtBearer() method.")]
public static IServiceCollection AddJWTBearerAuth(this IServiceCollection services, string tokenSigningKey, Action<JwtBearerOptions> jwtOptions)
Parameters
Returns
ClaimValue(ClaimsPrincipal, string)
get the claim value for a given claim type of the current user principal. if the user doesn't have the requested claim type, a null will be returned.
Declaration
public static string? ClaimValue(this ClaimsPrincipal principal, string claimType)
Parameters
Returns
HasClaimType(ClaimsPrincipal, string)
determines if the current user principal has the given claim type
Declaration
public static bool HasClaimType(this ClaimsPrincipal principal, string claimType)
Parameters
Returns
HasPermission(ClaimsPrincipal, string)
returns true of the current user principal has a given permission code.
Declaration
public static bool HasPermission(this ClaimsPrincipal principal, string permissionCode)
Parameters
Returns