@beholdio/ts-lambda-api - v2.4.8
    Preparing search index...

    Interface IAuthFilter<T, U>

    Authentication filter that can extract authentication data from a HTTP request and preform authentication using that data.

    interface IAuthFilter<T, U extends Principal> {
        authenticationSchemeName: string;
        name: string;
        authenticate(authData: T): Promise<U>;
        extractAuthData(request: Request): Promise<T>;
    }

    Type Parameters

    • T

      Authentication data type

    • U extends Principal

      Principal data type, the type must extend Principal

    Implemented by

    Index

    Properties

    authenticationSchemeName: string

    String to use in WWW-Authenticate header when returing a HTTP 401 response, see: https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml

    name: string

    A human readable name for this authentication filter.

    Methods

    • Attempt to authorise a user suing the authentication data supplied. An instance of the principal type U should be returned on authentication success, otherwise undefined should be returned.

      Parameters

      • authData: T

        An instance of the authentication data type T.

      Returns Promise<U>

      Instance of type U or undefined on authentication failure.

    • Extract an instance of the authentication data type T from a HTTP request. If extraction is not possible due to missing request headers/data, undefined should be returned.

      Parameters

      • request: Request

        Request context to use.

      Returns Promise<T>

      Instance of type T or undefined on extraction failure.