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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var loginUri = string.Empty;
|
var redirectUri = string.Empty;
|
||||||
if (ChallengeContext != null)
|
if (ChallengeContext != null)
|
||||||
{
|
{
|
||||||
loginUri = new AuthenticationProperties(ChallengeContext.Properties).RedirectUri;
|
redirectUri = new AuthenticationProperties(ChallengeContext.Properties).RedirectUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(loginUri))
|
if (string.IsNullOrWhiteSpace(redirectUri))
|
||||||
{
|
{
|
||||||
var currentUri =
|
redirectUri =
|
||||||
Request.PathBase +
|
Request.PathBase +
|
||||||
Request.Path +
|
Request.Path +
|
||||||
Request.QueryString;
|
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);
|
var redirectContext = new CookieApplyRedirectContext(Context, Options, loginUri);
|
||||||
Options.Notifications.ApplyRedirect(redirectContext);
|
Options.Notifications.ApplyRedirect(redirectContext);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(true)]
|
[InlineData(true)]
|
||||||
[InlineData(false)]
|
[InlineData(false)]
|
||||||
public async Task ProtectedCustomRequestShouldRedirectToCustomLogin(bool auto)
|
public async Task ProtectedCustomRequestShouldRedirectToCustomRedirectUri(bool auto)
|
||||||
{
|
{
|
||||||
var server = CreateServer(options =>
|
var server = CreateServer(options =>
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Authentication.Cookies
|
||||||
if (auto)
|
if (auto)
|
||||||
{
|
{
|
||||||
Uri location = transaction.Response.Headers.Location;
|
Uri location = transaction.Response.Headers.Location;
|
||||||
location.ToString().ShouldBe("/CustomRedirect");
|
location.ToString().ShouldBe("http://example.com/login?ReturnUrl=%2FCustomRedirect");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue