mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Fix initialize openid auth strategy
This commit is contained in:
parent
e07d17c472
commit
89eb857c14
@ -69,6 +69,11 @@ class Auth {
|
|||||||
* Passport use OpenIDClient.Strategy
|
* Passport use OpenIDClient.Strategy
|
||||||
*/
|
*/
|
||||||
initAuthStrategyOpenID() {
|
initAuthStrategyOpenID() {
|
||||||
|
if (!Database.serverSettings.isOpenIDAuthSettingsValid) {
|
||||||
|
Logger.error(`[Auth] Cannot init openid auth strategy - invalid settings`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const openIdIssuerClient = new OpenIDClient.Issuer({
|
const openIdIssuerClient = new OpenIDClient.Issuer({
|
||||||
issuer: global.ServerSettings.authOpenIDIssuerURL,
|
issuer: global.ServerSettings.authOpenIDIssuerURL,
|
||||||
authorization_endpoint: global.ServerSettings.authOpenIDAuthorizationURL,
|
authorization_endpoint: global.ServerSettings.authOpenIDAuthorizationURL,
|
||||||
|
@ -556,10 +556,10 @@ class MiscController {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 'add':
|
case 'add':
|
||||||
this.watcher.onFileAdded(libraryId, path)
|
this.watcher.onFileAdded(libraryId, path)
|
||||||
break;
|
break
|
||||||
case 'unlink':
|
case 'unlink':
|
||||||
this.watcher.onFileRemoved(libraryId, path)
|
this.watcher.onFileRemoved(libraryId, path)
|
||||||
break;
|
break
|
||||||
case 'rename':
|
case 'rename':
|
||||||
const oldPath = req.body.oldPath
|
const oldPath = req.body.oldPath
|
||||||
if (!oldPath) {
|
if (!oldPath) {
|
||||||
@ -567,7 +567,7 @@ class MiscController {
|
|||||||
return res.sendStatus(400)
|
return res.sendStatus(400)
|
||||||
}
|
}
|
||||||
this.watcher.onFileRename(libraryId, oldPath, path)
|
this.watcher.onFileRename(libraryId, oldPath, path)
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
Logger.error(`[MiscController] Invalid type for updateWatchedPath. type: "${type}"`)
|
Logger.error(`[MiscController] Invalid type for updateWatchedPath. type: "${type}"`)
|
||||||
return res.sendStatus(400)
|
return res.sendStatus(400)
|
||||||
@ -670,6 +670,8 @@ class MiscController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasUpdates) {
|
if (hasUpdates) {
|
||||||
|
await Database.updateServerSettings()
|
||||||
|
|
||||||
// Use/unuse auth methods
|
// Use/unuse auth methods
|
||||||
Database.serverSettings.supportedAuthMethods.forEach((authMethod) => {
|
Database.serverSettings.supportedAuthMethods.forEach((authMethod) => {
|
||||||
if (originalAuthMethods.includes(authMethod) && !Database.serverSettings.authActiveAuthMethods.includes(authMethod)) {
|
if (originalAuthMethods.includes(authMethod) && !Database.serverSettings.authActiveAuthMethods.includes(authMethod)) {
|
||||||
@ -682,8 +684,6 @@ class MiscController {
|
|||||||
this.auth.useAuthStrategy(authMethod)
|
this.auth.useAuthStrategy(authMethod)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await Database.updateServerSettings()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
@ -133,15 +133,7 @@ class ServerSettings {
|
|||||||
|
|
||||||
// remove uninitialized methods
|
// remove uninitialized methods
|
||||||
// OpenID
|
// OpenID
|
||||||
if (this.authActiveAuthMethods.includes('openid') && (
|
if (this.authActiveAuthMethods.includes('openid') && !this.isOpenIDAuthSettingsValid) {
|
||||||
!this.authOpenIDIssuerURL ||
|
|
||||||
!this.authOpenIDAuthorizationURL ||
|
|
||||||
!this.authOpenIDTokenURL ||
|
|
||||||
!this.authOpenIDUserInfoURL ||
|
|
||||||
!this.authOpenIDJwksURL ||
|
|
||||||
!this.authOpenIDClientID ||
|
|
||||||
!this.authOpenIDClientSecret
|
|
||||||
)) {
|
|
||||||
this.authActiveAuthMethods.splice(this.authActiveAuthMethods.indexOf('openid', 0), 1)
|
this.authActiveAuthMethods.splice(this.authActiveAuthMethods.indexOf('openid', 0), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +227,19 @@ class ServerSettings {
|
|||||||
return ['local', 'openid']
|
return ['local', 'openid']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auth settings required for openid to be valid
|
||||||
|
*/
|
||||||
|
get isOpenIDAuthSettingsValid() {
|
||||||
|
return this.authOpenIDIssuerURL &&
|
||||||
|
this.authOpenIDAuthorizationURL &&
|
||||||
|
this.authOpenIDTokenURL &&
|
||||||
|
this.authOpenIDUserInfoURL &&
|
||||||
|
this.authOpenIDJwksURL &&
|
||||||
|
this.authOpenIDClientID &&
|
||||||
|
this.authOpenIDClientSecret
|
||||||
|
}
|
||||||
|
|
||||||
get authenticationSettings() {
|
get authenticationSettings() {
|
||||||
return {
|
return {
|
||||||
authActiveAuthMethods: this.authActiveAuthMethods,
|
authActiveAuthMethods: this.authActiveAuthMethods,
|
||||||
|
Loading…
Reference in New Issue
Block a user