Search Results for

    Show / Hide Table of Contents

    Class AuthExtensions

    a set of auth related extensions

    Inheritance
    object
    AuthExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastEndpoints.Security
    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
    Type Name Description
    List<Claim> list
    Claim[] claims

    the Claims to append to the list.

    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
    Type Name Description
    List<Claim> list
    (string claimType, string claimValue)[] claims

    the claim Type & Value tuples to add to the list.

    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
    Type Name Description
    IServiceCollection services
    TimeSpan validFor

    specify how long the created cookie is valid for with a TimeSpan

    Action<CookieAuthenticationOptions> options

    optional action for configuring cookie authentication options

    Returns
    Type Description
    IServiceCollection

    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
    Type Name Description
    IServiceCollection services
    Action<JwtSigningOptions> signingOptions

    an action to configure JwtSigningOptions

    Action<JwtBearerOptions> bearerOptions

    an action to configure JwtBearerOptions

    Returns
    Type Description
    IServiceCollection
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    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
    Type Name Description
    ClaimsPrincipal principal
    string claimType

    the claim type to look for

    Returns
    Type Description
    string

    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
    Type Name Description
    ClaimsPrincipal principal
    string claimType

    the claim type to check for

    Returns
    Type Description
    bool

    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
    Type Name Description
    ClaimsPrincipal principal
    string permissionCode

    the permission code to check for

    Returns
    Type Description
    bool
    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX