You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Use Redirect URL Returned by handleLogout in BaseAuthProvider #1791
Currently, all AdminJS authentication adapters (@adminjs/express, @adminjs/fastify, @adminjs/nestjs) handle logout by destroying the local session and redirecting to the login URL, for example:
This works for simple local authentication but does not support OAuth/OIDC logout flows, such as with:
Keycloak
Auth0
Azure AD
Google Workspace
In these cases, AdminJS only clears the local session but never calls the provider’s logout endpoint — so the user remains authenticated at the provider level. When they revisit the login page, they are automatically re-logged in (silent login).
Why This Matters
Each OAuth provider has its own logout URL (e.g., Keycloak’s protocol/openid-connect/logout), and these need to be called explicitly.
Because AdminJS plugins manage logout internally and redirect immediately, there’s no clean way to integrate provider-specific logout behavior.
Suggested Solution
When the configured BaseAuthProvider implements handleLogout, and that function returns a redirect URL, the adapters should redirect to that URL instead of hardcoding the login redirect. This is help
// Current behaviorrouter.get('/logout',async(req,res)=>{awaitprovider.handleLogout(req,res);req.session.destroy(()=>res.redirect(admin.options.rootPath+'/login'));});
// Proposed behaviorrouter.get('/logout',async(req,res)=>{constredirectUrl=awaitprovider.handleLogout?.(req,res);// Always destroy the sessionif(req.session){awaitnewPromise(resolve=>req.session.destroy(resolve));}// If handleLogout returned a URL, redirect thereif(redirectUrl){returnres.redirect(redirectUrl);}// Otherwise, fallback to AdminJS login pathreturnres.redirect(admin.options.rootPath+'/login');});
Benefits
Proper OAuth logout support: enables redirecting to provider logout endpoints.
Backward compatible: existing providers continue to work if handleLogout returns undefined.
Minimal change: no breaking API changes or new interfaces.
In the handleLogout of my Firebase Provider I revoke the tokens from the current user and then the AdminJs destroys the session and redirect to login afterwards.
Activity
leonakao commentedon Oct 30, 2025
I'm using Firebase Authentication as provider.
In the
handleLogoutof my Firebase Provider I revoke the tokens from the current user and then the AdminJs destroys the session and redirect to login afterwards.You can save under the
_authproperty any identifier of your user in the provider.gugupy commentedon Oct 31, 2025
@leonakao I think, this only revoke the token but not the user session in the provider(Keycloak)?
Let me give it a try.