|
|
|
@ -6,7 +6,7 @@ import { Permission } from '@server/lib/permissions';
|
|
|
|
|
import { getSettings } from '@server/lib/settings';
|
|
|
|
|
import logger from '@server/logger';
|
|
|
|
|
import { isAuthenticated } from '@server/middleware/auth';
|
|
|
|
|
import { Router } from 'express';
|
|
|
|
|
import { Router, Request } from 'express';
|
|
|
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
|
|
|
import {
|
|
|
|
|
createJwtSchema,
|
|
|
|
@ -443,7 +443,21 @@ authRoutes.get('/oidc-login', async (req, res, next) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
authRoutes.get('/oidc-callback', async (req, res, next) => {
|
|
|
|
|
logger.info('OIDC callback initiated', { req });
|
|
|
|
|
try {
|
|
|
|
|
const logRequestInfo = (req: Request) => {
|
|
|
|
|
const remoteIp = req.headers['x-real-ip'] || req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
|
|
|
|
const requestInfo = {
|
|
|
|
|
method: req.method,
|
|
|
|
|
url: req.url,
|
|
|
|
|
headers: req.headers,
|
|
|
|
|
remoteIp: remoteIp,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return requestInfo;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
logger.info('OIDC callback initiated', { req: logRequestInfo(req) });
|
|
|
|
|
|
|
|
|
|
const settings = getSettings();
|
|
|
|
|
const { oidcDomain, oidcClientId, oidcClientSecret } = settings.main;
|
|
|
|
|
|
|
|
|
@ -598,6 +612,17 @@ authRoutes.get('/oidc-callback', async (req, res, next) => {
|
|
|
|
|
});
|
|
|
|
|
return res.redirect('/login');
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// Log the error details
|
|
|
|
|
logger.error('Error in OIDC callback', {
|
|
|
|
|
path: '/oidc-callback',
|
|
|
|
|
error: error.message,
|
|
|
|
|
stack: error.stack, // Include the error stack trace for debugging
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Handle the error as appropriate for your application
|
|
|
|
|
next(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|