Logout to a external service

Hi,
I need to customize logout for xwiki.
We have a keycloak server to manage authorization and I logout from xwiki I should call a specific URL like
http://login.mydomain.com/auth/realms/myrealm/protocol/openid-connect/logout

Xwiki file drawer.vm has a specific line to logout:

<a href="$xwiki.getURL(‘XWiki.XWikiLogout’, ‘logout’, “xredirect=$escapetool.url($xwiki.relativeRequestURL)”)" id=“tmLogout”>$services.icon.renderHTML(‘log-out’) $escapetool.xml($services.localization.render(‘logout’))

It’s not clear to me how to customize it using variables shown above - if it’s possible (in xwiki.cfg/properties there’s no reference to them).

Do you have something to suggest, please?

Thank you in advance.
Nicola

What you could is create a page that does what you have to do, and modify drawer.vm with a xredirect to that page, passing the original xredirect into another request parameter and have your custom page handle the redirect.

If you have a custom authenticator it’s going to be called during logout too so you could send back a redirect when that happen which go to your service and ideally have this service go back to XWiki when it’s done.

Is there a way to call the method to logout directly from a vm file?
My idea is to write a workaround.vm in which I logout from wiki and I redirect to my login page (keycloak).
Sorry for my question, but I don’t know velocity.

Thank you
Nicola

Did you find a solution @nicoben? I would be really interested.

As a workaround, it would be nice to modify the “xredirect” linkt mentioned in:

https://example.de/bin/logout/XWiki/XWikiLogout?xredirect=http://login.mydomain.com/auth/realms/myrealm/protocol/openid-connect/logout

Would this be somehow possible?

to look like this:

https://example.de/bin/logout/XWiki/XWikiLogout?xredirect=%2Fbin%2Fview%2FMain%2F%3Foidc.skipped%3Dtrue