diff --git a/src/Microsoft.AspNet.Http.Core/Authentication/SignOutContext.cs b/src/Microsoft.AspNet.Http.Core/Authentication/SignOutContext.cs index 2abccf3cfb..3676102e03 100644 --- a/src/Microsoft.AspNet.Http.Core/Authentication/SignOutContext.cs +++ b/src/Microsoft.AspNet.Http.Core/Authentication/SignOutContext.cs @@ -11,13 +11,16 @@ namespace Microsoft.AspNet.Http.Core.Authentication { private bool _accepted; - public SignOutContext(string authenticationScheme) + public SignOutContext([NotNull] string authenticationScheme, IDictionary properties) { AuthenticationScheme = authenticationScheme; + Properties = properties ?? new Dictionary(StringComparer.Ordinal); } public string AuthenticationScheme { get; } + public IDictionary Properties { get; } + public bool Accepted { get { return _accepted; } diff --git a/src/Microsoft.AspNet.Http.Core/DefaultHttpResponse.cs b/src/Microsoft.AspNet.Http.Core/DefaultHttpResponse.cs index ff1fa8e0ae..fd2dab86ed 100644 --- a/src/Microsoft.AspNet.Http.Core/DefaultHttpResponse.cs +++ b/src/Microsoft.AspNet.Http.Core/DefaultHttpResponse.cs @@ -7,13 +7,11 @@ using System.IO; using System.Linq; using System.Security.Claims; using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNet.Http.Core.Authentication; using Microsoft.AspNet.Http.Core.Collections; using Microsoft.AspNet.Http.Core.Infrastructure; -using Microsoft.AspNet.Http.Core.Authentication; using Microsoft.AspNet.Http.Infrastructure; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Authentication; -using Microsoft.AspNet.Http.Authentication; namespace Microsoft.AspNet.Http.Core { @@ -162,11 +160,11 @@ namespace Microsoft.AspNet.Http.Core } } - public override void SignOut(string authenticationScheme) + public override void SignOut(string authenticationScheme, AuthenticationProperties properties) { var handler = HttpAuthenticationFeature.Handler; - var signOutContext = new SignOutContext(authenticationScheme); + var signOutContext = new SignOutContext(authenticationScheme, properties?.Dictionary); if (handler != null) { handler.SignOut(signOutContext); @@ -178,5 +176,10 @@ namespace Microsoft.AspNet.Http.Core throw new InvalidOperationException("The following authentication scheme was not accepted: " + authenticationScheme); } } + + public override void SignOut(string authenticationScheme) + { + SignOut(authenticationScheme, properties: null); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Http.Interfaces/Security/ISignOutContext.cs b/src/Microsoft.AspNet.Http.Interfaces/Security/ISignOutContext.cs index 4fbca12a3a..2bb7036026 100644 --- a/src/Microsoft.AspNet.Http.Interfaces/Security/ISignOutContext.cs +++ b/src/Microsoft.AspNet.Http.Interfaces/Security/ISignOutContext.cs @@ -1,12 +1,16 @@ // 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; + namespace Microsoft.AspNet.Http.Authentication { public interface ISignOutContext { string AuthenticationScheme { get; } + IDictionary Properties { get; } + void Accept(); } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Http/HttpResponse.cs b/src/Microsoft.AspNet.Http/HttpResponse.cs index 047b09825d..85dec115e7 100644 --- a/src/Microsoft.AspNet.Http/HttpResponse.cs +++ b/src/Microsoft.AspNet.Http/HttpResponse.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Http public virtual void Challenge(IEnumerable authenticationSchemes) { - Challenge(properties: null, authenticationSchemes: authenticationSchemes); + Challenge(properties: null, authenticationSchemes: authenticationSchemes); } public virtual void Challenge(AuthenticationProperties properties, params string[] authenticationSchemes) @@ -75,9 +75,11 @@ namespace Microsoft.AspNet.Http public virtual void SignOut() { - SignOut(authenticationScheme: null); + SignOut(authenticationScheme: null, properties: null); } public abstract void SignOut(string authenticationScheme); + + public abstract void SignOut(string authenticationScheme, AuthenticationProperties properties); } } diff --git a/test/Microsoft.AspNet.Http.Core.Tests/DefaultHttpContextTests.cs b/test/Microsoft.AspNet.Http.Core.Tests/DefaultHttpContextTests.cs index 0393392f1b..02b040af69 100644 --- a/test/Microsoft.AspNet.Http.Core.Tests/DefaultHttpContextTests.cs +++ b/test/Microsoft.AspNet.Http.Core.Tests/DefaultHttpContextTests.cs @@ -90,6 +90,8 @@ namespace Microsoft.AspNet.Http.Core.Tests Assert.False(handler.SignedIn); context.Response.SignIn("ignored", user); Assert.True(handler.SignedIn); + context.Response.SignOut("ignored", new AuthenticationProperties() { RedirectUri = "~/logout" }); + Assert.False(handler.SignedIn); } private class AuthHandler : IAuthenticationHandler