diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
index cc1dc91685..b002fc2d68 100644
--- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAuthenticationHandler.cs
@@ -193,8 +193,8 @@ namespace Microsoft.AspNet.Authentication.Cookies
_sessionKey = await Options.SessionStore.StoreAsync(model);
var principal = new ClaimsPrincipal(
new ClaimsIdentity(
- new[] { new Claim(SessionIdClaim, _sessionKey) },
- Options.AuthenticationScheme));
+ new[] { new Claim(SessionIdClaim, _sessionKey, ClaimValueTypes.String, Options.ClaimsIssuer) },
+ Options.ClaimsIssuer));
model = new AuthenticationTicket(principal, null, Options.AuthenticationScheme);
}
var cookieValue = Options.TicketDataFormat.Protect(model);
@@ -243,7 +243,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
await Options.SessionStore.RenewAsync(_sessionKey, model);
var principal = new ClaimsPrincipal(
new ClaimsIdentity(
- new[] { new Claim(SessionIdClaim, _sessionKey) },
+ new[] { new Claim(SessionIdClaim, _sessionKey, ClaimValueTypes.String, Options.ClaimsIssuer) },
Options.AuthenticationScheme));
model = new AuthenticationTicket(principal, null, Options.AuthenticationScheme);
}
diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationHandler.cs
index aa306d683a..3549eec2d2 100644
--- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationHandler.cs
@@ -13,7 +13,6 @@ using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Http.Collections;
using Microsoft.AspNet.Http.Extensions;
using Microsoft.AspNet.WebUtilities;
-using Microsoft.Framework.WebEncoders;
using Newtonsoft.Json.Linq;
namespace Microsoft.AspNet.Authentication.Facebook
@@ -65,34 +64,34 @@ namespace Microsoft.AspNet.Authentication.Facebook
var context = new FacebookAuthenticatedContext(Context, Options, user, tokens);
var identity = new ClaimsIdentity(
- Options.AuthenticationScheme,
+ Options.ClaimsIssuer,
ClaimsIdentity.DefaultNameClaimType,
ClaimsIdentity.DefaultRoleClaimType);
if (!string.IsNullOrEmpty(context.Id))
{
- identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, context.Id, ClaimValueTypes.String, Options.AuthenticationScheme));
+ identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, context.Id, ClaimValueTypes.String, Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.UserName))
{
- identity.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, context.UserName, ClaimValueTypes.String, Options.AuthenticationScheme));
+ identity.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, context.UserName, ClaimValueTypes.String, Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.Email))
{
- identity.AddClaim(new Claim(ClaimTypes.Email, context.Email, ClaimValueTypes.String, Options.AuthenticationScheme));
+ identity.AddClaim(new Claim(ClaimTypes.Email, context.Email, ClaimValueTypes.String, Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.Name))
{
- identity.AddClaim(new Claim("urn:facebook:name", context.Name, ClaimValueTypes.String, Options.AuthenticationScheme));
+ identity.AddClaim(new Claim("urn:facebook:name", context.Name, ClaimValueTypes.String, Options.ClaimsIssuer));
// Many Facebook accounts do not set the UserName field. Fall back to the Name field instead.
if (string.IsNullOrEmpty(context.UserName))
{
- identity.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, context.Name, ClaimValueTypes.String, Options.AuthenticationScheme));
+ identity.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, context.Name, ClaimValueTypes.String, Options.ClaimsIssuer));
}
}
if (!string.IsNullOrEmpty(context.Link))
{
- identity.AddClaim(new Claim("urn:facebook:link", context.Link, ClaimValueTypes.String, Options.AuthenticationScheme));
+ identity.AddClaim(new Claim("urn:facebook:link", context.Link, ClaimValueTypes.String, Options.ClaimsIssuer));
}
context.Properties = properties;
context.Principal = new ClaimsPrincipal(identity);
@@ -104,7 +103,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
private string GenerateAppSecretProof(string accessToken)
{
- using (HMACSHA256 algorithm = new HMACSHA256(Encoding.ASCII.GetBytes(Options.AppSecret)))
+ using (var algorithm = new HMACSHA256(Encoding.ASCII.GetBytes(Options.AppSecret)))
{
var hash = algorithm.ComputeHash(Encoding.ASCII.GetBytes(accessToken));
var builder = new StringBuilder();
@@ -124,4 +123,4 @@ namespace Microsoft.AspNet.Authentication.Facebook
return string.Join(",", Options.Scope);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs
index b54f657be5..621e77d830 100644
--- a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationHandler.cs
@@ -33,39 +33,39 @@ namespace Microsoft.AspNet.Authentication.Google
var context = new GoogleAuthenticatedContext(Context, Options, user, tokens);
var identity = new ClaimsIdentity(
- Options.AuthenticationScheme,
+ Options.ClaimsIssuer,
ClaimsIdentity.DefaultNameClaimType,
ClaimsIdentity.DefaultRoleClaimType);
if (!string.IsNullOrEmpty(context.Id))
{
identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, context.Id,
- ClaimValueTypes.String, Options.AuthenticationScheme));
+ ClaimValueTypes.String, Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.GivenName))
{
identity.AddClaim(new Claim(ClaimTypes.GivenName, context.GivenName,
- ClaimValueTypes.String, Options.AuthenticationScheme));
+ ClaimValueTypes.String, Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.FamilyName))
{
identity.AddClaim(new Claim(ClaimTypes.Surname, context.FamilyName,
- ClaimValueTypes.String, Options.AuthenticationScheme));
+ ClaimValueTypes.String, Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.Name))
{
identity.AddClaim(new Claim(ClaimTypes.Name, context.Name, ClaimValueTypes.String,
- Options.AuthenticationScheme));
+ Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.Email))
{
identity.AddClaim(new Claim(ClaimTypes.Email, context.Email, ClaimValueTypes.String,
- Options.AuthenticationScheme));
+ Options.ClaimsIssuer));
}
if (!string.IsNullOrEmpty(context.Profile))
{
identity.AddClaim(new Claim("urn:google:profile", context.Profile, ClaimValueTypes.String,
- Options.AuthenticationScheme));
+ Options.ClaimsIssuer));
}
context.Properties = properties;
context.Principal = new ClaimsPrincipal(identity);
@@ -120,4 +120,4 @@ namespace Microsoft.AspNet.Authentication.Google
queryStrings[name] = value;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs
index 2921b6b211..db7a3c9881 100644
--- a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs
+++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNet.Authentication.OAuth;
using Microsoft.AspNet.Builder;
diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationOptions.cs
index 1dab084f04..e65b800eda 100644
--- a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationOptions.cs
+++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationOptions.cs
@@ -1,12 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
-using System.Collections.Generic;
-using System.Net.Http;
-using Microsoft.AspNet.Http;
-using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Authentication.OAuth;
+using Microsoft.AspNet.Http;
namespace Microsoft.AspNet.Authentication.Google
{
diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationHandler.cs
index 4ecaabab6d..31484f9985 100644
--- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationHandler.cs
@@ -32,18 +32,18 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount
var identity = new ClaimsIdentity(
new[]
{
- new Claim(ClaimTypes.NameIdentifier, context.Id, ClaimValueTypes.String, Options.AuthenticationScheme),
- new Claim(ClaimTypes.Name, context.Name, ClaimValueTypes.String, Options.AuthenticationScheme),
- new Claim("urn:microsoftaccount:id", context.Id, ClaimValueTypes.String, Options.AuthenticationScheme),
- new Claim("urn:microsoftaccount:name", context.Name, ClaimValueTypes.String, Options.AuthenticationScheme)
+ new Claim(ClaimTypes.NameIdentifier, context.Id, ClaimValueTypes.String, Options.ClaimsIssuer),
+ new Claim(ClaimTypes.Name, context.Name, ClaimValueTypes.String, Options.ClaimsIssuer),
+ new Claim("urn:microsoftaccount:id", context.Id, ClaimValueTypes.String, Options.ClaimsIssuer),
+ new Claim("urn:microsoftaccount:name", context.Name, ClaimValueTypes.String, Options.ClaimsIssuer)
},
- Options.AuthenticationScheme,
+ Options.ClaimsIssuer,
ClaimsIdentity.DefaultNameClaimType,
ClaimsIdentity.DefaultRoleClaimType);
if (!string.IsNullOrWhiteSpace(context.Email))
{
- identity.AddClaim(new Claim(ClaimTypes.Email, context.Email, ClaimValueTypes.String, Options.AuthenticationScheme));
+ identity.AddClaim(new Claim(ClaimTypes.Email, context.Email, ClaimValueTypes.String, Options.ClaimsIssuer));
}
context.Principal = new ClaimsPrincipal(identity);
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs
index e4357a68a6..70d4544a25 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs
@@ -69,7 +69,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
if (Options.StateDataFormat == null)
{
var dataProtector = dataProtectionProvider.CreateProtector(
- this.GetType().FullName, Options.AuthenticationScheme, "v1");
+ GetType().FullName, Options.AuthenticationScheme, "v1");
Options.StateDataFormat = new PropertiesDataFormat(dataProtector);
}
diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs
index bfbea1e29d..62296c4a96 100644
--- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
-using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication;
@@ -106,11 +105,6 @@ namespace Microsoft.AspNet.Authentication.OAuth
///
public string SignInScheme { get; set; }
- ///
- /// Gets or sets the issuer that should be used for any claims that are created
- ///
- public string ClaimsIssuer { get; set; }
-
///
/// Gets or sets the type used to secure data handled by the middleware.
///
diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs
index c88d456043..b088519509 100644
--- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationHandler.cs
@@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer
// notify user token was received
var securityTokenReceivedNotification =
- new SecurityTokenReceivedNotification(Context, Options)
+ new SecurityTokenReceivedNotification(Context, Options)
{
ProtocolMessage = Context,
SecurityToken = token,
@@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer
}
else
{
- IEnumerable issuers = new[] { _configuration.Issuer };
+ var issuers = new[] { _configuration.Issuer };
validationParameters.ValidIssuers = (validationParameters.ValidIssuers == null ? issuers : validationParameters.ValidIssuers.Concat(issuers));
}
@@ -122,8 +122,8 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer
{
if (validator.CanReadToken(token))
{
- ClaimsPrincipal principal = validator.ValidateToken(token, validationParameters, out validatedToken);
- AuthenticationTicket ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme);
+ var principal = validator.ValidateToken(token, validationParameters, out validatedToken);
+ var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Options.AuthenticationScheme);
var securityTokenValidatedNotification = new SecurityTokenValidatedNotification(Context, Options)
{
ProtocolMessage = Context,
diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs
index ed1242b95b..c76071b6ab 100644
--- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationMiddleware.cs
@@ -23,8 +23,6 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer
///
public class OAuthBearerAuthenticationMiddleware : AuthenticationMiddleware
{
- private readonly ILogger _logger;
-
///
/// Bearer authentication component which is added to an HTTP pipeline. This constructor is not
/// called by application code directly, instead it is added by calling the the IAppBuilder UseOAuthBearerAuthentication
@@ -72,7 +70,7 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer
Options.MetadataAddress += ".well-known/openid-configuration";
}
- HttpClient httpClient = new HttpClient(ResolveHttpMessageHandler(Options));
+ var httpClient = new HttpClient(ResolveHttpMessageHandler(Options));
httpClient.Timeout = Options.BackchannelTimeout;
httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB
diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs
index 00cc96c7a7..e520406875 100644
--- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs
+++ b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs
@@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens;
using System.Net.Http;
-using Microsoft.AspNet.Authentication;
using Microsoft.IdentityModel.Protocols;
namespace Microsoft.AspNet.Authentication.OAuthBearer
diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs
index cd09a14165..61ff95e2f4 100644
--- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs
+++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationHandler.cs
@@ -78,7 +78,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
return new AuthenticationTicket(properties, Options.AuthenticationScheme);
}
- string oauthVerifier = query.Get("oauth_verifier");
+ var oauthVerifier = query.Get("oauth_verifier");
if (string.IsNullOrWhiteSpace(oauthVerifier))
{
Logger.LogWarning("Missing or blank oauth_verifier");
@@ -93,12 +93,12 @@ namespace Microsoft.AspNet.Authentication.Twitter
new ClaimsIdentity(
new[]
{
- new Claim(ClaimTypes.NameIdentifier, accessToken.UserId, "http://www.w3.org/2001/XMLSchema#string", Options.AuthenticationScheme),
- new Claim(ClaimTypes.Name, accessToken.ScreenName, "http://www.w3.org/2001/XMLSchema#string", Options.AuthenticationScheme),
- new Claim("urn:twitter:userid", accessToken.UserId, "http://www.w3.org/2001/XMLSchema#string", Options.AuthenticationScheme),
- new Claim("urn:twitter:screenname", accessToken.ScreenName, "http://www.w3.org/2001/XMLSchema#string", Options.AuthenticationScheme)
+ new Claim(ClaimTypes.NameIdentifier, accessToken.UserId, "http://www.w3.org/2001/XMLSchema#string", Options.ClaimsIssuer),
+ new Claim(ClaimTypes.Name, accessToken.ScreenName, "http://www.w3.org/2001/XMLSchema#string", Options.ClaimsIssuer),
+ new Claim("urn:twitter:userid", accessToken.UserId, "http://www.w3.org/2001/XMLSchema#string", Options.ClaimsIssuer),
+ new Claim("urn:twitter:screenname", accessToken.ScreenName, "http://www.w3.org/2001/XMLSchema#string", Options.ClaimsIssuer)
},
- Options.AuthenticationScheme,
+ Options.ClaimsIssuer,
ClaimsIdentity.DefaultNameClaimType,
ClaimsIdentity.DefaultRoleClaimType));
context.Properties = requestToken.Properties;
diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs
index 7cfd6138ff..188f903c49 100644
--- a/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs
+++ b/src/Microsoft.AspNet.Authentication/AuthenticationMiddleware.cs
@@ -35,6 +35,12 @@ namespace Microsoft.AspNet.Authentication
Logger = loggerFactory.CreateLogger(this.GetType().FullName);
UrlEncoder = encoder;
+ if (string.IsNullOrEmpty(Options.ClaimsIssuer))
+ {
+ // Default to something reasonable
+ Options.ClaimsIssuer = Options.AuthenticationScheme;
+ }
+
_next = next;
}
diff --git a/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs
index b1c2bc263a..54f8a7a352 100644
--- a/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs
+++ b/src/Microsoft.AspNet.Authentication/AuthenticationOptions.cs
@@ -33,6 +33,11 @@ namespace Microsoft.AspNet.Authentication
///
public bool AutomaticAuthentication { get; set; }
+ ///
+ /// Gets or sets the issuer that should be used for any claims that are created
+ ///
+ public string ClaimsIssuer { get; set; }
+
///
/// Additional information about the authentication type which is made available to the application.
///
diff --git a/src/Microsoft.AspNet.Authentication/DataHandler/Encoder/Base64UrlTextEncoder.cs b/src/Microsoft.AspNet.Authentication/DataHandler/Encoder/Base64UrlTextEncoder.cs
index 723736973d..28d74196fa 100644
--- a/src/Microsoft.AspNet.Authentication/DataHandler/Encoder/Base64UrlTextEncoder.cs
+++ b/src/Microsoft.AspNet.Authentication/DataHandler/Encoder/Base64UrlTextEncoder.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
using System;
using Microsoft.Framework.Internal;
diff --git a/src/Microsoft.AspNet.Authentication/SecurityHelper.cs b/src/Microsoft.AspNet.Authentication/SecurityHelper.cs
index ea7234b209..617fe14a16 100644
--- a/src/Microsoft.AspNet.Authentication/SecurityHelper.cs
+++ b/src/Microsoft.AspNet.Authentication/SecurityHelper.cs
@@ -1,9 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Http;
using Microsoft.Framework.Internal;
@@ -21,7 +18,7 @@ namespace Microsoft.AspNet.Authentication
///
public static void AddUserPrincipal([NotNull] HttpContext context, [NotNull] ClaimsPrincipal principal)
{
- ClaimsPrincipal existingPrincipal = context.User;
+ var existingPrincipal = context.User;
if (existingPrincipal != null)
{
foreach (var existingClaimsIdentity in existingPrincipal.Identities)
diff --git a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
index d35978aeea..c368365329 100644
--- a/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
+++ b/test/Microsoft.AspNet.Authentication.Test/Cookies/CookieMiddlewareTests.cs
@@ -27,10 +27,10 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact]
public async Task NormalRequestPassesThrough()
{
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
});
- HttpResponseMessage response = await server.CreateClient().GetAsync("http://example.com/normal");
+ var response = await server.CreateClient().GetAsync("http://example.com/normal");
response.StatusCode.ShouldBe(HttpStatusCode.OK);
}
@@ -39,13 +39,13 @@ namespace Microsoft.AspNet.Authentication.Cookies
[InlineData(false)]
public async Task ProtectedRequestShouldRedirectToLoginOnlyWhenAutomatic(bool auto)
{
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.LoginPath = new PathString("/login");
options.AutomaticAuthentication = auto;
});
- Transaction transaction = await SendAsync(server, "http://example.com/protected");
+ var transaction = await SendAsync(server, "http://example.com/protected");
transaction.Response.StatusCode.ShouldBe(auto ? HttpStatusCode.Redirect : HttpStatusCode.Unauthorized);
if (auto)
@@ -61,13 +61,13 @@ namespace Microsoft.AspNet.Authentication.Cookies
[InlineData(false)]
public async Task ProtectedCustomRequestShouldRedirectToCustomLogin(bool auto)
{
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.LoginPath = new PathString("/login");
options.AutomaticAuthentication = auto;
});
- Transaction transaction = await SendAsync(server, "http://example.com/protected/CustomRedirect");
+ var transaction = await SendAsync(server, "http://example.com/protected/CustomRedirect");
transaction.Response.StatusCode.ShouldBe(auto ? HttpStatusCode.Redirect : HttpStatusCode.Unauthorized);
if (auto)
@@ -102,15 +102,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact]
public async Task SignInCausesDefaultCookieToBeCreated()
{
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.LoginPath = new PathString("/login");
options.CookieName = "TestCookie";
}, SignInAsAlice);
- Transaction transaction = await SendAsync(server, "http://example.com/testpath");
+ var transaction = await SendAsync(server, "http://example.com/testpath");
- string setCookie = transaction.SetCookie;
+ var setCookie = transaction.SetCookie;
setCookie.ShouldStartWith("TestCookie=");
setCookie.ShouldContain("; path=/");
setCookie.ShouldContain("; HttpOnly");
@@ -122,7 +122,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact]
public async Task SignInWrongAuthTypeThrows()
{
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.LoginPath = new PathString("/login");
options.CookieName = "TestCookie";
@@ -134,7 +134,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
[Fact]
public async Task SignOutWrongAuthTypeThrows()
{
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.LoginPath = new PathString("/login");
options.CookieName = "TestCookie";
@@ -155,15 +155,15 @@ namespace Microsoft.AspNet.Authentication.Cookies
string requestUri,
bool shouldBeSecureOnly)
{
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.LoginPath = new PathString("/login");
options.CookieName = "TestCookie";
options.CookieSecure = cookieSecureOption;
}, SignInAsAlice);
- Transaction transaction = await SendAsync(server, requestUri);
- string setCookie = transaction.SetCookie;
+ var transaction = await SendAsync(server, requestUri);
+ var setCookie = transaction.SetCookie;
if (shouldBeSecureOnly)
{
@@ -187,9 +187,9 @@ namespace Microsoft.AspNet.Authentication.Cookies
options.CookieHttpOnly = true;
}, SignInAsAlice, new Uri("http://example.com/base"));
- Transaction transaction1 = await SendAsync(server1, "http://example.com/base/testpath");
+ var transaction1 = await SendAsync(server1, "http://example.com/base/testpath");
- string setCookie1 = transaction1.SetCookie;
+ var setCookie1 = transaction1.SetCookie;
setCookie1.ShouldContain("TestCookie=");
setCookie1.ShouldContain(" path=/foo");
@@ -197,16 +197,16 @@ namespace Microsoft.AspNet.Authentication.Cookies
setCookie1.ShouldContain(" secure");
setCookie1.ShouldContain(" HttpOnly");
- TestServer server2 = CreateServer(options =>
+ var server2 = CreateServer(options =>
{
options.CookieName = "SecondCookie";
options.CookieSecure = CookieSecureOption.Never;
options.CookieHttpOnly = false;
}, SignInAsAlice, new Uri("http://example.com/base"));
- Transaction transaction2 = await SendAsync(server2, "http://example.com/base/testpath");
+ var transaction2 = await SendAsync(server2, "http://example.com/base/testpath");
- string setCookie2 = transaction2.SetCookie;
+ var setCookie2 = transaction2.SetCookie;
setCookie2.ShouldContain("SecondCookie=");
setCookie2.ShouldContain(" path=/base");
@@ -219,14 +219,14 @@ namespace Microsoft.AspNet.Authentication.Cookies
public async Task CookieContainsIdentity()
{
var clock = new TestClock();
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.SystemClock = clock;
}, SignInAsAlice);
- Transaction transaction1 = await SendAsync(server, "http://example.com/testpath");
+ var transaction1 = await SendAsync(server, "http://example.com/testpath");
- Transaction transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
+ var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
FindClaimValue(transaction2, ClaimTypes.Name).ShouldBe("Alice");
}
@@ -235,7 +235,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
public async Task CookieAppliesClaimsTransform()
{
var clock = new TestClock();
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.SystemClock = clock;
},
@@ -253,9 +253,9 @@ namespace Microsoft.AspNet.Authentication.Cookies
return p;
}));
- Transaction transaction1 = await SendAsync(server, "http://example.com/testpath");
+ var transaction1 = await SendAsync(server, "http://example.com/testpath");
- Transaction transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
+ var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
FindClaimValue(transaction2, ClaimTypes.Name).ShouldBe("Alice");
FindClaimValue(transaction2, "xform").ShouldBe("yup");
@@ -266,24 +266,24 @@ namespace Microsoft.AspNet.Authentication.Cookies
public async Task CookieStopsWorkingAfterExpiration()
{
var clock = new TestClock();
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.SystemClock = clock;
options.ExpireTimeSpan = TimeSpan.FromMinutes(10);
options.SlidingExpiration = false;
}, SignInAsAlice);
- Transaction transaction1 = await SendAsync(server, "http://example.com/testpath");
+ var transaction1 = await SendAsync(server, "http://example.com/testpath");
- Transaction transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
+ var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
clock.Add(TimeSpan.FromMinutes(7));
- Transaction transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
+ var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
clock.Add(TimeSpan.FromMinutes(7));
- Transaction transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
+ var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue);
transaction2.SetCookie.ShouldBe(null);
FindClaimValue(transaction2, ClaimTypes.Name).ShouldBe("Alice");
@@ -297,7 +297,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
public async Task CookieExpirationCanBeOverridenInSignin()
{
var clock = new TestClock();
- TestServer server = CreateServer(options =>
+ var server = CreateServer(options =>
{
options.SystemClock = clock;
options.ExpireTimeSpan = TimeSpan.FromMinutes(10);
@@ -311,17 +311,17 @@ namespace Microsoft.AspNet.Authentication.Cookies
return Task.FromResult