1

我正在使用 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.
    
      }
4

1 回答 1

0

将注销 url 添加到配置

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

在您的组件中使用

import { OAuthService } from 'angular-oauth2-oidc';
constructor(private oauthService: OAuthService,) {}
logOut() {
  this.oauthService.logOut();
}
于 2021-01-31T11:01:17.860 回答