(This question can be seen as follow ups to these two StackOverflow posts about OpenAuth with DotNetOpenAuth in a ServiceStack scenario: first and second)
From what I understand, ServiceStack uses an IAuthSession
to know which user is authenticated, but this seems to rely on the HTTP session cookie. With OAuth request, no such cookie exist.
Question: I want my ServiceStack requests to be considered authenticated if 1) a the browser cookie is present or 2) if the OAuth Authentication Header Bearer is present. How should I do this?
I tried the following to set the thread's authentication, but it relies on ASP.NET's HttpContext.Current.User
.
I'd also like it to work on both IIS hosted and Self-Hosted scenarios...
var analyzer = new StandardAccessTokenAnalyzer((RSACryptoServiceProvider)signCert.PublicKey.Key, (RSACryptoServiceProvider)encryptCert.PrivateKey);
var resourceServer = new ResourceServer(analyzer);
var requestWrapper = new HttpRequestWrapper((HttpRequest)request.OriginalRequest);
var principal = resourceServer.GetPrincipal(requestWrapper, requiredScopes);
HttpContext.Current.User = principal;
Any help is appreciated.