feat(troubleshooting): roll-back du dernier commit et clean de debugg comments
This commit is contained in:
parent
a80dd357a3
commit
3a0dc4c1ce
|
|
@ -5,12 +5,12 @@ import { Request, Response } from 'express';
|
|||
@Controller('auth')
|
||||
export class AuthController {
|
||||
|
||||
// @UseGuards(OIDCLoginGuard)
|
||||
@UseGuards(OIDCLoginGuard)
|
||||
@Get('/v1/login')
|
||||
login() { }
|
||||
|
||||
@Get('/callback')
|
||||
// @UseGuards(OIDCLoginGuard)
|
||||
@UseGuards(OIDCLoginGuard)
|
||||
loginCallback(@Req() req: Request, @Res() res: Response) {
|
||||
// res.redirect('http://10.100.251.2:9011/#/login-success');
|
||||
res.redirect('http://localhost:9000/#/login-success');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export class OIDCLoginGuard extends AuthGuard('openidconnect') {
|
|||
async canActivate(context: ExecutionContext) {
|
||||
const result = (await super.canActivate(context)) as boolean;
|
||||
const request = context.switchToHttp().getRequest();
|
||||
console.log('JWT HEADER:', request.headers.authorization);
|
||||
await super.logIn(request);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ export class AuthentikStrategy extends PassportStrategy(OIDCStrategy, 'openidcon
|
|||
|
||||
const components = _idToken.split('.');
|
||||
const payload = Buffer.from(components[1], "base64").toString('utf-8');
|
||||
console.log('JWT PAYLOAD:', payload);
|
||||
const claims = JSON.parse(payload);
|
||||
|
||||
if (!claims.email) return cb(new Error('Missing email in OIDC profile'), false);
|
||||
|
|
|
|||
78
src/main.ts
78
src/main.ts
|
|
@ -4,19 +4,16 @@ if (!(globalThis as any).crypto) {
|
|||
(globalThis as any).crypto = nodeCrypto;
|
||||
}
|
||||
import { ensureAttachmentsTmpDir } from './time-and-attendance/attachments/config/attachment.fs';
|
||||
import { resolveAttachmentsRoot } from './time-and-attendance/attachments/config/attachment.config';// log to be removed post dev
|
||||
import { ATT_TMP_DIR } from './time-and-attendance/attachments/config/attachment.config'; // log to be removed post dev
|
||||
import { NestFactory, Reflector } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
// import { JwtAuthGuard } from './modules/authentication/guards/jwt-auth.guard';
|
||||
import { ModulesGuard } from './common/guards/modules.guard';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { writeFileSync } from 'fs';
|
||||
// import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
// import { writeFileSync } from 'fs';
|
||||
import * as session from 'express-session';
|
||||
import * as passport from 'passport';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { PrismaSessionStore } from '@quixo3/prisma-session-store';
|
||||
|
||||
// import { extractOldShifts } from 'scripts/migrate-shifts';
|
||||
// import { extractOldTimesheets } from 'scripts/migrate-timesheets';
|
||||
// import { extractOldExpenses } from 'scripts/migrate-expenses';
|
||||
|
|
@ -24,23 +21,10 @@ import { PrismaSessionStore } from '@quixo3/prisma-session-store';
|
|||
const SESSION_TOKEN_DURATION_MINUTES = 180
|
||||
|
||||
async function bootstrap() {
|
||||
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const prisma_service = app.get(PrismaService);
|
||||
const reflector = app.get(Reflector);
|
||||
|
||||
app.use((req, res, next) => {
|
||||
console.log('--- INCOMING REQUEST ---');
|
||||
console.log('METHOD:', req.method);
|
||||
console.log('URL:', req.originalUrl);
|
||||
console.log('HEADERS:', req.headers);
|
||||
console.log('BODY:', req.body);
|
||||
console.log('------------------------');
|
||||
console.log(req.headers.authorization);
|
||||
console.log(req.headers['x-authentik-signature']);
|
||||
console.log(req.headers['content-type)']);
|
||||
next();
|
||||
});
|
||||
const reflector = app.get(Reflector);
|
||||
|
||||
app.useGlobalGuards(
|
||||
// new JwtAuthGuard(reflector), //Authentification JWT
|
||||
|
|
@ -73,35 +57,35 @@ async function bootstrap() {
|
|||
credentials: true,
|
||||
});
|
||||
|
||||
//swagger config
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Targo_Backend')
|
||||
.setDescription('Documentation de l`API REST pour Targo (NestJS + Prisma)')
|
||||
.setVersion('1.0')
|
||||
.addBearerAuth({
|
||||
type: 'http',
|
||||
scheme: 'bearer',
|
||||
bearerFormat: 'JWT',
|
||||
name: 'Authorization',
|
||||
description: 'Invalid JWT token',
|
||||
in: 'header',
|
||||
}, 'access-token')
|
||||
.addTag('Users')
|
||||
.addTag('Employees')
|
||||
.addTag('Customers')
|
||||
.addTag('Timesheets')
|
||||
.addTag('Shifts')
|
||||
.addTag('Leave Requests')
|
||||
.addTag('Shift Codes')
|
||||
.addTag('OAuth Access Tokens')
|
||||
.addTag('Authorization')
|
||||
.build();
|
||||
// //swagger config
|
||||
// const config = new DocumentBuilder()
|
||||
// .setTitle('Targo_Backend')
|
||||
// .setDescription('Documentation de l`API REST pour Targo (NestJS + Prisma)')
|
||||
// .setVersion('1.0')
|
||||
// .addBearerAuth({
|
||||
// type: 'http',
|
||||
// scheme: 'bearer',
|
||||
// bearerFormat: 'JWT',
|
||||
// name: 'Authorization',
|
||||
// description: 'Invalid JWT token',
|
||||
// in: 'header',
|
||||
// }, 'access-token')
|
||||
// .addTag('Users')
|
||||
// .addTag('Employees')
|
||||
// .addTag('Customers')
|
||||
// .addTag('Timesheets')
|
||||
// .addTag('Shifts')
|
||||
// .addTag('Leave Requests')
|
||||
// .addTag('Shift Codes')
|
||||
// .addTag('OAuth Access Tokens')
|
||||
// .addTag('Authorization')
|
||||
// .build();
|
||||
|
||||
//document builder for swagger docs
|
||||
const documentFactory = () => SwaggerModule.createDocument(app, config);
|
||||
const document = documentFactory()
|
||||
SwaggerModule.setup('api/docs', app, document);
|
||||
writeFileSync('./docs/swagger/swagger-spec.json', JSON.stringify(document, null, 2));
|
||||
// //document builder for swagger docs
|
||||
// const documentFactory = () => SwaggerModule.createDocument(app, config);
|
||||
// const document = documentFactory()
|
||||
// SwaggerModule.setup('api/docs', app, document);
|
||||
// writeFileSync('./docs/swagger/swagger-spec.json', JSON.stringify(document, null, 2));
|
||||
|
||||
await ensureAttachmentsTmpDir();
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user