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