diff --git a/src/Microsoft.AspNet.Http/HttpRequest.cs b/src/Microsoft.AspNet.Http/HttpRequest.cs
index a59ae78ab6..9a09b01a65 100644
--- a/src/Microsoft.AspNet.Http/HttpRequest.cs
+++ b/src/Microsoft.AspNet.Http/HttpRequest.cs
@@ -120,12 +120,5 @@ namespace Microsoft.AspNet.Http
///
/// The owin.RequestBody Stream.
public abstract Stream Body { get; set; }
-
- ///
- /// Gets or sets the cancellation token for the request.
- ///
- /// The cancellation token for the request.
- public abstract CancellationToken CallCanceled { get; set; }
-
}
}
diff --git a/src/Microsoft.AspNet.Owin/OwinEnvironment.cs b/src/Microsoft.AspNet.Owin/OwinEnvironment.cs
index c624e1a8c0..38cb35443c 100644
--- a/src/Microsoft.AspNet.Owin/OwinEnvironment.cs
+++ b/src/Microsoft.AspNet.Owin/OwinEnvironment.cs
@@ -8,11 +8,14 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
+using System.Security.Claims;
using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.HttpFeature;
+using Microsoft.AspNet.HttpFeature.Security;
namespace Microsoft.AspNet.Owin
{
@@ -28,12 +31,14 @@ namespace Microsoft.AspNet.Owin
_context = context;
_entries = new Dictionary()
{
+ { OwinConstants.CallCancelled, new FeatureMap(feature => feature.OnRequestAborted) },
{ OwinConstants.RequestProtocol, new FeatureMap(feature => feature.Protocol, (feature, value) => feature.Protocol = Convert.ToString(value)) },
{ OwinConstants.RequestScheme, new FeatureMap(feature => feature.Scheme, (feature, value) => feature.Scheme = Convert.ToString(value)) },
{ OwinConstants.RequestMethod, new FeatureMap(feature => feature.Method, (feature, value) => feature.Method = Convert.ToString(value)) },
{ OwinConstants.RequestPathBase, new FeatureMap(feature => feature.PathBase, (feature, value) => feature.PathBase = Convert.ToString(value)) },
{ OwinConstants.RequestPath, new FeatureMap(feature => feature.Path, (feature, value) => feature.Path = Convert.ToString(value)) },
- { OwinConstants.RequestQueryString, new FeatureMap(feature => feature.QueryString, (feature, value) => feature.QueryString = Convert.ToString(value)) },
+ { OwinConstants.RequestQueryString, new FeatureMap(feature => RemoveQuestionMark(feature.QueryString),
+ (feature, value) => feature.QueryString = AddQuestionMark(Convert.ToString(value))) },
{ OwinConstants.RequestHeaders, new FeatureMap(feature => feature.Headers, (feature, value) => feature.Headers = (IDictionary)value) },
{ OwinConstants.RequestBody, new FeatureMap(feature => feature.Body, (feature, value) => feature.Body = (Stream)value) },
@@ -56,6 +61,8 @@ namespace Microsoft.AspNet.Owin
{ OwinConstants.CommonKeys.IsLocal, new FeatureMap(feature => feature.IsLocal, (feature, value) => feature.IsLocal = Convert.ToBoolean(value)) },
{ OwinConstants.SendFiles.SendAsync, new FeatureMap(feature => new SendFileFunc(feature.SendFileAsync)) },
+
+ { OwinConstants.Security.User, new FeatureMap(feature => feature.User, (feature, value) => feature.User = MakeClaimsPrincipal((IPrincipal)value)) },
};
if (context.Request.IsSecure)
@@ -222,6 +229,36 @@ namespace Microsoft.AspNet.Owin
throw new NotImplementedException();
}
+ private string RemoveQuestionMark(string queryString)
+ {
+ if (!string.IsNullOrEmpty(queryString))
+ {
+ if (queryString[0] == '?')
+ {
+ return queryString.Substring(1);
+ }
+ }
+ return queryString;
+ }
+
+ private string AddQuestionMark(string queryString)
+ {
+ if (!string.IsNullOrEmpty(queryString))
+ {
+ return '?' + queryString;
+ }
+ return queryString;
+ }
+
+ private ClaimsPrincipal MakeClaimsPrincipal(IPrincipal principal)
+ {
+ if (principal is ClaimsPrincipal)
+ {
+ return principal as ClaimsPrincipal;
+ }
+ return new ClaimsPrincipal(principal);
+ }
+
public class FeatureMap
{
public FeatureMap(Type featureInterface, Func