@lark-apaas/nestjs-authzpaas 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,673 @@
1
+ import { DynamicModule, Type, CanActivate, ExecutionContext, NestMiddleware, HttpException, ExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ import { PureAbility } from '@casl/ability';
4
+ import { Request, Response, NextFunction } from 'express';
5
+
6
+ /**
7
+ * 用户角色
8
+ */
9
+ interface UserRole {
10
+ /** 角色ID */
11
+ id: string;
12
+ /** 角色名称 */
13
+ name: string;
14
+ /** 角色描述 */
15
+ description?: string;
16
+ }
17
+ /**
18
+ * 权限点位
19
+ */
20
+ interface Permission {
21
+ /** 资源类型 */
22
+ sub: string;
23
+ /** 操作类型 */
24
+ actions: string[];
25
+ /** 权限ID */
26
+ id?: string;
27
+ /** 权限名称 */
28
+ name?: string;
29
+ /** 权限条件 */
30
+ conditions?: Record<string, unknown>;
31
+ }
32
+ /**
33
+ * 用户权限数据
34
+ */
35
+ interface UserPermissionData {
36
+ /** 用户ID ,匿名用户时为空*/
37
+ userId?: string;
38
+ /** 用户角色列表 */
39
+ roles: string[];
40
+ /** 用户权限点位列表 */
41
+ permissions: Permission[];
42
+ /** 数据获取时间 */
43
+ fetchedAt: Date;
44
+ }
45
+ /**
46
+ * 环境信息
47
+ */
48
+ interface EnvironmentContext {
49
+ /** 网络信息 */
50
+ network?: {
51
+ ip?: string;
52
+ region?: string;
53
+ };
54
+ /** 终端信息 */
55
+ device?: {
56
+ type?: 'mobile' | 'desktop' | 'tablet';
57
+ os?: string;
58
+ browser?: string;
59
+ };
60
+ /** 自定义环境变量 */
61
+ custom?: Record<string, unknown>;
62
+ }
63
+ /**
64
+ * 权限检查上下文
65
+ */
66
+ interface AuthorizationContext {
67
+ /** 用户ID */
68
+ userId: string;
69
+ /** 用户权限数据 */
70
+ permissionData?: UserPermissionData;
71
+ /** 环境信息 */
72
+ environment?: EnvironmentContext;
73
+ /** 请求对象 */
74
+ request?: unknown;
75
+ }
76
+ /**
77
+ * CASL 动作类型
78
+ */
79
+ type Action = 'create' | 'read' | 'update' | 'delete' | 'manage' | string;
80
+ /**
81
+ * CASL 主体类型
82
+ */
83
+ type Subject = string | object;
84
+ /**
85
+ * 缓存配置
86
+ */
87
+ interface CacheConfig {
88
+ /** 缓存过期时间(秒),默认 300 秒 */
89
+ ttl?: number;
90
+ /** 最大缓存数量,默认 1000 */
91
+ max?: number;
92
+ /** 是否启用缓存,默认 true */
93
+ enabled?: boolean;
94
+ }
95
+ /**
96
+ * 权限 API 配置
97
+ */
98
+ interface PermissionApiConfig {
99
+ /** 权限 API 基础 URL */
100
+ baseUrl: string;
101
+ /** API 认证 Token(可选) */
102
+ apiToken?: string;
103
+ /** 权限的端点路径 */
104
+ endpoint: string;
105
+ /** 自定义请求头 */
106
+ headers?: Record<string, string>;
107
+ /** 请求超时时间(毫秒),默认 5000 */
108
+ timeout?: number;
109
+ }
110
+ /**
111
+ * AuthZPaas 模块配置
112
+ */
113
+ interface AuthZPaasModuleOptions {
114
+ /** 权限 API 配置 */
115
+ permissionApi?: PermissionApiConfig;
116
+ /** 缓存配置 */
117
+ cache?: CacheConfig;
118
+ /** 是否启用 mock 角色功能,默认 false */
119
+ enableMockRole?: boolean;
120
+ /** 是否总是需要登录,默认 true */
121
+ alwaysNeedLogin?: boolean;
122
+ /** 未登录时默认重定向的登录页路径(可被 @NeedLogin 覆盖),默认 '/login' */
123
+ loginPath?: string;
124
+ /** 是否全局模块,默认 true */
125
+ isGlobal?: boolean;
126
+ }
127
+
128
+ interface AuthZPaasModuleAsyncOptions {
129
+ imports?: Type<unknown>[];
130
+ inject?: (string | symbol | Type<unknown>)[];
131
+ useFactory: (...args: unknown[]) => Promise<AuthZPaasModuleOptions> | AuthZPaasModuleOptions;
132
+ isGlobal?: boolean;
133
+ }
134
+ declare class AuthZPaasModule {
135
+ static forRoot(options: AuthZPaasModuleOptions): DynamicModule;
136
+ /**
137
+ * 异步注册 AuthZPaas 模块(根模块)
138
+ * 用于需要从配置服务获取设置的场景
139
+ *
140
+ * @param options 异步配置选项
141
+ * @returns 动态模块
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * @Module({
146
+ * imports: [
147
+ * AuthZPaasModule.forRootAsync({
148
+ * imports: [ConfigModule],
149
+ * inject: [ConfigService],
150
+ * useFactory: async (configService: ConfigService) => ({
151
+ * permissionApi: {
152
+ * baseUrl: configService.get('PERMISSION_API_URL'),
153
+ * apiToken: configService.get('PERMISSION_API_TOKEN'),
154
+ * },
155
+ * cache: {
156
+ * ttl: configService.get('CACHE_TTL', 300),
157
+ * max: configService.get('CACHE_MAX', 1000),
158
+ * },
159
+ * }),
160
+ * }),
161
+ * ],
162
+ * })
163
+ * export class AppModule {}
164
+ * ```
165
+ */
166
+ static forRootAsync(options: AuthZPaasModuleAsyncOptions): DynamicModule;
167
+ }
168
+
169
+ /**
170
+ * 角色要求配置
171
+ */
172
+ interface RoleRequirement {
173
+ /** 需要的角色列表 */
174
+ roles: string[];
175
+ /** 是否需要所有角色(AND),默认 false(OR) */
176
+ and?: boolean;
177
+ }
178
+ type CheckRoleRequirement = RoleRequirement;
179
+ /**
180
+ * 要求用户拥有指定角色
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * // 需要任一角色
185
+ * @CanRole(['admin', 'moderator'])
186
+ * async deleteUser() {}
187
+ *
188
+ * // 需要所有角色
189
+ * @CanRole(['admin', 'superuser'], true)
190
+ * async criticalOperation() {}
191
+ * ```
192
+ */
193
+ declare const CanRole: (role: string[] | string, and?: boolean) => MethodDecorator;
194
+
195
+ /**
196
+ * 权限要求配置
197
+ */
198
+ interface PermissionRequirement {
199
+ /** 操作类型 */
200
+ actions: Action[];
201
+ /** 资源类型 */
202
+ subject: Subject;
203
+ /** 是否需要所有操作(AND),默认 true(AND) */
204
+ or?: boolean;
205
+ }
206
+ /**
207
+ * 要求用户拥有指定权限
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * // 通过 CASL 动作和资源检查(推荐使用)
212
+ * @CanPermission({ actions: ['create'], subject: 'User' })
213
+ * async createUser() {}
214
+ *
215
+ * @CanPermission({ actions: ['update'], subject: 'Article' })
216
+ * async updateArticle() {}
217
+ *
218
+ * @CanPermission({ actions: ['delete'], subject: 'Comment' })
219
+ * async deleteComment() {}
220
+ *
221
+ * // 注意:基于权限名称列表的检查方式暂不支持
222
+ * // permissions 参数暂时保留用于未来扩展
223
+ * ```
224
+ */
225
+ declare const CanPermission: (permission: PermissionRequirement[] | PermissionRequirement, or?: boolean) => MethodDecorator;
226
+
227
+ /**
228
+ * 网络要求
229
+ */
230
+ interface NetworkRequirement {
231
+ /** 允许的 IP 地址列表(支持 CIDR) */
232
+ allowedIPs?: string[];
233
+ /** 禁止的 IP 地址列表 */
234
+ blockedIPs?: string[];
235
+ /** 允许的地区列表 */
236
+ allowedRegions?: string[];
237
+ }
238
+ /**
239
+ * 设备要求
240
+ */
241
+ interface DeviceRequirement {
242
+ /** 允许的设备类型 */
243
+ types?: Array<'mobile' | 'desktop' | 'tablet'>;
244
+ /** 允许的操作系统 */
245
+ os?: string[];
246
+ /** 允许的浏览器 */
247
+ browsers?: string[];
248
+ }
249
+ /**
250
+ * 环境要求配置
251
+ */
252
+ interface EnvironmentRequirement {
253
+ /** 网络要求 */
254
+ network?: NetworkRequirement;
255
+ /** 设备要求 */
256
+ device?: DeviceRequirement;
257
+ /** 自定义环境验证函数 */
258
+ custom?: (context: any) => boolean | Promise<boolean>;
259
+ }
260
+ /**
261
+ * 要求特定的环境条件
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * // 仅允许桌面端访问
266
+ * @CanEnv({ device: { types: ['desktop'] } })
267
+ * async adminPanel() {}
268
+ *
269
+ * // 限制 IP 访问
270
+ * @CanEnv({
271
+ * network: {
272
+ * allowedIPs: ['192.168.1.0/24', '10.0.0.1']
273
+ * }
274
+ * })
275
+ * async internalAPI() {}
276
+ *
277
+ * // 自定义验证
278
+ * @CanEnv({
279
+ * custom: (ctx) => ctx.headers['x-api-key'] === 'secret'
280
+ * })
281
+ * async secretEndpoint() {}
282
+ * ```
283
+ */
284
+ declare const CanEnv: (requirement: EnvironmentRequirement) => MethodDecorator;
285
+
286
+ /**
287
+ * 获取当前用户 ID
288
+ *
289
+ * @example
290
+ * ```typescript
291
+ * @Get('profile')
292
+ * getProfile(@UserId() userId: string) {
293
+ * return { userId };
294
+ * }
295
+ * ```
296
+ */
297
+ declare const UserId: (...dataOrPipes: unknown[]) => ParameterDecorator;
298
+
299
+ declare const MockRoles: (...dataOrPipes: unknown[]) => ParameterDecorator;
300
+
301
+ /**
302
+ * CASL Ability 类型
303
+ */
304
+ type AppAbility = PureAbility<[Action, Subject]>;
305
+ /**
306
+ * 角色检查的特殊 Subject
307
+ * 用于统一角色鉴权和权限点位鉴权
308
+ *
309
+ * 使用方式:
310
+ * - 权限点位鉴权:ability.can('read', 'Todo')
311
+ * - 角色鉴权:ability.can('admin', ROLE_SUBJECT) 或 ability.can('admin', '@role')
312
+ */
313
+ declare const ROLE_SUBJECT = "@role";
314
+ /**
315
+ * Ability 工厂
316
+ * 负责根据用户权限数据创建 CASL Ability 实例
317
+ *
318
+ * 统一了两种鉴权方式:
319
+ * 1. 基于角色的鉴权 - 角色名作为 action,'@role' 作为 subject
320
+ * 2. 基于权限点位的鉴权 - 标准的 action + subject 模式
321
+ */
322
+ declare class AbilityFactory {
323
+ /**
324
+ * 为用户创建 Ability
325
+ */
326
+ createForUser(permissionData: UserPermissionData): AppAbility;
327
+ }
328
+
329
+ interface CheckPermissionsParams {
330
+ requirements: PermissionRequirement[];
331
+ or?: boolean;
332
+ }
333
+ /**
334
+ * 权限服务
335
+ * 内置权限获取和缓存逻辑,以及权限检查逻辑
336
+ */
337
+ declare class PermissionService {
338
+ private readonly apiConfig;
339
+ private readonly abilityFactory;
340
+ private readonly logger;
341
+ private readonly cache;
342
+ private readonly pendingRequests;
343
+ constructor(apiConfig: PermissionApiConfig, cacheConfig: CacheConfig, abilityFactory: AbilityFactory);
344
+ /**
345
+ * 构建权限/Ability 缓存 key
346
+ * - 若存在模拟角色:按角色集合排序拼接 + 用户维度
347
+ * - 否则按 userId/匿名用户
348
+ */
349
+ private buildCacheKey;
350
+ /**
351
+ * 获取用户权限数据(带缓存)
352
+ */
353
+ getUserPermissions(userId?: string, mockRoles?: string[]): Promise<UserPermissionData | null>;
354
+ /**
355
+ * 从 API 获取权限数据
356
+ * 内置实现,用户无需配置
357
+ */
358
+ private fetchFromApi;
359
+ /**
360
+ * 基于模拟角色获取权限数据(不使用缓存)
361
+ * 该方法用于前端/守卫在检测到 mockRoles 时直接按角色获取权限
362
+ */
363
+ getPermissionsByMockRoles(userId: string | undefined, mockRoles: string[]): Promise<UserPermissionData>;
364
+ /**
365
+ * 获取用户的 Ability 实例(带缓存)
366
+ * @param userId 用户ID
367
+ * @returns CASL Ability 实例
368
+ */
369
+ private getUserAbility;
370
+ /**
371
+ * 清除用户权限缓存
372
+ */
373
+ clearUserCache(userId: string): void;
374
+ /**
375
+ * 清除所有缓存
376
+ */
377
+ clearAllCache(): void;
378
+ /**
379
+ * 获取缓存统计信息
380
+ */
381
+ getCacheStats(): {
382
+ size: number;
383
+ hits: number;
384
+ misses: number;
385
+ hitRate: number;
386
+ enabled: boolean;
387
+ };
388
+ /**
389
+ * 检查角色要求
390
+ * 使用 CASL Ability 统一鉴权方式
391
+ * @param requirement 角色要求
392
+ * @param userId 用户ID,匿名用户时为空
393
+ * @returns 用户权限数据
394
+ * @throws PermissionDeniedException 当角色不满足时
395
+ */
396
+ checkRoles(requirement: RoleRequirement, userId?: string, mockRoles?: string[]): Promise<UserPermissionData>;
397
+ /**
398
+ * 检查权限要求
399
+ * @param requirements 权限要求列表
400
+ * @param userId 用户ID
401
+ * @returns 用户权限数据
402
+ * @throws PermissionDeniedException 当权限不满足时
403
+ */
404
+ checkPermissions(params: CheckPermissionsParams, userId?: string, mockRoles?: string[]): Promise<UserPermissionData>;
405
+ getAbility(userId: string): Promise<AppAbility>;
406
+ }
407
+
408
+ /**
409
+ * AuthZPaas 守卫
410
+ * 负责协调所有鉴权检查,具体检查逻辑委托给 PermissionService
411
+ */
412
+ declare class AuthZPaasGuard implements CanActivate {
413
+ private reflector;
414
+ private permissionService;
415
+ private moduleOptions;
416
+ constructor(reflector: Reflector, permissionService: PermissionService, moduleOptions: AuthZPaasModuleOptions);
417
+ canActivate(context: ExecutionContext): Promise<boolean>;
418
+ /**
419
+ * 从请求中提取用户ID
420
+ * 子类可以重写此方法以适应不同的认证策略
421
+ */
422
+ protected extractUserId(request: {
423
+ userContext?: {
424
+ userId?: string;
425
+ };
426
+ cookies?: Record<string, string | undefined>;
427
+ }): string | undefined;
428
+ /**
429
+ * 从请求中提取环境上下文
430
+ */
431
+ protected extractEnvironmentContext(request: {
432
+ ip?: string;
433
+ connection?: {
434
+ remoteAddress?: string;
435
+ };
436
+ headers: Record<string, string | string[] | undefined>;
437
+ query?: Record<string, unknown>;
438
+ }): EnvironmentContext;
439
+ /**
440
+ * 检测设备类型
441
+ */
442
+ private detectDeviceType;
443
+ /**
444
+ * 检查角色要求
445
+ */
446
+ private checkRoleRequirement;
447
+ /**
448
+ * 检查权限要求
449
+ */
450
+ private checkPermissionRequirement;
451
+ /**
452
+ * 检查环境要求
453
+ */
454
+ private checkEnvironmentRequirement;
455
+ /**
456
+ * 检查网络要求
457
+ */
458
+ private checkNetworkRequirement;
459
+ /**
460
+ * 检查设备要求
461
+ */
462
+ private checkDeviceRequirement;
463
+ /**
464
+ * 检查 IP 是否匹配
465
+ * 简化版本,仅支持精确匹配
466
+ * 生产环境建议使用 ipaddr.js 等库
467
+ */
468
+ private checkIPMatch;
469
+ }
470
+
471
+ /**
472
+ * 常量
473
+ */
474
+ /** 匿名用户 ID */
475
+ declare const ANONYMOUS_USER_ID = "anonymous_user_id";
476
+ /**
477
+ * 依赖注入 Token
478
+ */
479
+ /** 权限 API 配置 Token */
480
+ declare const PERMISSION_API_CONFIG_TOKEN: unique symbol;
481
+ /** 缓存配置 Token */
482
+ declare const CACHE_CONFIG_TOKEN: unique symbol;
483
+ /** AuthZPaas 模块选项 Token */
484
+ declare const AUTHZPAAS_MODULE_OPTIONS: unique symbol;
485
+ /**
486
+ * 元数据键
487
+ */
488
+ /** 需要的角色元数据键 */
489
+ declare const ROLES_KEY = "authzpaas:roles";
490
+ /** 需要的权限元数据键 */
491
+ declare const PERMISSIONS_KEY = "authzpaas:permissions";
492
+ /** 需要的环境元数据键 */
493
+ declare const ENVIRONMENT_KEY = "authzpaas:environment";
494
+ /** 需要登录元数据键 */
495
+ declare const NEED_LOGIN_KEY = "authzpaas:needLogin";
496
+ /** 模块选项:登录页路径默认值 */
497
+ declare const DEFAULT_LOGIN_PATH = "/login";
498
+ /** 角色模拟的 Cookie 键名 */
499
+ declare const MOCK_ROLES_COOKIE_KEY = "mockRoles";
500
+ declare const ENABLE_MOCK_ROLE_KEY = "__authzpaas_enableMockRole";
501
+
502
+ interface UserContext {
503
+ userId?: string;
504
+ tenantId?: number;
505
+ appId?: string;
506
+ userRoles?: string[];
507
+ }
508
+ /**
509
+ * 扩展 Express Request 类型,添加用户权限相关字段
510
+ */
511
+ declare global {
512
+ namespace Express {
513
+ interface Request {
514
+ userContext: UserContext;
515
+ [ENABLE_MOCK_ROLE_KEY]?: boolean;
516
+ }
517
+ }
518
+ }
519
+ declare class RolesMiddleware implements NestMiddleware {
520
+ private readonly permissionService;
521
+ private readonly logger;
522
+ constructor(permissionService: PermissionService);
523
+ use(req: Request, _res: Response, next: NextFunction): Promise<void>;
524
+ }
525
+
526
+ /**
527
+ * 权限拒绝异常类型
528
+ */
529
+ declare enum PermissionDeniedType {
530
+ /** 用户未认证 */
531
+ UNAUTHENTICATED = "UNAUTHENTICATED",
532
+ /** 缺少角色 */
533
+ ROLE_REQUIRED = "ROLE_REQUIRED",
534
+ /** 缺少权限 */
535
+ PERMISSION_REQUIRED = "PERMISSION_REQUIRED",
536
+ /** 环境不满足 */
537
+ ENVIRONMENT_REQUIRED = "ENVIRONMENT_REQUIRED",
538
+ /** 权限配置查询失败 */
539
+ PERMISSION_CONFIG_QUERY_FAILED = "PERMISSION_CONFIG_QUERY_FAILED"
540
+ }
541
+ /**
542
+ * 权限拒绝异常详情
543
+ */
544
+ interface PermissionDeniedDetails {
545
+ /** 错误堆栈 */
546
+ cause?: Error;
547
+ /** 异常类型 */
548
+ type: PermissionDeniedType;
549
+ /** 错误消息 */
550
+ message: string;
551
+ /** 需要的角色(如果适用) */
552
+ requiredRoles?: string[];
553
+ /** 需要的权限(如果适用) */
554
+ requiredPermissions?: Array<{
555
+ actions: string[];
556
+ subject: string;
557
+ }>;
558
+ /** 环境要求(如果适用) */
559
+ environmentRequirement?: string;
560
+ /** 额外信息 */
561
+ metadata?: Record<string, any>;
562
+ }
563
+ /**
564
+ * 权限拒绝异常
565
+ * 专门用于 AuthZPaas 模块的权限检查失败场景
566
+ */
567
+ declare class PermissionDeniedException extends HttpException {
568
+ readonly type: PermissionDeniedType;
569
+ readonly details: PermissionDeniedDetails;
570
+ constructor(details: PermissionDeniedDetails, httpStatusCode?: number);
571
+ /**
572
+ * 创建用户未认证异常
573
+ */
574
+ static unauthenticated(message?: string): PermissionDeniedException;
575
+ /**
576
+ * 创建角色不足异常
577
+ */
578
+ static roleRequired(requiredRoles: string[], and?: boolean): PermissionDeniedException;
579
+ /**
580
+ * 创建权限不足异常
581
+ */
582
+ static permissionRequired(requiredPermissions: Array<{
583
+ actions: string[];
584
+ subject: string;
585
+ }>, or?: boolean, customMessage?: string): PermissionDeniedException;
586
+ /**
587
+ * 创建环境不满足异常
588
+ */
589
+ static environmentRequired(requirement: string, message?: string): PermissionDeniedException;
590
+ }
591
+
592
+ /**
593
+ * AuthZPaas 异常过滤器
594
+ * 确保权限错误信息能够正确返回给客户端
595
+ */
596
+ declare class AuthZPaasExceptionFilter implements ExceptionFilter {
597
+ catch(exception: PermissionDeniedException, host: ArgumentsHost): void;
598
+ }
599
+
600
+ /**
601
+ * 权限数据 DTO
602
+ */
603
+ declare class PermissionDto {
604
+ sub: string;
605
+ actions: string[];
606
+ id?: string;
607
+ name?: string;
608
+ conditions?: Record<string, unknown>;
609
+ }
610
+ /**
611
+ * 权限查询响应
612
+ */
613
+ declare class PermissionResponse {
614
+ userId?: string;
615
+ roles: string[];
616
+ permissions: Permission[];
617
+ fetchedAt: Date;
618
+ }
619
+ /**
620
+ * 权限控制器
621
+ * 提供权限查询接口,供前端客户端使用
622
+ */
623
+ declare class PermissionController {
624
+ private readonly permissionService;
625
+ constructor(permissionService: PermissionService);
626
+ /**
627
+ * 获取当前用户的权限数据
628
+ *
629
+ * @param userId 当前用户ID(从请求上下文中获取)
630
+ * @returns 用户权限数据
631
+ *
632
+ * @example
633
+ * GET /api/permissions
634
+ *
635
+ * Response:
636
+ * {
637
+ * "userId": "user123",
638
+ * "roles": ["admin", "user"],
639
+ * "permissions": [
640
+ * { "sub": "task", "actions": ["create", "read", "update", "delete"] }
641
+ * ],
642
+ * "fetchedAt": "2025-10-14T00:00:00.000Z"
643
+ * }
644
+ */
645
+ getUserPermissions(userId: string, mockRoles: string[]): Promise<PermissionResponse>;
646
+ /**
647
+ * 开启角色模拟:将传入的 userId 写入 cookie,服务端优先使用该值请求权限
648
+ */
649
+ enableMock(res: Response, roles: string[]): Promise<{
650
+ success: boolean;
651
+ message: string;
652
+ roles?: undefined;
653
+ } | {
654
+ success: boolean;
655
+ roles: string[];
656
+ message?: undefined;
657
+ }>;
658
+ /**
659
+ * 关闭角色模拟:清除 cookie
660
+ */
661
+ disableMock(res: Response): Promise<{
662
+ success: boolean;
663
+ }>;
664
+ getMockRoles(mockRoles: string[] | undefined, userId: string): Promise<{
665
+ mocking: boolean;
666
+ roles: string[];
667
+ permissions: Permission[];
668
+ fetchedAt: Date;
669
+ userId: string;
670
+ }>;
671
+ }
672
+
673
+ export { ANONYMOUS_USER_ID, AUTHZPAAS_MODULE_OPTIONS, AbilityFactory, type Action, type AppAbility, AuthZPaasExceptionFilter, AuthZPaasGuard, AuthZPaasModule, type AuthZPaasModuleOptions, type AuthorizationContext, CACHE_CONFIG_TOKEN, type CacheConfig, CanEnv, CanPermission, CanRole, type CheckRoleRequirement, DEFAULT_LOGIN_PATH, type DeviceRequirement, ENABLE_MOCK_ROLE_KEY, ENVIRONMENT_KEY, type EnvironmentContext, type EnvironmentRequirement, MOCK_ROLES_COOKIE_KEY, MockRoles, NEED_LOGIN_KEY, type NetworkRequirement, PERMISSIONS_KEY, PERMISSION_API_CONFIG_TOKEN, type Permission, type PermissionApiConfig, PermissionController, type PermissionDeniedDetails, PermissionDeniedException, PermissionDeniedType, PermissionDto, type PermissionRequirement, PermissionResponse, PermissionService, ROLES_KEY, ROLE_SUBJECT, type RoleRequirement, RolesMiddleware, type Subject, type UserContext, UserId, type UserPermissionData, type UserRole };