mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
feat: 🎸 set SSO login logic
This commit is contained in:
parent
fa44a5343b
commit
db3bf4c12c
@ -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,
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user