ambassador + keyclock logout redirect URL
See original GitHub issuePlease describe your use case / problem. A clear and concise description of your use case / problem. The “why” is really valuable to us. For example, “I have a set of services whose clients have long-lived connections.” Hi people, I’m trying redirect URL when I log out in my system. but I read the documentation and not exist de parameter of URL redirect. this documentation than I read https://www.getambassador.io/docs/latest/topics/using/filters/oauth2/#rp-initiated-logout I’m using keyclock of SSO
Describe the solution you’d like A clear and concise description of what you want to happen. in documentation tell to set the ‘realm’. I wanted (need) to set URL after redirect for example
function logout(realm) {
var form = document.createElement('form');
form.method = 'post';
form.action = '/.ambassador/oauth2/logout?realm='+realm;
//form.target = '_blank'; // uncomment to open the identity provider's page in a new tab
var xsrfInput = document.createElement('input');
xsrfInput.type = 'hidden';
xsrfInput.name = '_xsrf';
xsrfInput.value = getCookie("ambassador_xsrf."+realm);
var urlredirect = document.createElement('input');
urlredirect.type = 'hidden';
urlredirect.name = urlRedirect';
urlredirect.value = 'https://website.com.br';
form.appendChild(xsrfInput);
document.body.appendChild(form);
form.submit();
}
and after executing the code call this URL http://auth-server/auth/realms/{realm}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri
this is documentation to redirect in keyclock https://www.keycloak.org/docs/latest/securing_apps/index.html#logout
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top GitHub Comments
Hello, I found a solution for that, is not the best solution but you will can logout using a button.
async function logout() { const data = new URLSearchParams("realm=keycloak-oauth2-filter.ambassador") data.append('_xsrf', getCookie("ambassador_xsrf.keycloak-oauth2-filter.ambassador")); fetch('/.ambassador/oauth2/logout', { method: 'POST', body: data }) .then(function (response) { if (response.ok) { return response.text() } else { throw "Err"; } }) .then(function (text) { console.log(text); }) .catch(function (err) { console.log(err); }); }
Post Logout Redirect URI support for Oauth2 Filter was released with v3.2. Please see release notes here for details .