addition of new dashboard

This commit is contained in:
2026-08-20 15:08:32 +00:00
parent 0622018d95
commit bf59249ed7
161 changed files with 13170 additions and 119 deletions

View File

@@ -0,0 +1,52 @@
import OpenIDConnectStrategy from "passport-openidconnect";
import { checkUser } from "../../http/auth.js";
import { getConfig } from "../../common/config.js";
const key = 'oidc';
export function getModuleConfig() {
const config = getConfig();
return {
title: 'FedID',
icon: 'login',
issuer: process.env.OIDC_ISSUER,
authorizationURL: process.env.OIDC_AUTHORIZATION_URL,
tokenURL: process.env.OIDC_TOKEN_URL,
userInfoURL: process.env.OIDC_USERINFO_URL,
logoutURL: process.env.OIDC_LOGOUT_URL,
clientID: process.env.OIDC_CLIENT_ID,
clientSecret: process.env.OIDC_CLIENT_SECRET,
callbackURL: `${config.publicCallbackUrl}/callback/${key}`,
}
}
export async function initModule(app, passport) {
const config = getConfig();
passport.use(new OpenIDConnectStrategy(
config.authModules[key],
function verify(issuer, profile, cb) {
(async () => {
try {
const user = await checkUser(key, issuer, profile.id, profile.username);
return cb(null, user);
} catch (e) {
if (config.debug)
console.error(e);
return cb(null, null);
}
})();
}
));
app.get(`/login/${key}`,passport.authenticate('openidconnect'));
app.get(`/callback/${key}`,
passport.authenticate('openidconnect', {
failureRedirect: '/',
failureMessage: true
}),
function (req, res) {
req.session.authStrategy = 'oidc';
res.redirect('/home');
}
);
}