Class JWTBearer
static class for easy creation of jwt bearer auth tokens
Inherited Members
Namespace: FastEndpoints.Security
Assembly: FastEndpoints.Security.dll
Syntax
public static class JWTBearer
Methods
CreateToken(string, TokenSigningStyle, string?, string?, DateTime?, IEnumerable<string>?, IEnumerable<string>?, params (string claimType, string claimValue)[])
generate a jwt token with the supplied parameters and token signing style
Declaration
public static string CreateToken(string signingKey, JWTBearer.TokenSigningStyle signingStyle, string? issuer = null, string? audience = null, DateTime? expireAt = null, IEnumerable<string>? permissions = null, IEnumerable<string>? roles = null, params (string claimType, string claimValue)[] claims)
Parameters
Type | Name | Description |
---|---|---|
string | signingKey | the secret key to use for signing the tokens |
JWTBearer.TokenSigningStyle | signingStyle | the signing style to use (Symmertic or Asymmetric) |
string | issuer | the issue |
string | audience | the audience |
DateTime? | expireAt | the expiry date |
IEnumerable<string> | permissions | one or more permissions to assign to the user principal |
IEnumerable<string> | roles | one or more roles to assign the user principal |
(string claimType, string claimValue)[] | claims | one or more claims to assign to the user principal |
Returns
Type | Description |
---|---|
string |
CreateToken(string, Action<UserPrivileges>, string?, string?, DateTime?, TokenSigningStyle)
generate a jwt token with the supplied parameters
Declaration
public static string CreateToken(string signingKey, Action<UserPrivileges> privileges, string? issuer = null, string? audience = null, DateTime? expireAt = null, JWTBearer.TokenSigningStyle signingStyle = TokenSigningStyle.Symmetric)
Parameters
Type | Name | Description |
---|---|---|
string | signingKey | the secret key to use for signing the tokens |
Action<UserPrivileges> | privileges | an action to specify the privileges of the user |
string | issuer | the issuer |
string | audience | the audience |
DateTime? | expireAt | the expiry date |
JWTBearer.TokenSigningStyle | signingStyle | the signing style to use (Symmertic or Asymmetric) |
Returns
Type | Description |
---|---|
string |
CreateToken(string, DateTime?, IEnumerable<string>?, IEnumerable<string>?, IEnumerable<Claim>?, string?, string?, TokenSigningStyle)
generate a jwt token with the supplied parameters
Declaration
public static string CreateToken(string signingKey, DateTime? expireAt = null, IEnumerable<string>? permissions = null, IEnumerable<string>? roles = null, IEnumerable<Claim>? claims = null, string? issuer = null, string? audience = null, JWTBearer.TokenSigningStyle signingStyle = TokenSigningStyle.Symmetric)
Parameters
Type | Name | Description |
---|---|---|
string | signingKey | the secret key to use for signing the tokens |
DateTime? | expireAt | the expiry date |
IEnumerable<string> | permissions | one or more permissions to assign to the user principal |
IEnumerable<string> | roles | one or more roles to assign the user principal |
IEnumerable<Claim> | claims | one or more claims to assign to the user principal |
string | issuer | the issuer |
string | audience | the audience |
JWTBearer.TokenSigningStyle | signingStyle | the signing style to use (Symmetric or Asymmetric) |
Returns
Type | Description |
---|---|
string |
CreateToken(string, DateTime?, IEnumerable<string>?, IEnumerable<string>?, params (string claimType, string claimValue)[])
generate a jwt token with the supplied parameters
Declaration
public static string CreateToken(string signingKey, DateTime? expireAt = null, IEnumerable<string>? permissions = null, IEnumerable<string>? roles = null, params (string claimType, string claimValue)[] claims)
Parameters
Type | Name | Description |
---|---|---|
string | signingKey | the secret key to use for signing the tokens |
DateTime? | expireAt | the expiry date |
IEnumerable<string> | permissions | one or more permissions to assign to the user principal |
IEnumerable<string> | roles | one or more roles to assign the user principal |
(string claimType, string claimValue)[] | claims | one or more claims to assign to the user principal |
Returns
Type | Description |
---|---|
string |
CreateToken(string, string?, string?, DateTime?, IEnumerable<string>?, IEnumerable<string>?, params (string claimType, string claimValue)[])
generate a jwt token with the supplied parameters
Declaration
public static string CreateToken(string signingKey, string? issuer, string? audience, DateTime? expireAt = null, IEnumerable<string>? permissions = null, IEnumerable<string>? roles = null, params (string claimType, string claimValue)[] claims)
Parameters
Type | Name | Description |
---|---|---|
string | signingKey | the secret key to use for signing the tokens |
string | issuer | the issue |
string | audience | the audience |
DateTime? | expireAt | the expiry date |
IEnumerable<string> | permissions | one or more permissions to assign to the user principal |
IEnumerable<string> | roles | one or more roles to assign the user principal |
(string claimType, string claimValue)[] | claims | one or more claims to assign to the user principal |
Returns
Type | Description |
---|---|
string |