【问题标题】:Active Directory logging out without a redirect to Default Microsoft Logout Page in Angular 2Active Directory 注销而不重定向到 Angular 2 中的默认 Microsoft 注销页面
【发布时间】:2018-03-09 09:19:42
【问题描述】:

我已经实现了 Angular 2 多租户应用程序。 我可以通过使用注销活动目录 下面的方法

    logout() {
    this.context.logOut();
    }

但是现在我必须在不去微软注销页面的情况下实现注销活动目录用户。Active Directory 用户注销而不去注销页面,如下图所示。

用户注销不像上图。我不想使用内置的注销功能。我尝试了以下两种不同的方法

           this.context.clearCacheForResource(this.userInfo.userName);
           this.context.clearCache();

但用户信息不清楚。 当我清除浏览器的缓存时它正在工作。

感谢任何答案。

在此先感谢........!

【问题讨论】:

    标签: javascript azure-active-directory adal active-directory-group adal.js


    【解决方案1】:

    我刚遇到同样的问题,我花了一些时间在MSAL.js documentation 中找到answer

    export class AuthenticationService {
      constructor(
        private msalService: MsalService,
      ) { }
    
      logoutWithoutRedirect(): void {
        this.msalService.logoutRedirect({
          // Return false if you would like to stop navigation after local logout
          onRedirectNavigate: () => false
        })
      }
    }
    

    【讨论】:

      【解决方案2】:

      我已经通过使用下面的代码解决了这个问题

      import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
      
      @Component({
      
      
      selector: 'auth-container',
      

      模板:<iframe class="embed-responsive-item" *ngIf="show" width="0" height="0" [src]="url" allowfullscreen></iframe>,})

      export class Auth implements OnInit {
      
      public show = false;
      
      constructor(private sanitizer: DomSanitizer) {
      this.url = sanitizer.bypassSecurityTrustResourceUrl('https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=' + window.location.origin);  }}
      

      这里我根据要求隐藏和显示 iframe

      谢谢@南

      【讨论】:

        【解决方案3】:

        您的方法仅清除本地缓存/存储,它不会清除 azure 广告上的任何会话/cookie 保留,由于 cookie 仍然存在,可能会发生静默身份验证。如果您想清除它,那么内置注销应该是使用的。

        这是一个similar thread,它提供了实现静默注销的解决方法:

        您可以尝试实现静默注销(可能使用 iframe,这将阻止 ux 显示),然后调用 clearCache 清除本地存储/会话存储

        【讨论】:

        • 嗨,南,你能简单解释一下使用 iframe 进行静默注销吗?(在任何文章中为我提供示例)。谢谢
        • code sample在anjular 2中使用iframe
        • 我尝试使用 iframe 但无法正常工作 <iframe class="embed-responsive-item" *ngIf="false" width="300" height="100" [src]="'https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=http://192.168.2.50:8080' | safe" allowfullscreen></iframe> 类似 不支持评估引用的错误!。我想知道我正在执行的过程是否正确或不是。谢谢
        • 在分配模板绑定时尝试删除单引号。
        猜你喜欢
        • 2021-06-15
        • 1970-01-01
        • 2014-10-31
        • 1970-01-01
        • 2019-02-23
        • 2014-07-23
        • 1970-01-01
        • 1970-01-01
        • 2015-04-03
        相关资源
        最近更新 更多