UNPKG

loopback4-authentication

Version:

A loopback-next extension for authentication feature. Various Oauth strategies supported by this package.

51 lines (50 loc) 1.43 kB
/// <reference types="express" /> import { BindingKey } from '@loopback/core'; import { Request, Response } from '@loopback/rest'; import { VerifyFunction } from './strategies'; export * from './strategies/types'; export interface IAuthClient { clientId: string; clientSecret: string; redirectUrl?: string; } export interface IAuthSecureClient { clientId: string; clientSecret: string; clientType: ClientType; redirectUrl?: string; } export interface IAuthUser { id?: number | string; username: string; password?: string; } export interface EntityWithIdentifier { getIdentifier?(): string | undefined; } export interface AuthenticationMetadata<T = void> { strategy: string; options?: Object; verifier?: BindingKey<VerifyFunction.GenericAuthFn<T>>; authOptions?: (req: Request) => Object; } /** * interface definition of a function which accepts a request * and returns an authenticated user */ export type AuthenticateFn<T> = (request: Request, response?: Response) => Promise<T>; export interface ClientAuthCode<T extends IAuthUser, ID = number> { clientId: string; mfa?: boolean; userId?: ID; user?: T; } export interface AuthenticationConfig { useClientAuthenticationMiddleware?: boolean; useUserAuthenticationMiddleware?: boolean; secureClient?: boolean; } export declare enum ClientType { public = "public", private = "private" }