feat: 🎸 set SSO login logic

This commit is contained in:
Jin 2025-06-06 17:16:11 +02:00 committed by JYC333
parent fa44a5343b
commit db3bf4c12c
2 changed files with 14 additions and 2 deletions

View File

@ -19,6 +19,8 @@ function loginPage(req: Request, res: Response) {
wrongTotp: false, wrongTotp: false,
totpEnabled: totp.isTotpEnabled(), totpEnabled: totp.isTotpEnabled(),
ssoEnabled: openID.isOpenIDEnabled(), ssoEnabled: openID.isOpenIDEnabled(),
ssoIssuerName: openID.getSSOIssuerName(),
ssoIssuerIcon: openID.getSSOIssuerIcon(),
assetPath: assetPath, assetPath: assetPath,
assetPathFragment: assetUrlFragment, assetPathFragment: assetUrlFragment,
appPath: appPath, appPath: appPath,

View File

@ -8,7 +8,7 @@ import config from "./config.js";
function checkOpenIDConfig() { function checkOpenIDConfig() {
let missingVars: string[] = [] const missingVars: string[] = []
if (config.MultiFactorAuthentication.oauthBaseUrl === "") { if (config.MultiFactorAuthentication.oauthBaseUrl === "") {
missingVars.push("oauthBaseUrl"); missingVars.push("oauthBaseUrl");
} }
@ -89,6 +89,14 @@ function isTokenValid(req: Request, res: Response, next: NextFunction) {
} }
} }
function getSSOIssuerName() {
return config.MultiFactorAuthentication.oauthIssuerName;
}
function getSSOIssuerIcon() {
return config.MultiFactorAuthentication.oauthIssuerIcon;
}
function generateOAuthConfig() { function generateOAuthConfig() {
const authRoutes = { const authRoutes = {
callback: "/callback", callback: "/callback",
@ -105,7 +113,7 @@ function generateOAuthConfig() {
auth0Logout: false, auth0Logout: false,
baseURL: config.MultiFactorAuthentication.oauthBaseUrl, baseURL: config.MultiFactorAuthentication.oauthBaseUrl,
clientID: config.MultiFactorAuthentication.oauthClientId, clientID: config.MultiFactorAuthentication.oauthClientId,
issuerBaseURL: "https://accounts.google.com", issuerBaseURL: config.MultiFactorAuthentication.oauthIssuerBaseUrl,
secret: config.MultiFactorAuthentication.oauthClientSecret, secret: config.MultiFactorAuthentication.oauthClientSecret,
clientSecret: config.MultiFactorAuthentication.oauthClientSecret, clientSecret: config.MultiFactorAuthentication.oauthClientSecret,
authorizationParams: { authorizationParams: {
@ -147,6 +155,8 @@ function generateOAuthConfig() {
export default { export default {
generateOAuthConfig, generateOAuthConfig,
getOAuthStatus, getOAuthStatus,
getSSOIssuerName,
getSSOIssuerIcon,
isOpenIDEnabled, isOpenIDEnabled,
clearSavedUser, clearSavedUser,
isTokenValid, isTokenValid,