How to exit the Azure app?

I created an Azure AD application and a web application. Azure AD application uses AAD Authentication. It works well. When I go to my url and I'm not authenticated, I have to enter my credentials. When I enter my credentials, I am redirected to my application.

But then the problem arises. How to log out. I found this question , and I wanted to implement option 2: do not exit using code, but use Azure AD links. The thing is, I don’t know where to set it up. He claims that

Add some specific login and logout links

But where? Where in Azure and on which portal (new or old) can I configure this? He also provided a link with a sample, but I do not understand this sample (I’m kind of new to Azure).

+4
source share
3 answers

What you can do is create a drop-down code URI in your application, and when a user clicks on a link or button Logout, you redirect your users to that URI.

Dropdown URI format:

https://login.microsoftonline.com/{0}/oauth2/logout?post_logout_redirect_uri={1}

Where {0}is the tenant ID or AD Azure name ( something.onmicrosoft.com) and {1}is the link to your application where the user will be redirected after the completion of the checkout process at the end of Azure AD.

+4
source

- , , : WEBSITE_AUTH_LOGOUT_PATH , /.auth/logout .

+4

URI

https://login.microsoftonline.com/{0}/oauth2/logout?post_logout_redirect_uri={1}

. cookie . , cookie :

foreach (string cookie in HttpContext.Current.Request.Cookies.AllKeys) { HttpContext.Current.Response.Cookies[cookie].Expires=DateTime.Now.AddDays(-1);}

But there is also one problem with the fact that Azure AD caches cookies for a certain period of time, so any request sent using the same cookie from any other source can be successfully authenticated by Azure AD. I'm still trying to figure out how to handle this.

Hope this helps. Thanks

+1
source

Source: https://habr.com/ru/post/1653982/


All Articles