This commit is contained in:
alex-sviridov 2026-02-26 21:20:54 +02:00 committed by GitHub
commit ecac07d7d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 319 additions and 2 deletions

View file

@ -64,6 +64,10 @@ class ServerSettings {
this.authLoginCustomMessage = null
this.authActiveAuthMethods = ['local']
// Proxy authentication settings
this.authProxyHeaderName = null
this.authProxyLogoutURL = null
// openid settings
this.authOpenIDIssuerURL = null
this.authOpenIDAuthorizationURL = null
@ -147,10 +151,21 @@ class ServerSettings {
this.authOpenIDAdvancedPermsClaim = settings.authOpenIDAdvancedPermsClaim || ''
this.authOpenIDSubfolderForRedirectURLs = settings.authOpenIDSubfolderForRedirectURLs
this.authProxyHeaderName = settings.authProxyHeaderName || null
this.authProxyLogoutURL = settings.authProxyLogoutURL || null
if (!Array.isArray(this.authActiveAuthMethods)) {
this.authActiveAuthMethods = ['local']
}
// Environment variable to enable proxy authentication (only during initialization)
if (process.env.AUTH_PROXY_ENABLED === 'true' || process.env.AUTH_PROXY_ENABLED === '1') {
if (!this.authActiveAuthMethods.includes('proxy')) {
Logger.info(`[ServerSettings] Enabling proxy authentication from environment variable AUTH_PROXY_ENABLED`)
this.authActiveAuthMethods.push('proxy')
}
}
// remove uninitialized methods
// OpenID
if (this.authActiveAuthMethods.includes('openid') && !this.isOpenIDAuthSettingsValid) {
@ -200,6 +215,16 @@ class ServerSettings {
Logger.info(`[ServerSettings] Using allowIframe from environment variable`)
this.allowIframe = true
}
// Proxy authentication environment override
if (process.env.AUTH_PROXY_HEADER_NAME) {
Logger.info(`[ServerSettings] Using proxy header name from environment variable: ${process.env.AUTH_PROXY_HEADER_NAME}`)
this.authProxyHeaderName = process.env.AUTH_PROXY_HEADER_NAME
}
if (process.env.AUTH_PROXY_LOGOUT_URL) {
Logger.info(`[ServerSettings] Using proxy logout URL from environment variable: ${process.env.AUTH_PROXY_LOGOUT_URL}`)
this.authProxyLogoutURL = process.env.AUTH_PROXY_LOGOUT_URL
}
}
toJSON() {
@ -239,6 +264,8 @@ class ServerSettings {
buildNumber: this.buildNumber,
authLoginCustomMessage: this.authLoginCustomMessage,
authActiveAuthMethods: this.authActiveAuthMethods,
authProxyHeaderName: this.authProxyHeaderName,
authProxyLogoutURL: this.authProxyLogoutURL,
authOpenIDIssuerURL: this.authOpenIDIssuerURL,
authOpenIDAuthorizationURL: this.authOpenIDAuthorizationURL,
authOpenIDTokenURL: this.authOpenIDTokenURL,
@ -271,7 +298,7 @@ class ServerSettings {
}
get supportedAuthMethods() {
return ['local', 'openid']
return ['local', 'openid', 'proxy']
}
/**
@ -285,6 +312,8 @@ class ServerSettings {
return {
authLoginCustomMessage: this.authLoginCustomMessage,
authActiveAuthMethods: this.authActiveAuthMethods,
authProxyHeaderName: this.authProxyHeaderName,
authProxyLogoutURL: this.authProxyLogoutURL,
authOpenIDIssuerURL: this.authOpenIDIssuerURL,
authOpenIDAuthorizationURL: this.authOpenIDAuthorizationURL,
authOpenIDTokenURL: this.authOpenIDTokenURL,