Is there any way how can I set RedirectUri property for OpenIdConnectMessage based on a Request scope, not Application scope?
My app is serving multiple domains (myapp.com, myapp.fr, ..) and based on domain, it determine default language for the content. I need that the user is taken back to the same domain after login thru IdP so I need to find a way how RedirectUri is set per request scope rather than app scope as done by configuring middleware options in startup.cs .
If you're using ResponseType = OpenIdConnectResponseType.CodeIdToken
, it's necessary to set RedirectUri
in several notification events.
In the AuthorizationCodeReceived
notification, you can set the RedirectUri
on TokenEndpointRequest
to ensure the same value is also passed in the token request.
RedirectToIdentityProvider = n =>
{
n.ProtocolMessage.RedirectUri = redirectUrl;
// other settings
}
AuthorizationCodeReceived = n =>
{
n.TokenEndpointRequest.RedirectUri = redirectUrl;
// other settings
}
I know this is an old post and the answer is already mentioned. But it still took me a while to figure out how to set the dynamic RedirectUri.
I was assigning RedirectUri in OpenIdConnectAuthenticationOptions and RedirectToIdentityProvider, which was causing issues.
We should assign RedirectUri only in RedirectToIdentityProvider event.
For someone who needs help, you can check my code here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With