ServiceStack/ServiceStack — pull request #396 by Its-Tyson (2013-01-05 06:47:45+00:00)
Title: AuthService doesn't obey new session's ReferrerUrl for html requests

IAuthProvider.Authenticate implementations may change the current session [(e.g. CredentialsAuthProvider)](https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.ServiceInterface/Auth/CredentialsAuthProvider.cs#L84-L88).

However after this call [AuthService then uses the old session instance and accessed the old ReferrerUrl property](https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.ServiceInterface/Auth/AuthService.cs#L154).

This fix addresses the issue by passing the session instance by reference into the Authenticate method. While I like this as it makes the fact that the session instance may change explicit as part of the method signature, I understand it will be a breaking change to IAuthProviders implementations and you may not want to pull it. In that case a simple workaround is for the [AuthService to just get the current session again after the Authenticate call](https://github.com/Its-Tyson/ServiceStack/blob/html-auth-session-referrer-workaround/src/ServiceStack.ServiceInterface/Auth/AuthService.cs#L153-L154). I have [a branch for the workaround approach here](https://github.com/Its-Tyson/ServiceStack/tree/html-auth-session-referrer-workaround), let me know if you want me to submit a pull request for that instead.

It also contains a unit test, but as the ReferrerUrl is only sent during html requests I had to add a HtmlServiceClient, which involved some minor additions/changes to the base ServiceClientBase class. Also I haven't fully implemented the HtmlClient class, only the parts I needed for the test (.e.g. The response DTO is not deserialized from the html content, a default DTO is constructed and returned).