mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 22:57:32 +00:00
refactor(server): auth, oidc and admin nest modules read env via app-config
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Controller, Get, Query, Req, Res } from '@nestjs/common';
|
||||
import type { Request, Response } from 'express';
|
||||
import { readEnv } from '../../app-config';
|
||||
import { OidcService } from './oidc.service';
|
||||
import { cookieOptions } from '../../services/cookie';
|
||||
|
||||
@@ -29,7 +30,7 @@ export class OidcController {
|
||||
res.status(400).json({ error: 'OIDC not configured' });
|
||||
return;
|
||||
}
|
||||
if (config.issuer && !config.issuer.startsWith('https://') && process.env.NODE_ENV?.toLowerCase() === 'production') {
|
||||
if (config.issuer && !config.issuer.startsWith('https://') && readEnv().app.isProduction) {
|
||||
res.status(400).json({ error: 'OIDC issuer must use HTTPS in production' });
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +53,7 @@ export class OidcController {
|
||||
response_type: 'code',
|
||||
client_id: config.clientId,
|
||||
redirect_uri: redirectUri,
|
||||
scope: process.env.OIDC_SCOPE || 'openid email profile',
|
||||
scope: readEnv().oidc.scope,
|
||||
state,
|
||||
code_challenge: codeChallenge,
|
||||
code_challenge_method: 'S256',
|
||||
@@ -93,7 +94,7 @@ export class OidcController {
|
||||
|
||||
const config = this.oidc.getOidcConfig();
|
||||
if (!config) return f('/login?oidc_error=not_configured');
|
||||
if (config.issuer && !config.issuer.startsWith('https://') && process.env.NODE_ENV?.toLowerCase() === 'production') {
|
||||
if (config.issuer && !config.issuer.startsWith('https://') && readEnv().app.isProduction) {
|
||||
return f('/login?oidc_error=issuer_not_https');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user