fix(auth): change auth to work with remote docker lab

This commit is contained in:
Nicolas 2025-10-30 14:23:52 -04:00
parent 2dd8bdb3c3
commit 78aec894ed
3 changed files with 57 additions and 57 deletions

View File

@ -17,7 +17,7 @@ ENV AUTHENTIK_AUTH_URL="https://auth.targo.ca/application/o/authorize/"
ENV AUTHENTIK_TOKEN_URL="https://auth.targo.ca/application/o/token/"
ENV AUTHENTIK_USERINFO_URL="https://auth.targo.ca/application/o/userinfo/"
ENV TARGO_FRONTEND_URI="http://localhost:9000/"
ENV TARGO_FRONTEND_URI="http://10.100.251.2/"
ENV ATTACHMENTS_SERVER_ID="server"
ENV ATTACHMENTS_ROOT=C:/

View File

@ -12,7 +12,7 @@ export class AuthController {
@Get('/callback')
@UseGuards(OIDCLoginGuard)
loginCallback(@Req() req: Request, @Res() res: Response) {
res.redirect('http://localhost:9000/#/login-success');
res.redirect('http://10.100.251.2:9011/#/login-success');
}
@Get('/me')

View File

@ -1,8 +1,8 @@
import 'reflect-metadata';
//import and if case for @nestjs/schedule Cron jobs
import * as nodeCrypto from 'crypto';
if(!(globalThis as any).crypto) {
(globalThis as any).crypto = nodeCrypto;
if (!(globalThis as any).crypto) {
(globalThis as any).crypto = nodeCrypto;
}
import { ensureAttachmentsTmpDir } from './config/attachment.fs';
@ -20,59 +20,59 @@ import * as session from 'express-session';
import * as passport from 'passport';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create(AppModule);
const reflector = app.get(Reflector); //setup Reflector for Roles()
const reflector = app.get(Reflector); //setup Reflector for Roles()
app.useGlobalGuards(
// new JwtAuthGuard(reflector), //Authentification JWT
new RolesGuard(reflector), //deny-by-default and Role-based Access Control
new OwnershipGuard(reflector, app.get(ModuleRef)), //Global use of OwnershipGuard, not implemented yet
);
app.useGlobalGuards(
// new JwtAuthGuard(reflector), //Authentification JWT
new RolesGuard(reflector), //deny-by-default and Role-based Access Control
new OwnershipGuard(reflector, app.get(ModuleRef)), //Global use of OwnershipGuard, not implemented yet
);
// Authentication and session
app.use(session({
secret: 'This is a super secret dev secret that you cant share with anyone',
resave: false,
saveUninitialized: false,
rolling: true,
cookie: {
maxAge: 30 * 60 * 1000,
httpOnly: true,
}
}))
app.use(passport.initialize());
app.use(passport.session());
// Authentication and session
app.use(session({
secret: 'This is a super secret dev secret that you cant share with anyone',
resave: false,
saveUninitialized: false,
rolling: true,
cookie: {
maxAge: 30 * 60 * 1000,
httpOnly: true,
}
}))
app.use(passport.initialize());
app.use(passport.session());
// Enable CORS
app.enableCors({
origin: 'http://localhost:9000',
credentials: true,
});
// Enable CORS
app.enableCors({
origin: ['http://10.100.251.2:9011', 'http://10.100.251.2:9012', 'http://10.100.251.2:9013'],
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);
@ -85,7 +85,7 @@ async function bootstrap() {
console.log('[resolveAttachmentsRoot()]', resolveAttachmentsRoot());
console.log('[ATT_TMP_DIR()]', ATT_TMP_DIR());
await ensureAttachmentsTmpDir();
await app.listen(process.env.PORT ?? 3000);
await ensureAttachmentsTmpDir();
await app.listen(process.env.PORT ?? 3000);
}
bootstrap();