Reenable external signout

resolved issued with middleware ordering in AddIdentity
This commit is contained in:
Hao Kung 2014-09-25 15:57:22 -07:00
parent c5d3d32445
commit 08c6522bf4
4 changed files with 6 additions and 7 deletions

View File

@ -115,7 +115,7 @@ namespace IdentitySamples
options.Password.RequireLowercase = false;
options.Password.RequireUppercase = false;
options.Password.RequireNonLetterOrDigit = false;
options.SecurityStampValidationInterval = TimeSpan.FromMinutes(1);
options.SecurityStampValidationInterval = TimeSpan.Zero;
});
services.SetupOptions<GoogleAuthenticationOptions>(options =>
{

View File

@ -20,9 +20,9 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException("app");
}
var options = app.ApplicationServices.GetService<IOptionsAccessor<IdentityOptions>>().Options;
app.UseCookieAuthentication(options.ApplicationCookie);
app.SetDefaultSignInAsAuthenticationType(options.DefaultSignInAsAuthenticationType);
app.UseCookieAuthentication(options.ExternalCookie);
app.UseCookieAuthentication(options.ApplicationCookie);
app.UseCookieAuthentication(options.TwoFactorRememberMeCookie);
app.UseCookieAuthentication(options.TwoFactorUserIdCookie);
return app;

View File

@ -75,8 +75,7 @@ namespace Microsoft.AspNet.Identity
{
var userIdentity = await CreateUserIdentityAsync(user);
// Should always clear any external login cookies when signing in for real
// BUG: SignOut currently throws if auth type was not signed in
//Context.Response.SignOut(Options.ExternalCookie.AuthenticationType);
Context.Response.SignOut(Options.ExternalCookie.AuthenticationType);
if (authenticationMethod != null)
{
userIdentity.AddClaim(new Claim(ClaimTypes.AuthenticationMethod, authenticationMethod));

View File

@ -280,7 +280,7 @@ namespace Microsoft.AspNet.Identity.Test
contextAccessor.Setup(a => a.Value).Returns(context.Object);
var roleManager = MockHelpers.MockRoleManager<TestRole>();
var identityOptions = new IdentityOptions();
//response.Setup(r => r.SignOut(identityOptions.ExternalCookie.AuthenticationType)).Verifiable();
response.Setup(r => r.SignOut(identityOptions.ExternalCookie.AuthenticationType)).Verifiable();
var options = new Mock<IOptionsAccessor<IdentityOptions>>();
options.Setup(a => a.Options).Returns(identityOptions);
var claimsFactory = new Mock<ClaimsIdentityFactory<TestUser, TestRole>>(manager.Object, roleManager.Object, options.Object);
@ -365,7 +365,7 @@ namespace Microsoft.AspNet.Identity.Test
It.Is<ClaimsIdentity>(i => i.FindFirstValue(ClaimTypes.Name) == user.Id
&& i.AuthenticationType == ClaimsIdentityOptions.DefaultTwoFactorRememberMeAuthenticationType))).Verifiable();
}
//response.Setup(r => r.SignOut(identityOptions.ExternalCookie.AuthenticationType)).Verifiable();
response.Setup(r => r.SignOut(identityOptions.ExternalCookie.AuthenticationType)).Verifiable();
context.Setup(c => c.Response).Returns(response.Object).Verifiable();
context.Setup(c => c.AuthenticateAsync(ClaimsIdentityOptions.DefaultTwoFactorUserIdAuthenticationType)).ReturnsAsync(authResult).Verifiable();
contextAccessor.Setup(a => a.Value).Returns(context.Object);
@ -449,7 +449,7 @@ namespace Microsoft.AspNet.Identity.Test
contextAccessor.Setup(a => a.Value).Returns(context.Object);
var roleManager = MockHelpers.MockRoleManager<TestRole>();
var identityOptions = new IdentityOptions();
//response.Setup(r => r.SignOut(identityOptions.ExternalCookie.AuthenticationType)).Verifiable();
response.Setup(r => r.SignOut(identityOptions.ExternalCookie.AuthenticationType)).Verifiable();
var options = new Mock<IOptionsAccessor<IdentityOptions>>();
options.Setup(a => a.Options).Returns(identityOptions);
var claimsFactory = new Mock<ClaimsIdentityFactory<TestUser, TestRole>>(manager.Object, roleManager.Object, options.Object);