feat(xo-server): passport strategies can be unregistered (#4702)
Now all authentication plugins can be unloaded.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
Reference in New Issue
Block a user