【发布时间】:2022-07-28 00:03:24
【问题描述】:
我在我的 Angular 应用程序中使用 OIDC 客户端和 WSO2 API Manager 3.2.0 进行身份验证。在我退出之前一切正常。
首先,我从一个选项卡登录应用程序,然后在成功登录后复制该选项卡。 之后,当我从一个选项卡注销时,其他选项卡也应该注销,但不会发生。我创建了一个 iframe 并不断检查会话,如下所示。
.ts 文件:
baseUrl = new URL(window.location.href);
callbackURI = this.baseUrl.origin + '/slate/dashboard';
checkSessionURL = this.sanitizer.bypassSecurityTrustResourceUrl('https://localhost:9443/oidc/checksession' + '?client_id='
+ localStorage.getItem('client_id') + '&redirect_uri=' + this.callbackURI);
constructor(private sanitizer: DomSanitizer, private authService: AuthService) {
}
ngOnInit(): void {
}
ngAfterViewInit(): void {
if (this.authService.isLoggedUser()) {
this.checkSession();
}
}
isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
input !== null && input.tagName === 'IFRAME'
/**
* Invoke check session OIDC endpoint.
*/
checkSession(): void {
setInterval(() => {
const msg = localStorage.getItem('client_id') + ' ' + localStorage.getItem('sessionState');
const frame = document.getElementById('iframeOP');
if (this.isIFrame(frame) && frame.contentWindow) {
frame.contentWindow.postMessage(msg, 'https://localhost:9443/oidc/checksession');
}
}, 3000);
}
.HTML 文件:
<iframe
title='iframeOP'
id='iframeOP'
[src]="checkSessionURL"
></iframe>
刷新重复标签后,我得到了这个。
https://localhost:9443/authenticationendpoint/oauth2_error.do?oauthErrorCode=access_denied&oauthErrorMsg=Error+occurred+while+extracting+data+from+id+token。
但是,重复选项卡中的注销应该会自动发生。如果有人可以提供帮助,我将不胜感激。
【问题讨论】:
标签: angular wso2 openid-connect identityserver3 wso2-identity-server