【问题标题】:angular-auth-oidc-client logout not workingangular-auth-oidc-client 注销不起作用
【发布时间】:2021-01-22 03:30:25
【问题描述】:

我正在使用 angular-auth-oidc-client lib 以 keycloak 作为身份服务器来验证我的应用程序。我能够登录到应用程序,但是注销功能不起作用。我已阅读文档并使用相同的注销调用,但它似乎不起作用。请帮忙。提前致谢。

这是我的配置:

{
    "sts_server": "http://localhost/auth/realms/test",
    "redirect_url": "http://localhost:4200/app/",
    "client_id": "test_client",
    "response_type": "code",
    "scope": "openid profile email",
    "post_logout_redirect_uri": "http://localhost:4200/app/#/homepage/",
    "startup_route": "/homepage/welcome",
    "start_checksession": "true",
    "silent_renew": "true",
    "silent_renew_url": "assets",
    "max_id_token_iat_offset_allowed_in_seconds": "10",
    "logLevel": "info",
    "forbidden_route": "/unauthorized",
    "unauthorized_route": "/unauthorized"
}

我的注销方法:

  logOut() {
        this.oidcSecurityService.logoffLocal();
        this.oidcSecurityService.logoffAndRevokeTokens();
        this.oidcSecurityService.logoff();
// none of the three mentioned above work.
    
      }

【问题讨论】:

  • 您好@wazza,您找到解决方案了吗?如果是,请回答,我会投票,以便帖子可以尽快关闭。如果否,请提供更多详细信息。注销时会发生什么?您在控制台中遇到错误吗?控制台输出是什么,您是否看到相关的网络请求?顺便说一句 .logoff() 对于大多数情况来说应该足够了。
  • @GeofoxCoding 我还没有找到解决方案。我还在寻找。控制台上看不到任何错误。
  • 好的,首先添加一个调试日志级别,例如“logLevel:LogLevel.Debug”。然后只执行 .logoff() 并在您注销时查看您的网络流量。您应该看到一个对端点 /logout 的请求,其中包含 id_token_hint 和 post_logout_redirect_uri。重定向回您的应用程序。还要查看此请求的响应位置标头。

标签: angular keycloak openid-connect angular-auth-oidc-client


【解决方案1】:

在配置中添加注销 url

logoutUrl: 'https://${your url logout}/Logout',

在你的组件中使用

import { OAuthService } from 'angular-oauth2-oidc';
constructor(private oauthService: OAuthService,) {}
logOut() {
  this.oauthService.logOut();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-17
    • 2015-04-29
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    • 1970-01-01
    • 2019-11-15
    • 1970-01-01
    相关资源
    最近更新 更多