UNPKG

@citrineos/util

Version:

The OCPP util module which supplies helpful utilities like cache and queue connectors, etc.

53 lines (52 loc) 1.43 kB
import { FastifyPluginAsync, FastifyReply } from 'fastify'; import { ILogObj, Logger } from 'tslog'; import { IApiAuthProvider, UserInfo } from '@citrineos/base'; /** * Options for the authentication plugin */ export interface AuthPluginOptions { /** * Routes that don't require authentication */ excludedRoutes?: string[]; /** * Enable verbose debug logging */ debug?: boolean; } /** * Extend the FastifyRequest interface to include user information */ declare module 'fastify' { interface FastifyRequest { /** * Authenticated user information */ user?: UserInfo; } } /** * Extend FastifyInstance to include our auth functions and provider */ declare module 'fastify' { interface FastifyInstance { /** * The authentication provider instance */ authProvider: IApiAuthProvider; /** * Authenticates a request by validating the token in Authorization header */ authenticate: (request: FastifyRequest, reply: FastifyReply) => Promise<void>; /** * Authorizes a request for a specific resource */ authorize: (request: FastifyRequest, reply: FastifyReply) => Promise<void>; } } declare const _default: FastifyPluginAsync<{ provider: IApiAuthProvider; options?: AuthPluginOptions; logger?: Logger<ILogObj>; }>; export default _default;