You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When user signs in BarViz, they get routed back to the / address. This is because the allowed redirectUri is configured in the Entra app and cannot be dynamic.
To make this work, we will probably store the original URI in the state: https://learn.microsoft.com/en-us/entra/identity-platform/reply-url#use-a-state-parameter and then read it after the return and redirect there.
Goal
Store the current URI in the state field before redirecting to the login page
Read the state after the user comes back signed in
Redirect the user to the original URI
Notes
Copilot says something like this:
Save the original URL: When a user tries to access a protected resource and gets redirected to the Microsoft login page, save the original URL they were trying to access. You can do this in a middleware or in the OnRedirectToIdentityProvider event.
options.Events=newOpenIdConnectEvents{OnRedirectToIdentityProvider= context =>{varoriginalUrl=context.Request.Path+context.Request.QueryString;context.ProtocolMessage.State= ...// Encode the original URL in the state parameterreturn Task.CompletedTask;}};
Retrieve the state parameter: After the user signs in, the Microsoft identity platform will redirect them back to your specified redirect URI with the state parameter. You will need to decode this state parameter to redirect the user back to the original URL.
options.Events=newOpenIdConnectEvents{OnMessageReceived= context =>{
...// Decode the state parameter to get the original URLreturn Task.CompletedTask;}};
Redirect the user back: Once you have retrieved the original URL from the state parameter, you can redirect the user back to that URL.
options.Events=newOpenIdConnectEvents{OnTicketReceived= context =>{varoriginalUrl= ...// Retrieve the original URL from the context or sessioncontext.Properties.RedirectUri=originalUrl;returnTask.CompletedTask;}};
The text was updated successfully, but these errors were encountered:
Context
When user signs in BarViz, they get routed back to the
/
address. This is because the allowedredirectUri
is configured in the Entra app and cannot be dynamic.To make this work, we will probably store the original URI in the state: https://learn.microsoft.com/en-us/entra/identity-platform/reply-url#use-a-state-parameter and then read it after the return and redirect there.
Goal
Notes
Copilot says something like this:
Save the original URL: When a user tries to access a protected resource and gets redirected to the Microsoft login page, save the original URL they were trying to access. You can do this in a middleware or in the OnRedirectToIdentityProvider event.
Retrieve the state parameter: After the user signs in, the Microsoft identity platform will redirect them back to your specified redirect URI with the state parameter. You will need to decode this state parameter to redirect the user back to the original URL.
Redirect the user back: Once you have retrieved the original URL from the state parameter, you can redirect the user back to that URL.
The text was updated successfully, but these errors were encountered: