diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs
index 3f09191900..6547450e51 100644
--- a/samples/CookieSample/Startup.cs
+++ b/samples/CookieSample/Startup.cs
@@ -28,7 +28,7 @@ namespace CookieSample
if (string.IsNullOrEmpty(context.User.Identity.Name))
{
var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") }));
- context.Response.SignIn(CookieAuthenticationDefaults.AuthenticationScheme, user);
+ context.Authentication.SignIn(CookieAuthenticationDefaults.AuthenticationScheme, user);
context.Response.ContentType = "text/plain";
await context.Response.WriteAsync("Hello First timer");
return;
diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs
index 0f962caeda..f0b1b5219b 100644
--- a/samples/CookieSessionSample/Startup.cs
+++ b/samples/CookieSessionSample/Startup.cs
@@ -36,7 +36,7 @@ namespace CookieSessionSample
{
claims.Add(new Claim(ClaimTypes.Role, "SomeRandomGroup" + i, ClaimValueTypes.String, "IssuedByBob", "OriginalIssuerJoe"));
}
- context.Response.SignIn(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(claims)));
+ context.Authentication.SignIn(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(new ClaimsIdentity(claims)));
context.Response.ContentType = "text/plain";
await context.Response.WriteAsync("Hello First timer");
return;
diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs
index 7c1969d3bc..2077d802bb 100644
--- a/samples/OpenIdConnectSample/Startup.cs
+++ b/samples/OpenIdConnectSample/Startup.cs
@@ -40,7 +40,7 @@ namespace OpenIdConnectSample
{
if (string.IsNullOrEmpty(context.User.Identity.Name))
{
- context.Response.Challenge(new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectAuthenticationDefaults.AuthenticationScheme);
+ context.Authentication.Challenge(OpenIdConnectAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" });
context.Response.ContentType = "text/plain";
await context.Response.WriteAsync("Hello First timer");
diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs
index 4bfc7b6594..f552ceea3c 100644
--- a/samples/SocialSample/Startup.cs
+++ b/samples/SocialSample/Startup.cs
@@ -188,14 +188,14 @@ namespace CookieSample
{
// By default the client will be redirect back to the URL that issued the challenge (/login?authtype=foo),
// send them to the home page instead (/).
- context.Response.Challenge(new AuthenticationProperties() { RedirectUri = "/" }, authType);
+ context.Authentication.Challenge(authType, new AuthenticationProperties() { RedirectUri = "/" });
return;
}
context.Response.ContentType = "text/html";
await context.Response.WriteAsync("
");
await context.Response.WriteAsync("Choose an authentication scheme:
");
- foreach (var type in context.GetAuthenticationSchemes())
+ foreach (var type in context.Authentication.GetAuthenticationSchemes())
{
await context.Response.WriteAsync("" + (type.Caption ?? "(suppressed)") + "
");
}
@@ -208,7 +208,7 @@ namespace CookieSample
{
signoutApp.Run(async context =>
{
- context.Response.SignOut(CookieAuthenticationDefaults.AuthenticationScheme);
+ context.Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationScheme);
context.Response.ContentType = "text/html";
await context.Response.WriteAsync("");
await context.Response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "
");
@@ -223,7 +223,7 @@ namespace CookieSample
if (string.IsNullOrEmpty(context.User.Identity.Name))
{
// The cookie middleware will intercept this 401 and redirect to /login
- context.Response.Challenge();
+ context.Authentication.Challenge();
return;
}
await next();
diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
index 27b0d2c4e0..5e1acbcb16 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
@@ -157,23 +157,23 @@ namespace Microsoft.AspNet.Authentication.Cookies
Options,
Options.AuthenticationScheme,
signin.Principal,
- signin.Properties,
+ new AuthenticationProperties(signin.Properties),
cookieOptions);
DateTimeOffset issuedUtc;
- if (signin.Properties.IssuedUtc.HasValue)
+ if (signInContext.Properties.IssuedUtc.HasValue)
{
- issuedUtc = signin.Properties.IssuedUtc.Value;
+ issuedUtc = signInContext.Properties.IssuedUtc.Value;
}
else
{
issuedUtc = Options.SystemClock.UtcNow;
- signin.Properties.IssuedUtc = issuedUtc;
+ signInContext.Properties.IssuedUtc = issuedUtc;
}
- if (!signin.Properties.ExpiresUtc.HasValue)
+ if (!signInContext.Properties.ExpiresUtc.HasValue)
{
- signin.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan);
+ signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan);
}
Options.Notifications.ResponseSignIn(signInContext);
@@ -226,7 +226,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
Context,
Options,
cookieOptions);
-
+
Options.Notifications.ResponseSignOut(context);
Options.CookieManager.DeleteCookie(
diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs
index 175c38c207..c30e70526f 100644
--- a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs
@@ -102,14 +102,14 @@ namespace Microsoft.AspNet.Authentication.Google
string name, string defaultValue = null)
{
string value;
- if (!properties.Dictionary.TryGetValue(name, out value))
+ if (!properties.Items.TryGetValue(name, out value))
{
value = defaultValue;
}
else
{
// Remove the parameter from AuthenticationProperties so it won't be serialized to state parameter
- properties.Dictionary.Remove(name);
+ properties.Items.Remove(name);
}
if (value == null)
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs
index 5d3cb8c60d..21c684a68d 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationHandler.cs
@@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
if (context.SignInScheme != null && context.Principal != null)
{
- Context.Response.SignIn(context.SignInScheme, context.Principal, context.Properties);
+ Context.Authentication.SignIn(context.SignInScheme, context.Principal, context.Properties);
}
if (!context.IsRequestCompleted && context.RedirectUri != null)
diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs
index 25af5a4a0c..3ea2a4578d 100644
--- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs
@@ -161,7 +161,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
// When redeeming a 'code' for an AccessToken, this value is needed
if (!string.IsNullOrWhiteSpace(Options.RedirectUri))
{
- properties.Dictionary.Add(OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey, Options.RedirectUri);
+ properties.Items.Add(OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey, Options.RedirectUri);
}
if (_configuration == null && Options.ConfigurationManager != null)
@@ -385,12 +385,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
ticket = new AuthenticationTicket(principal, properties, Options.AuthenticationScheme);
if (!string.IsNullOrWhiteSpace(message.SessionState))
{
- ticket.Properties.Dictionary[OpenIdConnectSessionProperties.SessionState] = message.SessionState;
+ ticket.Properties.Items[OpenIdConnectSessionProperties.SessionState] = message.SessionState;
}
if (_configuration != null && !string.IsNullOrWhiteSpace(_configuration.CheckSessionIframe))
{
- ticket.Properties.Dictionary[OpenIdConnectSessionProperties.CheckSessionIFrame] = _configuration.CheckSessionIframe;
+ ticket.Properties.Items[OpenIdConnectSessionProperties.CheckSessionIFrame] = _configuration.CheckSessionIframe;
}
// Rename?
@@ -466,8 +466,8 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
Code = message.Code,
JwtSecurityToken = jwt,
ProtocolMessage = message,
- RedirectUri = ticket.Properties.Dictionary.ContainsKey(OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey) ?
- ticket.Properties.Dictionary[OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey] : string.Empty,
+ RedirectUri = ticket.Properties.Items.ContainsKey(OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey) ?
+ ticket.Properties.Items[OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey] : string.Empty,
};
await Options.Notifications.AuthorizationCodeReceived(authorizationCodeReceivedNotification);
@@ -632,7 +632,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
{
if (ticket.Principal != null)
{
- Request.HttpContext.Response.SignIn(Options.SignInScheme, ticket.Principal, ticket.Properties);
+ Request.HttpContext.Authentication.SignIn(Options.SignInScheme, ticket.Principal, ticket.Properties);
}
// Redirect back to the original secured resource, if any.
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs
index 6df6fc1a80..e487f76982 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs
@@ -208,7 +208,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
if (context.SignInScheme != null && context.Principal != null)
{
- Context.Response.SignIn(context.SignInScheme, context.Principal, context.Properties);
+ Context.Authentication.SignIn(context.SignInScheme, context.Principal, context.Properties);
}
if (!context.IsRequestCompleted && context.RedirectUri != null)
diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs
index fed4778780..22bc9eb36b 100644
--- a/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication/AuthenticationHandler.cs
@@ -31,9 +31,9 @@ namespace Microsoft.AspNet.Authentication
private AuthenticationOptions _baseOptions;
- protected IChallengeContext ChallengeContext { get; set; }
+ protected ChallengeContext ChallengeContext { get; set; }
protected SignInContext SignInContext { get; set; }
- protected ISignOutContext SignOutContext { get; set; }
+ protected SignOutContext SignOutContext { get; set; }
protected HttpContext Context { get; private set; }
@@ -145,9 +145,9 @@ namespace Microsoft.AspNet.Authentication
return Task.FromResult(false);
}
- public virtual void GetDescriptions(IDescribeSchemesContext describeContext)
+ public virtual void GetDescriptions(DescribeSchemesContext describeContext)
{
- describeContext.Accept(BaseOptions.Description.Dictionary);
+ describeContext.Accept(BaseOptions.Description.Items);
if (PriorHandler != null)
{
@@ -155,7 +155,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public virtual void Authenticate(IAuthenticateContext context)
+ public virtual void Authenticate(AuthenticateContext context)
{
if (ShouldHandleScheme(context.AuthenticationScheme))
{
@@ -163,7 +163,7 @@ namespace Microsoft.AspNet.Authentication
if (ticket?.Principal != null)
{
AuthenticateCalled = true;
- context.Authenticated(ticket.Principal, ticket.Properties.Dictionary, BaseOptions.Description.Dictionary);
+ context.Authenticated(ticket.Principal, ticket.Properties.Items, BaseOptions.Description.Items);
}
else
{
@@ -177,7 +177,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public virtual async Task AuthenticateAsync(IAuthenticateContext context)
+ public virtual async Task AuthenticateAsync(AuthenticateContext context)
{
if (ShouldHandleScheme(context.AuthenticationScheme))
{
@@ -185,7 +185,7 @@ namespace Microsoft.AspNet.Authentication
if (ticket?.Principal != null)
{
AuthenticateCalled = true;
- context.Authenticated(ticket.Principal, ticket.Properties.Dictionary, BaseOptions.Description.Dictionary);
+ context.Authenticated(ticket.Principal, ticket.Properties.Items, BaseOptions.Description.Items);
}
else
{
@@ -326,13 +326,13 @@ namespace Microsoft.AspNet.Authentication
return Task.FromResult(0);
}
- public virtual void SignIn(ISignInContext context)
+ public virtual void SignIn(SignInContext context)
{
if (ShouldHandleScheme(context.AuthenticationScheme))
{
- SignInContext = new SignInContext(context.Principal, new AuthenticationProperties(context.Properties));
+ SignInContext = context;
SignOutContext = null;
- context.Accept(BaseOptions.Description.Dictionary);
+ context.Accept();
}
if (PriorHandler != null)
@@ -341,7 +341,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public virtual void SignOut(ISignOutContext context)
+ public virtual void SignOut(SignOutContext context)
{
if (ShouldHandleScheme(context.AuthenticationScheme))
{
@@ -356,7 +356,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public virtual void Challenge(IChallengeContext context)
+ public virtual void Challenge(ChallengeContext context)
{
if (ShouldHandleScheme(context.AuthenticationScheme))
{
@@ -414,7 +414,7 @@ namespace Microsoft.AspNet.Authentication
Secure = Request.IsHttps
};
- properties.Dictionary[correlationKey] = correlationId;
+ properties.Items[correlationKey] = correlationId;
Response.Cookies.Append(correlationKey, correlationId, cookieOptions);
}
@@ -437,7 +437,7 @@ namespace Microsoft.AspNet.Authentication
Response.Cookies.Delete(correlationKey, cookieOptions);
string correlationExtra;
- if (!properties.Dictionary.TryGetValue(
+ if (!properties.Items.TryGetValue(
correlationKey,
out correlationExtra))
{
@@ -445,7 +445,7 @@ namespace Microsoft.AspNet.Authentication
return false;
}
- properties.Dictionary.Remove(correlationKey);
+ properties.Items.Remove(correlationKey);
if (!string.Equals(correlationCookie, correlationExtra, StringComparison.Ordinal))
{
diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAuthenticationHandler.cs
index ae1599ee03..5839d4d4e5 100644
--- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAuthenticationHandler.cs
@@ -22,24 +22,24 @@ namespace Microsoft.AspNet.Authentication
public IAuthenticationHandler PriorHandler { get; set; }
- private void ApplyTransform(IAuthenticateContext context)
+ private void ApplyTransform(AuthenticateContext context)
{
if (_transform != null)
{
// REVIEW: this cast seems really bad (missing interface way to get the result back out?)
var authContext = context as AuthenticateContext;
- if (authContext?.Result?.Principal != null)
+ if (authContext?.Principal != null)
{
context.Authenticated(
- _transform.Invoke(authContext.Result.Principal),
- authContext.Result.Properties.Dictionary,
- authContext.Result.Description.Dictionary);
+ _transform.Invoke(authContext.Principal),
+ authContext.Properties,
+ authContext.Description);
}
}
}
- public void Authenticate(IAuthenticateContext context)
+ public void Authenticate(AuthenticateContext context)
{
if (PriorHandler != null)
{
@@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public async Task AuthenticateAsync(IAuthenticateContext context)
+ public async Task AuthenticateAsync(AuthenticateContext context)
{
if (PriorHandler != null)
{
@@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public void Challenge(IChallengeContext context)
+ public void Challenge(ChallengeContext context)
{
if (PriorHandler != null)
{
@@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public void GetDescriptions(IDescribeSchemesContext context)
+ public void GetDescriptions(DescribeSchemesContext context)
{
if (PriorHandler != null)
{
@@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public void SignIn(ISignInContext context)
+ public void SignIn(SignInContext context)
{
if (PriorHandler != null)
{
@@ -81,7 +81,7 @@ namespace Microsoft.AspNet.Authentication
}
}
- public void SignOut(ISignOutContext context)
+ public void SignOut(SignOutContext context)
{
if (PriorHandler != null)
{
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/Serializer/PropertiesSerializer.cs b/src/Microsoft.AspNet.Authentication/DataHandler/Serializer/PropertiesSerializer.cs
index 9b262e6c25..ccfba6456b 100644
--- a/src/Microsoft.AspNet.Authentication/DataHandler/Serializer/PropertiesSerializer.cs
+++ b/src/Microsoft.AspNet.Authentication/DataHandler/Serializer/PropertiesSerializer.cs
@@ -44,8 +44,8 @@ namespace Microsoft.AspNet.Authentication.DataHandler.Serializer
public static void Write([NotNull] BinaryWriter writer, [NotNull] AuthenticationProperties properties)
{
writer.Write(FormatVersion);
- writer.Write(properties.Dictionary.Count);
- foreach (var kv in properties.Dictionary)
+ writer.Write(properties.Items.Count);
+ foreach (var kv in properties.Items)
{
writer.Write(kv.Key);
writer.Write(kv.Value);
diff --git a/src/Microsoft.AspNet.Authentication/SignInContext.cs b/src/Microsoft.AspNet.Authentication/SignInContext.cs
deleted file mode 100644
index efe055ba83..0000000000
--- a/src/Microsoft.AspNet.Authentication/SignInContext.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.Security.Claims;
-using Microsoft.AspNet.Http.Authentication;
-
-namespace Microsoft.AspNet.Authentication
-{
- public class SignInContext
- {
- public SignInContext(ClaimsPrincipal principal, AuthenticationProperties properties)
- {
- Principal = principal;
- Properties = properties;
- }
-
- public ClaimsPrincipal Principal { get; private set; }
- public AuthenticationProperties Properties { get; private set; }
- }
-}
diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
index 9c1ac2fdd6..aa13043976 100644
--- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
@@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
private Task SignInAsAlice(HttpContext context)
{
- context.Response.SignIn("Cookies",
+ context.Authentication.SignIn("Cookies",
new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))),
new AuthenticationProperties());
return Task.FromResult