diff --git a/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationDescription.cs b/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationDescription.cs
index 81653dd1..97ca3fe1 100644
--- a/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationDescription.cs
+++ b/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationDescription.cs
@@ -20,23 +20,23 @@ public class AuthenticationDescription
/// Initializes a new instance of the class
///
public AuthenticationDescription()
+ : this(items: null)
{
- Dictionary = new Dictionary(StringComparer.Ordinal);
}
///
/// Initializes a new instance of the class
///
- ///
- public AuthenticationDescription([NotNull] IDictionary properties)
+ ///
+ public AuthenticationDescription(IDictionary items)
{
- Dictionary = properties;
+ Items = items ?? new Dictionary(StringComparer.Ordinal); ;
}
///
/// Contains metadata about the authentication provider.
///
- public IDictionary Dictionary { get; private set; }
+ public IDictionary Items { get; private set; }
///
/// Gets or sets the name used to reference the authentication middleware instance.
@@ -44,7 +44,7 @@ public AuthenticationDescription([NotNull] IDictionary propertie
public string AuthenticationScheme
{
get { return GetString(AuthenticationSchemePropertyKey); }
- set { Dictionary[AuthenticationSchemePropertyKey] = value; }
+ set { Items[AuthenticationSchemePropertyKey] = value; }
}
///
@@ -53,13 +53,13 @@ public string AuthenticationScheme
public string Caption
{
get { return GetString(CaptionPropertyKey); }
- set { Dictionary[CaptionPropertyKey] = value; }
+ set { Items[CaptionPropertyKey] = value; }
}
private string GetString(string name)
{
object value;
- if (Dictionary.TryGetValue(name, out value))
+ if (Items.TryGetValue(name, out value))
{
return Convert.ToString(value, CultureInfo.InvariantCulture);
}
diff --git a/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationManager.cs b/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationManager.cs
new file mode 100644
index 00000000..f7b4342b
--- /dev/null
+++ b/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationManager.cs
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+using System.Security.Claims;
+using System.Threading.Tasks;
+
+namespace Microsoft.AspNet.Http.Authentication
+{
+ public abstract class AuthenticationManager
+ {
+ public abstract IEnumerable GetAuthenticationSchemes();
+
+ public abstract AuthenticationResult Authenticate(string authenticationScheme);
+
+ public abstract Task AuthenticateAsync(string authenticationScheme);
+
+ public virtual void Challenge()
+ {
+ Challenge(authenticationScheme: null, properties: null);
+ }
+
+ public virtual void Challenge(AuthenticationProperties properties)
+ {
+ Challenge(authenticationScheme: null, properties: properties);
+ }
+
+ public virtual void Challenge(string authenticationScheme)
+ {
+ Challenge(authenticationScheme: authenticationScheme, properties: null);
+ }
+
+ public abstract void Challenge(string authenticationScheme, AuthenticationProperties properties);
+
+ public void SignIn(string authenticationScheme, ClaimsPrincipal principal)
+ {
+ SignIn(authenticationScheme, principal, properties: null);
+ }
+
+ public abstract void SignIn(string authenticationScheme, ClaimsPrincipal principal, AuthenticationProperties properties);
+
+ public virtual void SignOut()
+ {
+ SignOut(authenticationScheme: null, properties: null);
+ }
+
+ public abstract void SignOut(string authenticationScheme);
+
+ public abstract void SignOut(string authenticationScheme, AuthenticationProperties properties);
+ }
+}
diff --git a/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationProperties.cs b/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationProperties.cs
index 475dd027..f6574163 100644
--- a/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationProperties.cs
+++ b/src/Microsoft.AspNet.Http.Core/Authentication/AuthenticationProperties.cs
@@ -24,51 +24,51 @@ public class AuthenticationProperties
/// Initializes a new instance of the class
///
public AuthenticationProperties()
- : this(dictionary: null)
+ : this(items: null)
{
}
///
/// Initializes a new instance of the class
///
- ///
- public AuthenticationProperties(IDictionary dictionary)
+ ///
+ public AuthenticationProperties(IDictionary items)
{
- Dictionary = dictionary ?? new Dictionary(StringComparer.Ordinal);
+ Items = items ?? new Dictionary(StringComparer.Ordinal);
}
///
/// State values about the authentication session.
///
- public IDictionary Dictionary { get; private set; }
+ public IDictionary Items { get; private set; }
///
/// Gets or sets whether the authentication session is persisted across multiple requests.
///
public bool IsPersistent
{
- get { return Dictionary.ContainsKey(IsPersistentKey); }
+ get { return Items.ContainsKey(IsPersistentKey); }
set
{
- if (Dictionary.ContainsKey(IsPersistentKey))
+ if (Items.ContainsKey(IsPersistentKey))
{
if (!value)
{
- Dictionary.Remove(IsPersistentKey);
+ Items.Remove(IsPersistentKey);
}
}
else
{
if (value)
{
- Dictionary.Add(IsPersistentKey, string.Empty);
+ Items.Add(IsPersistentKey, string.Empty);
}
}
}
}
///
- /// Gets or sets the full path or absolute URI to be used as an http redirect response value.
+ /// Gets or sets the full path or absolute URI to be used as an http redirect response value.
///
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "By design")]
public string RedirectUri
@@ -76,19 +76,19 @@ public string RedirectUri
get
{
string value;
- return Dictionary.TryGetValue(RedirectUriKey, out value) ? value : null;
+ return Items.TryGetValue(RedirectUriKey, out value) ? value : null;
}
set
{
if (value != null)
{
- Dictionary[RedirectUriKey] = value;
+ Items[RedirectUriKey] = value;
}
else
{
- if (Dictionary.ContainsKey(RedirectUriKey))
+ if (Items.ContainsKey(RedirectUriKey))
{
- Dictionary.Remove(RedirectUriKey);
+ Items.Remove(RedirectUriKey);
}
}
}
@@ -102,7 +102,7 @@ public DateTimeOffset? IssuedUtc
get
{
string value;
- if (Dictionary.TryGetValue(IssuedUtcKey, out value))
+ if (Items.TryGetValue(IssuedUtcKey, out value))
{
DateTimeOffset dateTimeOffset;
if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset))
@@ -116,13 +116,13 @@ public DateTimeOffset? IssuedUtc
{
if (value.HasValue)
{
- Dictionary[IssuedUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
+ Items[IssuedUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
}
else
{
- if (Dictionary.ContainsKey(IssuedUtcKey))
+ if (Items.ContainsKey(IssuedUtcKey))
{
- Dictionary.Remove(IssuedUtcKey);
+ Items.Remove(IssuedUtcKey);
}
}
}
@@ -136,7 +136,7 @@ public DateTimeOffset? ExpiresUtc
get
{
string value;
- if (Dictionary.TryGetValue(ExpiresUtcKey, out value))
+ if (Items.TryGetValue(ExpiresUtcKey, out value))
{
DateTimeOffset dateTimeOffset;
if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset))
@@ -150,13 +150,13 @@ public DateTimeOffset? ExpiresUtc
{
if (value.HasValue)
{
- Dictionary[ExpiresUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
+ Items[ExpiresUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
}
else
{
- if (Dictionary.ContainsKey(ExpiresUtcKey))
+ if (Items.ContainsKey(ExpiresUtcKey))
{
- Dictionary.Remove(ExpiresUtcKey);
+ Items.Remove(ExpiresUtcKey);
}
}
}
@@ -170,7 +170,7 @@ public bool? AllowRefresh
get
{
string value;
- if (Dictionary.TryGetValue(RefreshKey, out value))
+ if (Items.TryGetValue(RefreshKey, out value))
{
bool refresh;
if (bool.TryParse(value, out refresh))
@@ -184,13 +184,13 @@ public bool? AllowRefresh
{
if (value.HasValue)
{
- Dictionary[RefreshKey] = value.Value.ToString();
+ Items[RefreshKey] = value.Value.ToString();
}
else
{
- if (Dictionary.ContainsKey(RefreshKey))
+ if (Items.ContainsKey(RefreshKey))
{
- Dictionary.Remove(RefreshKey);
+ Items.Remove(RefreshKey);
}
}
}
diff --git a/src/Microsoft.AspNet.Http.Core/HttpContext.cs b/src/Microsoft.AspNet.Http.Core/HttpContext.cs
index 47f595df..14646bf0 100644
--- a/src/Microsoft.AspNet.Http.Core/HttpContext.cs
+++ b/src/Microsoft.AspNet.Http.Core/HttpContext.cs
@@ -3,11 +3,8 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Net.WebSockets;
using System.Security.Claims;
using System.Threading;
-using System.Threading.Tasks;
using Microsoft.AspNet.Http.Authentication;
namespace Microsoft.AspNet.Http
@@ -20,6 +17,8 @@ public abstract class HttpContext : IDisposable
public abstract ConnectionInfo Connection { get; }
+ public abstract AuthenticationManager Authentication { get; }
+
public abstract ClaimsPrincipal User { get; set; }
public abstract IDictionary