英文:
Keycloak - Redirect to "Confirm Logout" page when logging out after a page refresh
问题
抱歉,你的要求是只返回翻译好的部分,不要有别的内容。以下是你要求的内容的翻译:
"I'm currently using keycloak on a project and everything is working fine. With one exception...
If I login, I am redirected to my project's page and if I then logout, everything works flawlessly.
But if for some reason I refresh the page after logging in, when I then logout, I am redirected to a 'Confirm logout' page.
How can I disable this page / prevent it from appearing?
These are the keycloak configurations I have atm:
await keycloak.init({
config: environment.keycloakConfig,
loadUserProfileAtStartUp: true,
initOptions: {
onLoad: 'check-sso',
checkLoginIframe: false,
silentCheckSsoRedirectUri: window.location.origin + '/assets/keycloak/silent-check-sso.html',
enableLogging: true
}
});
I believe there was an option in previous versions of keycloak-js/keycloak-angular to disable this page on the logout() action but there seems to be none with the most recent versions."
英文:
I'm currently using keycloak on a project and everything is working fine. With one exception...
If I login, I am redirected to my project's page and if I then logout, everything works flawlessly.
But if for some reason I refresh the page after logging in, when I then logout, I am redirected to a "Confirm logout" page.
How can I disable this page / prevent it from appearing?
These are the keycloak configurations I have atm:
await keycloak.init({
config: environment.keycloakConfig,
loadUserProfileAtStartUp: true,
initOptions: {
onLoad: 'check-sso',
checkLoginIframe: false,
silentCheckSsoRedirectUri: window.location.origin + '/assets/keycloak/silent-check-sso.html',
enableLogging: true
}
});
I believe there was an option in previous versions of keycloak-js/keycloak-angular to disable this page on the logout() action but there seems to be none with the most recent versions.
答案1
得分: 1
After a few hours trying to fix this problem and endless searching, I found out that the problem was that I followed a "tutorial" which said I should do the following on logout:
在尝试修复这个问题并进行无休止的搜索几个小时后,我发现问题出在我按照一个“教程”上的建议在注销时执行以下操作:
await this.keycloakService.logout(logoutUrl).then(() => {
this.keycloakService.clearToken(); // the problem is with this line!!
});
在注销时,Keycloak 需要令牌来正确注销,如果令牌不存在,您将被重定向到“确认注销”页面。因此,如果在那里清除令牌,它将总是重定向到该页面。
修复方法:
只需删除 this.keycloakService.clearToken();
这一行,问题就解决了。
英文:
After a few hours trying to fix this problem and endless searching, I found out that the problem was that I followed a "tutorial" which said I should do the following on logout:
await this.keycloakService.logout(logoutUrl).then(() => {
this.keycloakService.clearToken(); // the problem is with this line!!
});
On logout, keycloak needs the token to properly logout and if it is not present, you are redirected to the "Confirm logout" page. So, if you clear the token there, it will always redirect to that page.
FIX:
Just remove this.keycloakService.clearToken();
line and you are good to go.
答案2
得分: 1
请检查此链接,我尝试解释这种行为的原因:
https://github.com/keycloak/keycloak/discussions/12114#discussioncomment-6927266
英文:
Check this link, I tried to explain the reasons of this behaviour
https://github.com/keycloak/keycloak/discussions/12114#discussioncomment-6927266
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论