How do I disable users of my web app from navigating back to the Azure portal after redirect from login?

Smith, Noah 0 Reputation points
2024-05-23T20:35:44.01+00:00

I have a web app where we are using Azure Entra as the source of user identity. So the user is directed to SSO with Microsoft, where we keep their identity, on the way to starting a session in our app. Because of the way the routing is happening, they can click the "back" button at the top of their browser when they successfully login and get to our home screen, and it takes them back to the Azure portal.

From here, they cannot do anything too destructive as they do not have the permissions, but we don't want to have to deal with them poking around in there and then asking us questions about the Azure environment. Is there some way we can configure the redirect to our home page to "replace" in their browser history, so that they cannot navigate to the portal by pressing back once they log in?

By the time they get to our app, there is nothing we can do, it is just a navigation to our URL from Azure, so we cannot disable it from our end. Please let me know what a possible solution is for us here.

Thank you.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,171 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Akhilesh 6,740 Reputation points Microsoft Vendor
    2024-05-27T12:21:08.83+00:00

    Hi @Smith, Noah

    Thank you for post!

    The behavior of the back button is a feature of the web browser and is not directly controllable by a web application or a cloud service like Azure.

    You can use JavaScript to disable the back button or redirect the user to a different page when they click the back button.

    Use the replaceState method of the history object in JavaScript to replace the current history entry with a new one, effectively removing the Azure portal from the user's history.

    Reference: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
    https://medium.com/cnk-tech/controlling-and-directing-browsers-back-button-with-javascript-eaa798acdeb5
    https://learn.microsoft.com/en-us/entra/identity-platform/reply-url

    Hope this helps. Do let us know if you any further queries.

    Thanks,

    Akhilesh.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.