简体   繁体   English

Azure Active Directory注销

[英]Azure Active directory Logout

I am using angular2 and for authentication and I am using azure active directory authentication. 我正在使用angular2和身份验证,我使用azure活动目录身份验证。

For Logout from azure active directory authentication I am using below code: 对于从azure活动目录身份验证注销我使用下面的代码:

    localStorage.removeItem('user');
    localStorage.removeItem('useremail');

    window.localStorage.removeItem("id_token");
    window.localStorage.removeItem("access_token"); 
    window.localStorage.clear();   
     let link = ['/login'];
    this._router.navigate(link);  

But it is not working. 但它没有用。 Everything I have tried. 我尝试过的一切。 It actually redirect to login page but when again I do login it automatically login without any credential. 它实际上重定向到登录页面但是当我再次登录时它会自动登录而不需要任何凭据。

When I clear history manually it goes to login in azure server. 当我手动清除历史记录时,它将进入Azure服务器登录。

Please help me. 请帮我。

By using this my problem is solved 通过使用这个我的问题解决了

window.location.href = " https://login.microsoftonline.com/ {0}/oauth2/logout?post_logout_redirect_uri=" + "{1}" window.location.href =“ https://login.microsoftonline.com/ {0} / oauth2 / logout?post_logout_redirect_uri =”+“{1}”

{0} is tendentid ie b8267886-f0c8-4160-ab6f-6e9343468fdc90 {0}是tendentid即b8267886-f0c8-4160-ab6f-6e9343468fdc90

{1} is redirect url after logout ie http://localhost:5477/#/login 注销后{1}是重定向URL,即http:// localhost:5477 /#/ login

Your original code snippet just clear your cache data saved in local storage, which didn't clean the server session on AAD IDP. 您的原始代码段只清除保存在本地存储中的缓存数据,这些数据不会清除AAD IDP上的服务器会话。 In ng2, please use following code snippet to logout form AAD: 在ng2中,请使用以下代码段注销表格AAD:

import {AdalService} from 'ng2-adal/core';
class whateverComponent{
    public logOut() {
        this.adalService.logOut();
    }
}

And we can direct to the source code to see what it will do when we call the function, AuthenticationContext.prototype.logOut 我们可以直接查看源代码,看看在调用函数AuthenticationContext.prototype.logOut时它会做什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM