Added owin.RequestUser

This commit is contained in:
Kristian Hellang 2015-08-20 00:10:40 +02:00
parent 68eb9646ea
commit 138bc6a20f
3 changed files with 15 additions and 4 deletions

View File

@ -20,11 +20,12 @@ namespace Microsoft.AspNet.Owin
#endregion
#region OWIN v1.1.0 - 3.2.1 Request Data
#region OWIN v1.0.1 - 3.2.1 Request Data
// OWIN 1.1.0 http://owin.org/html/owin.html
// OWIN 1.0.1 http://owin.org/html/owin.html
public const string RequestId = "owin.RequestId";
public const string RequestUser = "owin.RequestUser";
#endregion

View File

@ -9,6 +9,7 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.WebSockets;
using System.Security.Claims;
using System.Security.Cryptography.X509Certificates;
using System.Security.Principal;
using System.Threading;
@ -57,6 +58,7 @@ namespace Microsoft.AspNet.Owin
(feature, value) => feature.QueryString = Utilities.AddQuestionMark(Convert.ToString(value))) },
{ OwinConstants.RequestHeaders, new FeatureMap<IHttpRequestFeature>(feature => feature.Headers, (feature, value) => feature.Headers = (IDictionary<string, string[]>)value) },
{ OwinConstants.RequestBody, new FeatureMap<IHttpRequestFeature>(feature => feature.Body, () => Stream.Null, (feature, value) => feature.Body = (Stream)value) },
{ OwinConstants.RequestUser, new FeatureMap<IHttpAuthenticationFeature>(feature => feature.User, () => null, (feature, value) => feature.User = (ClaimsPrincipal)value) },
{ OwinConstants.ResponseStatusCode, new FeatureMap<IHttpResponseFeature>(feature => feature.StatusCode, () => 200, (feature, value) => feature.StatusCode = Convert.ToInt32(value)) },
{ OwinConstants.ResponseReasonPhrase, new FeatureMap<IHttpResponseFeature>(feature => feature.ReasonPhrase, (feature, value) => feature.ReasonPhrase = Convert.ToString(value)) },

View File

@ -263,8 +263,16 @@ namespace Microsoft.AspNet.Owin
ClaimsPrincipal IHttpAuthenticationFeature.User
{
get { return Utilities.MakeClaimsPrincipal(Prop<IPrincipal>(OwinConstants.Security.User)); }
set { Prop(OwinConstants.Security.User, value); }
get
{
return Prop<ClaimsPrincipal>(OwinConstants.RequestUser)
?? Utilities.MakeClaimsPrincipal(Prop<IPrincipal>(OwinConstants.Security.User));
}
set
{
Prop(OwinConstants.RequestUser, value);
Prop(OwinConstants.Security.User, value);
}
}
IAuthenticationHandler IHttpAuthenticationFeature.Handler { get; set; }