Fix invalid challenge in CookieAuthenticationHandler.ApplyResponseChallenge
This commit is contained in:
parent
6f935f8e28
commit
c6230f5de2
|
|
@ -363,30 +363,30 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
return;
|
||||
}
|
||||
|
||||
var loginUri = string.Empty;
|
||||
var redirectUri = string.Empty;
|
||||
if (ChallengeContext != null)
|
||||
{
|
||||
loginUri = new AuthenticationProperties(ChallengeContext.Properties).RedirectUri;
|
||||
redirectUri = new AuthenticationProperties(ChallengeContext.Properties).RedirectUri;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(loginUri))
|
||||
if (string.IsNullOrWhiteSpace(redirectUri))
|
||||
{
|
||||
var currentUri =
|
||||
redirectUri =
|
||||
Request.PathBase +
|
||||
Request.Path +
|
||||
Request.QueryString;
|
||||
|
||||
loginUri =
|
||||
Request.Scheme +
|
||||
"://" +
|
||||
Request.Host +
|
||||
Request.PathBase +
|
||||
Options.LoginPath +
|
||||
QueryString.Create(Options.ReturnUrlParameter, currentUri);
|
||||
}
|
||||
|
||||
var loginUri =
|
||||
Request.Scheme +
|
||||
"://" +
|
||||
Request.Host +
|
||||
Request.PathBase +
|
||||
Options.LoginPath +
|
||||
QueryString.Create(Options.ReturnUrlParameter, redirectUri);
|
||||
|
||||
var redirectContext = new CookieApplyRedirectContext(Context, Options, loginUri);
|
||||
Options.Notifications.ApplyRedirect(redirectContext);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task ProtectedCustomRequestShouldRedirectToCustomLogin(bool auto)
|
||||
public async Task ProtectedCustomRequestShouldRedirectToCustomRedirectUri(bool auto)
|
||||
{
|
||||
var server = CreateServer(options =>
|
||||
{
|
||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
|||
if (auto)
|
||||
{
|
||||
Uri location = transaction.Response.Headers.Location;
|
||||
location.ToString().ShouldBe("/CustomRedirect");
|
||||
location.ToString().ShouldBe("http://example.com/login?ReturnUrl=%2FCustomRedirect");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue