UNPKG

@mamoorali295/rbac

Version:

Complete RBAC (Role-Based Access Control) system for Node.js with Express middleware, NestJS integration, GraphQL support, MongoDB & PostgreSQL support, modern admin dashboard, TypeScript support, and dynamic permission management

33 lines (32 loc) 1.07 kB
import { CanActivate, ExecutionContext } from '@nestjs/common'; /** * NestJS Guard for Admin Dashboard Authentication * Protects admin routes by checking for valid authentication session. * Redirects to login page if user is not authenticated. * * Features: * - Session-based authentication * - Automatic redirect to login for unauthenticated requests * - Compatible with NestJS guard system * * @example * ```typescript * @Controller('rbac-admin') * export class RbacAdminController { * @Get('dashboard') * @UseGuards(AdminAuthGuard) * async getDashboard() { * // This route is protected by admin authentication * return { message: 'Welcome to admin dashboard' }; * } * } * ``` */ export declare class AdminAuthGuard implements CanActivate { /** * Determines if the current request is authorized to access admin routes * @param context - ExecutionContext containing request/response objects * @returns boolean - True if authenticated, false otherwise */ canActivate(context: ExecutionContext): boolean; }