AJAX "cancel page lock upon logout" mechanism and SAML redirects

I’m having difficulties integrating XWiki into my Keycloak based SSO setup.
Everything works perfectly fine until one tries to log out while editing a page.
I can’t get the AJAX based page lock mechanism to play well with SAML POST based redirection.
The synchronous AJAX GET xwiki/bin/cancel/ seem to be fired as soon as the browser receives a response from the logout action, except for 302 redirects.
This causes the AJAX request to fire already when the client(XWiki) responds with the SAML logout redirect,
since these are passed as a 200 OK html/text with a Form submitted onLoad() instead of regular 302 redirects.
The lock request is in other words fired before the Identity provider (keycloak) has fully completed the logout flow.
This seems to cancel the ongoing logout flow and starts a new login that redirects to XWiki/bin/cancel/Main, which results in a blank page.

How is the “cancel lock upon logout” mechanism supposed to work? It seems to return 401 Unauthorized when I tried it on http://playground.xwiki.org.

I’ve tried the same with keycloak and openID Connect instead of SAML, which results in a successful logout and redirect although the lock cancel returns 401 Unauthorized. However, I’m forced to get this working with SAML.

Thanks in advance.