-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcedar-authorization.module.ts
More file actions
36 lines (35 loc) · 1.49 KB
/
cedar-authorization.module.ts
File metadata and controls
36 lines (35 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Global, MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthMiddleware } from '../../authorization/auth.middleware.js';
import { GlobalDatabaseContext } from '../../common/application/global-database-context.js';
import { BaseType } from '../../common/data-injection.tokens.js';
import { LogOutEntity } from '../log-out/log-out.entity.js';
import { UserEntity } from '../user/user.entity.js';
import { CedarAuthorizationController } from './cedar-authorization.controller.js';
import { CedarAuthorizationService } from './cedar-authorization.service.js';
import { CedarPermissionsService } from './cedar-permissions.service.js';
@Global()
@Module({
imports: [TypeOrmModule.forFeature([UserEntity, LogOutEntity])],
providers: [
{
provide: BaseType.GLOBAL_DB_CONTEXT,
useClass: GlobalDatabaseContext,
},
CedarAuthorizationService,
CedarPermissionsService,
],
controllers: [CedarAuthorizationController],
exports: [CedarAuthorizationService, CedarPermissionsService],
})
export class CedarAuthorizationModule implements NestModule {
public configure(consumer: MiddlewareConsumer): void {
consumer
.apply(AuthMiddleware)
.forRoutes(
{ path: '/connection/cedar-schema/:connectionId', method: RequestMethod.GET },
{ path: '/connection/cedar-schema/validate/:connectionId', method: RequestMethod.POST },
{ path: '/connection/cedar-policy/:connectionId', method: RequestMethod.POST },
);
}
}