feat(xo-server): passport strategies can be unregistered (#4702)

Now all authentication plugins can be unloaded.
This commit is contained in:
Julien Fontanet
2019-12-09 10:51:35 +01:00
committed by GitHub
parent c162a7d3b1
commit 8017e42797
4 changed files with 24 additions and 5 deletions
+6 -1
View File
@@ -48,6 +48,7 @@ You should try \`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddr
class AuthSamlXoPlugin {
constructor({ xo }) {
this._conf = null
this._unregisterPassportStrategy = undefined
this._usernameField = null
this._xo = xo
}
@@ -66,7 +67,7 @@ class AuthSamlXoPlugin {
load() {
const xo = this._xo
xo.registerPassportStrategy(
this._unregisterPassportStrategy = xo.registerPassportStrategy(
new Strategy(this._conf, async (profile, done) => {
const name = profile[this._usernameField]
if (!name) {
@@ -83,6 +84,10 @@ class AuthSamlXoPlugin {
})
)
}
unload() {
this._unregisterPassportStrategy()
}
}
// ===================================================================