问题
When I go to authorize controller(implemented in Identity Server 4):
(*) abc.com/authorize?par1=val1&par2=val2
I am being redirected to:
(**) abc.com/login?ReturnUrl=abc.com/abc.com%2Fauthorize%3Fpar1%3Dval1%26par2%3Dval2"
One can notice that ReturnUrl equals the (*) but just being html encoded.
I would like to add par2 value as a second parameter to the (**) url example:
abc.com/login?ReturnUrl=abc.com/abc.com%2Fauthorize%3Fpar1%3Dval1%26par2%3Dval2&par2=val2"
How to configure IdentityServer to achieve that?
回答1:
IdentityServer is a certified OpenId Connect protocol implementation, and it handles your (*) request as a standard Authorization request, which has predefined structure.
The only two parameters with no limitation by the spec are the state which is used by clients and should be sent back with response as it is, and acr_values which is specially aimed for sending additional parameters to the server.
You can involve acr_values for your purposes the following way: &acr_values=par2:val2 and then in BuildLoginViewModelAsync(string returnUrl) method of the AccountController you can access them as context?.AcrValues. You can extend LoginViewModel to bring the value to the layout.
来源:https://stackoverflow.com/questions/57856268/make-identity-server-4-pass-a-query-parameter-to-the-login-controller