This repository has been archived on 2024-06-14. You can view files and clone it, but cannot push or open issues or pull requests.
icynet-auth-server/src/modules/static-front-end/oauth2-router/oauth2-router.module.ts

26 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-08-27 08:59:26 +00:00
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AuthMiddleware } from 'src/middleware/auth.middleware';
2022-09-01 17:19:08 +00:00
import { CSRFMiddleware } from 'src/middleware/csrf.middleware';
import { UserMiddleware } from 'src/middleware/user.middleware';
2022-08-27 08:59:26 +00:00
import { ValidateCSRFMiddleware } from 'src/middleware/validate-csrf.middleware';
import { OAuth2Module } from 'src/modules/oauth2/oauth2.module';
import { OAuth2Service } from 'src/modules/oauth2/oauth2.service';
import { UserModule } from 'src/modules/objects/user/user.module';
import { OAuth2Controller } from './oauth2-router.controller';
@Module({
controllers: [OAuth2Controller],
imports: [OAuth2Module, UserModule],
})
export class OAuth2RouterModule implements NestModule {
constructor(private _service: OAuth2Service) {}
configure(consumer: MiddlewareConsumer) {
2022-09-01 17:19:08 +00:00
consumer.apply(CSRFMiddleware, UserMiddleware).forRoutes(OAuth2Controller);
2022-08-27 08:59:26 +00:00
consumer.apply(this._service.oauth.express()).forRoutes('oauth2/*');
consumer
.apply(AuthMiddleware, ValidateCSRFMiddleware)
.forRoutes('oauth2/authorize');
}
}