-
Notifications
You must be signed in to change notification settings - Fork 2
Single sign-off: back-channel support #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
To support back-channel logout, we can set a request filter matching the configured route for that purpose and invalidating the session identified by the request. The filter may look like this: public class BackChannelLogoutFilter extends GenericFilterBean {
private RequestMatcher requestMatcher;
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (requestMatcher.matches(request)) {
// 1. Get the token
// 2. Validate the token
// 3. Get the Session-ID claim
// 4. Invalidate the corresponding session
}
chain.doFilter(request, response);
}
public void setRequestMatcher(RequestMatcher logoutRequestMatcher) {
requestMatcher = logoutRequestMatcher;
}
} |
The token sent by the provider contains the Spring has a We can use this registry to get all the principal matching the final var sid = token.getClaimAsString("sid");
sessionRegistry.getAllPrincipals().stream().filter(principal -> {
if (principal instanceof OidcUser) {
final var user = (OidcUser) principal;
return sid.equals(user.getClaimAsString("sid"));
} else {
return false;
}
}).flatMap(p -> sessionRegistry.getAllSessions(p, false).stream()).forEach(SessionInformation::expireNow); This should trigger an authentication exception the next time those sessions are accessed, so we might want to add an exception handler for that to redirect the browser to the login route: http.exceptionHandling(exceptionHandling -> {
var entryPoint = new LoginUrlAuthenticationEntryPoint(loginRoute); // from configuration
exceptionHandling.authenticationEntryPoint(entryPoint);
}); |
Split of #24 to track back-channel logout support.
The text was updated successfully, but these errors were encountered: