first commit

This commit is contained in:
KIENTZ Alexandre 2025-12-03 22:08:26 +01:00
parent 0cebc620aa
commit 159face27e
2 changed files with 5 additions and 1 deletions

View File

@ -46,13 +46,15 @@ export function getOIDCClient() {
export function getAuthorizationUrl(req) { export function getAuthorizationUrl(req) {
const client = getOIDCClient(); const client = getOIDCClient();
const nonce = Math.random().toString(36).substring(7); const nonce = Math.random().toString(36).substring(7);
const state = Math.random().toString(36).substring(7);
req.session.nonce = nonce; req.session.nonce = nonce;
req.session.state = state;
return client.authorizationUrl({ return client.authorizationUrl({
scope: 'openid profile email', scope: 'openid profile email',
response_mode: 'form_post', response_mode: 'form_post',
nonce, nonce,
state: Math.random().toString(36).substring(7), state,
}); });
} }
@ -65,6 +67,7 @@ export async function handleCallback(req) {
const tokenSet = await client.callback(config.oidc.redirectUri, params, { const tokenSet = await client.callback(config.oidc.redirectUri, params, {
nonce: req.session.nonce, nonce: req.session.nonce,
state: req.session.state,
}); });
const userInfo = await client.userinfo(tokenSet); const userInfo = await client.userinfo(tokenSet);

View File

@ -54,6 +54,7 @@ async function initialize() {
} }
// Middleware // Middleware
app.trust('proxy');
app.use(requestLogger); app.use(requestLogger);
app.use(securityHeaders); app.use(securityHeaders);
app.use(bodyParser.json({ limit: '10mb' })); app.use(bodyParser.json({ limit: '10mb' }));