Skip to content

Build your personal knowledge base with Trilium Notes

feat: 🎸 set SSO login logic

Jindb3bf4c12c1b
diff --git a/apps/server/src/routes/login.ts b/apps/server/src/routes/login.ts
index d428f21bf9..10bfa5b944 100644
--- a/apps/server/src/routes/login.ts
+++ b/apps/server/src/routes/login.ts
@@ -19,6 +19,8 @@ function loginPage(req: Request, res: Response) {
wrongTotp: false,
totpEnabled: totp.isTotpEnabled(),
ssoEnabled: openID.isOpenIDEnabled(),
+ ssoIssuerName: openID.getSSOIssuerName(),
+ ssoIssuerIcon: openID.getSSOIssuerIcon(),
assetPath: assetPath,
assetPathFragment: assetUrlFragment,
appPath: appPath,
diff --git a/apps/server/src/services/open_id.ts b/apps/server/src/services/open_id.ts
index e45ed65997..2ae3bbe1ef 100644
--- a/apps/server/src/services/open_id.ts
+++ b/apps/server/src/services/open_id.ts
@@ -8,7 +8,7 @@ import config from "./config.js";
function checkOpenIDConfig() {
- let missingVars: string[] = []
+ const missingVars: string[] = []
if (config.MultiFactorAuthentication.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() {
const authRoutes = {
callback: "/callback",
@@ -105,7 +113,7 @@ function generateOAuthConfig() {
auth0Logout: false,
baseURL: config.MultiFactorAuthentication.oauthBaseUrl,
clientID: config.MultiFactorAuthentication.oauthClientId,
- issuerBaseURL: "https://accounts.google.com",
+ issuerBaseURL: config.MultiFactorAuthentication.oauthIssuerBaseUrl,
secret: config.MultiFactorAuthentication.oauthClientSecret,
clientSecret: config.MultiFactorAuthentication.oauthClientSecret,
authorizationParams: {
@@ -147,6 +155,8 @@ function generateOAuthConfig() {
export default {
generateOAuthConfig,
getOAuthStatus,
+ getSSOIssuerName,
+ getSSOIssuerIcon,
isOpenIDEnabled,
clearSavedUser,
isTokenValid,