SignOutContext needs AuthenticationProperties
This commit is contained in:
parent
9463b08d7b
commit
58c45cd379
|
|
@ -11,13 +11,16 @@ namespace Microsoft.AspNet.Http.Core.Authentication
|
|||
{
|
||||
private bool _accepted;
|
||||
|
||||
public SignOutContext(string authenticationScheme)
|
||||
public SignOutContext([NotNull] string authenticationScheme, IDictionary<string, string> properties)
|
||||
{
|
||||
AuthenticationScheme = authenticationScheme;
|
||||
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public string AuthenticationScheme { get; }
|
||||
|
||||
public IDictionary<string, string> Properties { get; }
|
||||
|
||||
public bool Accepted
|
||||
{
|
||||
get { return _accepted; }
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<string, string> Properties { get; }
|
||||
|
||||
void Accept();
|
||||
}
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Http
|
|||
|
||||
public virtual void Challenge(IEnumerable<string> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue