UNPKG

@kenniy/godeye-data-contracts

Version:

Enterprise-grade base repository architecture for GOD-EYE microservices with zero overhead and maximum code reuse

46 lines (45 loc) 1.75 kB
/** * Kong Gateway Authentication System * Unified authentication across all GOD-EYE microservices */ import { CanActivate, ExecutionContext } from '@nestjs/common'; import { IKongUserContext } from '../types/auth.types'; /** * Normalize request headers to string dictionary (DRY utility) * @param requestHeaders - Raw request headers * @returns Normalized headers as string dictionary */ export declare function normalizeHeaders(requestHeaders: any): Record<string, string>; /** * Extract Kong user context from Gateway headers * @param headers - HTTP headers from Kong Gateway * @returns Kong user context with all available user information */ export declare function extractKongUserContext(headers: Record<string, string>): IKongUserContext; /** * Kong User Parameter Decorator * Usage: async method(@KongUser() user: IKongUserContext) */ export declare const KongUser: (...dataOrPipes: unknown[]) => ParameterDecorator; /** * Kong Authentication Guard * Automatically validates Kong user context on protected routes */ export declare class KongAuthGuard implements CanActivate { private readonly required_roles?; private readonly skip_routes?; constructor(required_roles?: string[] | undefined, skip_routes?: string[] | undefined); canActivate(context: ExecutionContext): boolean; } /** * Create Kong Auth Guard with specific configuration */ export declare function createKongAuthGuard(options?: { required_roles?: string[]; skip_routes?: string[]; }): typeof KongAuthGuard; /** * Role-based access control decorator * Usage: @RequireRoles(['admin', 'manager']) */ export declare function RequireRoles(...roles: string[]): (target: any, propertyName: string, descriptor: PropertyDescriptor) => void;