Search code examples
http-redirectauthenticationidentityserver4deep-linkingdeeplink

IdentityServer4 how to redirect the flow after login


I have installed an IdentityServer4 and a Client (Hybrid Mvc Client). All is ok. The following flow works:
1. User call secure page PageX (the controller is protected with Authorize attribute)
2. than system redirects the flow to Login page on IdentityServer
3. After authentication/authorization the IdentityServer redirect the user to url defined (redirect_uri) in the client configuration (page named Home) .

Now i don't know how to implement at the step 3 the redirection to PageX, the original page requested.

I have to create a custom AuthorizeAttribute to save on session storage the url of PageX and than using it in callback page? or is there any configuration on IdentityServer or client that could help me?

Thanks in advance


Solution

  • This is typically what you’d use the state parameter for. Your callback will receive the state value back unaltered and then you can verify the URL within is local and redirect to it automatically.

    I’d recommend protecting the value from tampering using the DataProtection features in .net.