UNPKG

@labshare/services-auth

Version:

Loopback 4 plugin for resource scope-based HTTP route authz

35 lines (34 loc) 1.19 kB
/// <reference types="express" /> import { Provider, Getter } from "@loopback/core"; import { AuthenticateFn } from "../keys"; import type { Request } from "@loopback/rest"; export interface RequestWithUserInfo extends Request { userInfo: { [key: string]: any; }; } /** * @description Provider of a function which authenticates * @example `context.bind('authentication_key') * .toProvider(UserInfoActionProvider)` */ export declare class UserInfoActionProvider implements Provider<AuthenticateFn> { readonly getConfig: Getter<{ [key: string]: any; }>; constructor(getConfig: Getter<{ [key: string]: any; }>); /** * Sequence handler for setting the user profile on the request */ value(): AuthenticateFn; /** * @description The userInfo() sequence action. It attaches a "userInfo" object * to the incoming request if the following conditions are met: * - The configuration has been set up for the component * - A bearer token exists in the request headers * - The user info endpoint request to the Auth service is successful */ action(request: RequestWithUserInfo): Promise<any>; }