feat(auth): implement OIDC JWT verification with dynamic identity provider support
- Added JwtService (azure-jwt.service.ts) to verify tokens from multiple IdPs (Microsoft Entra ID, Amazon Cognito) - Implemented dynamic provider configuration (issuer, audience, jwksUri) - Added JwtAuthGuard for NestJS to handle JWT validation via jose library - Integrated @Public() and @IdP() decorators for route-level control - Audience () and issuer () validation logic aligned with OIDC standards - Added clock tolerance and allowed algorithm checks for security hardening
This commit is contained in:
1 parent
02255d7240
commit
d6b9477094
14 files changed
+346
-47
No files matched your search
+17
-13
@@ -5,20 +5,24 @@ import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const apiVersion = 1;
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Cats example')
|
||||
.setDescription('The cats API description')
|
||||
.setVersion('1.0')
|
||||
.addTag('cats')
|
||||
.build();
|
||||
const options: SwaggerCustomOptions = {
|
||||
ui: false, // Swagger UI is disabled
|
||||
raw: ['yaml'], // JSON API definition is still accessible (YAML is disabled)
|
||||
}
|
||||
const documentFactory = () => SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api', app, documentFactory, options);
|
||||
if (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'test') {
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Gemwiki API')
|
||||
.setDescription('The Gemwiki API description')
|
||||
.setVersion('1.0')
|
||||
.addTag('gemwiki')
|
||||
.build();
|
||||
const options: SwaggerCustomOptions = {
|
||||
ui: false,
|
||||
raw: ['yaml'],
|
||||
}
|
||||
const documentFactory = () => SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup(`v${apiVersion}/api`, app, documentFactory, options);
|
||||
}
|
||||
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
app.setGlobalPrefix(`v${apiVersion}`);
|
||||
await app.listen(process.env.PORT ?? 3415);
|
||||
}
|
||||
bootstrap();
|
||||
Reference in new issue
Block a user