koas-security
Version:
Koas security checks if a request matches the security requirement of an operation. For example, given the following partial OpenAPI document:
14 lines (13 loc) • 631 B
TypeScript
import { Context } from 'koa';
import { OpenAPIV3 } from 'openapi-types';
import { Promisable } from 'type-fest';
import { SecurityCheck } from './types';
export declare type GetApiKeyUser<User = unknown, Client = unknown> = (apiKey: string, ctx: Context) => Promisable<User | [User, Client?]>;
/**
* Get a user based on an apiKey security scheme.
*
* @param scheme - The OpenAPI security scheme.
* @param userGetter - A function for getting a user.
* @returns A tuple containing just the user.
*/
export declare function apiKeySecurityCheck(scheme: OpenAPIV3.ApiKeySecurityScheme, userGetter: GetApiKeyUser): SecurityCheck;