I'm trying to move my standard WebApi app over to OWIN, but having a problem with identities and $batch requests.
I currently have a DelegatingHandler
that detects and assigns the identity in SendAsync
:
// Detect bearer token and build the identity above.
IOwinContext owinContext = request.GetOwinContext();
owinContext.Authentication.User = new ClaimsPrincipal(identity);
And for normal requests, this carries on through to the ODataController.User
. However on $batch
requests the property returns to an unauthenticated ClaimsIdentity
.
Even GetOwinContext
returns an IOwinContext
without any User. I assume it has created a new context for each batch part, but I cannot see any way of finding the original context.
Any help would be great!