Since no one seems to know a straight forward way to do it, I am now trying workarounds...
What I've come up with so far is modifying the login.ftl of the login theme.
- open the link in a popup
- check for the popup being closed
When the popup is closed (the login at the external IDP was successful) the parent is either refreshed or redirected (depending on keycloak being opened via iframe or via browser redirect).
So originaly the code looked like this:
<a href="${p.loginUrl}" id="zocial-${p.alias}" class="zocial ${p.providerId}">
Now it looks like this:
<a id="zocial-${p.alias}" class="zocial ${p.providerId}" onclick="
let win = window.open('${p.loginUrl}', '${name}', 'toolbar=no,width=600,height=600')
let timer = setInterval(function() {
if (win.closed) {
clearInterval(timer);
if (win.parent == win.self) {
window.history.back();
} else {
window.parent.location.reload();
}
}
}, 1000);
">
Now that works quite alright.
Except that the popup does not get closed automatically.
And I just seem to can't find a way to do it automatically.
When the login via social provider is successful keycloak redirects directly to its client.
So there is no freemarker template loaded that I could manipulate to close the popup.
Also no SPI seems to be available for the /auth/realms/<myrealm>/broker/<mybroker>/endpoint endpoint.
And an event listener (who could actually detect the successful IDP login) seemingly has no communication chanel to the frontend...
Does anyone have any idea how I could solve this?