2

I am trying to use ServiceStack with IdentityServer4 to do the user logon authentication. However, I need to pass back some parameters to the URL after redirecting from the logon.

e.g. When the following API that requires user authentication is called. I want that var=123 passed back after the logon (in the state parameter or in any other way).

http://myserver/myapi/mydto/abc?var=123

I find the following links stating that the redirect_uri must be exact matching without any parameter. To passing back the parameters back to the redirect_uri after logon, it should use the state parameter

https://github.com/IdentityServer/IdentityServer3/issues/1371

google oauth2 redirect_uri with several parameters

I am using the ServiceStack Authenticate attribute, I am not sure where I should populate that state parameter during the ServiceStack Authenticate pipeline.

When this API is called,

http://myserver/myapi/mydto/abc?var=123

The ServiceStack.AuthenticateAttribute.DoHtmlRedirectIfConfigured will redirect to this urL:

http://myserver/myapi/auth/IdentityServer?redirect=http%3a%2f%2fmyserver%2fmyapi%2fmydto%2fabc%3fvar%3d123

This URL has only the redirect parameter and no state parameter is set. As a result, when the Authenticate DTO is generated, its State field is empty.

I see the ServiceStackHost has the OnPreExecuteServiceFilter.

public virtual object OnPreExecuteServiceFilter(IService service, object request, 
IRequest httpReq, IResponse httpRes);

Should I implement that OnPreExecuteServiceFilter and populate the state field in the request DTO with the parameters in the httpReq?

Any other suggestions are welcome.

Thanks in advance,

kklo
  • 661
  • 1
  • 8
  • 14

0 Answers0