I was trying to understand the flow of a backchannel logout from my web application, but I find the documentation confusing. I have a JEE application running in JBoss EAP, with a Java Servlet Filter Adapter (for some technical reasons, I can't use the EAP adapter). The documentation for logging out says:
You can log out of a web application in multiple ways. For Java EE servlet containers, you can call HttpServletRequest.logout(). For other browser applications, you can redirect the browser to http://auth-server/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri, which logs you out if you have an SSO session with your browser.
The documentation for the Admin URL configuration says:
For example the way backchannel logout works is: 1. User sends logout request from one application 2. The application sends logout request to Keycloak 3. The Keycloak server invalidates the user session 4. The Keycloak server then sends a backchannel request to application with an admin url that are associated with the session 5. When an application receives the logout request it invalidates the corresponding HTTP session
So from my understanding, either:
- calling HttpServletRequest.logout() is supposed to send a request to Keycloak
- a GET to
http://auth-server/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri
should somehow detect the clientId (from the redirect URI?) and send a request to the appropriate backchannel
Neither option seems to work for me. In neither case, do I get a callback from Keycloak to my adminUrl. Furthermore, I still see the same number of active sessions in my Keycloak Admin after calling Request.logout(). According to this SO post, it seems to work, but I'm not sure if I am missing a configuration or something of the sorts.
I've tried sending the GET to the logout endpoint with an access_token, but that doesn't make any difference either.
What am I misunderstanding from this documentation? How am I supposed to code the logout?