Skip to content

Commit ef5ab43

Browse files
authored
Use redirect helper (#22847)
1 parent 11fb7b6 commit ef5ab43

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/Security/Authentication/Core/src/RemoteAuthenticationHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ protected virtual async Task<HandleRequestResult> HandleAccessDeniedErrorAsync(A
276276
{
277277
uri = QueryHelpers.AddQueryString(uri, context.ReturnUrlParameter, context.ReturnUrl);
278278
}
279-
Response.Redirect(uri);
279+
Response.Redirect(BuildRedirectUri(uri));
280280

281281
return HandleRequestResult.Handle();
282282
}

src/Security/Authentication/test/GoogleTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public async Task ReplyPathWithAccessDeniedError_AllowsCustomizingPath()
417417
var transaction = await server.SendAsync("https://example.com/signin-google?error=access_denied&error_description=SoBad&error_uri=foobar&state=protected_state",
418418
".AspNetCore.Correlation.Google.correlationId=N");
419419
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
420-
Assert.Equal("/custom-denied-page?rurl=http%3A%2F%2Fwww.google.com%2F", transaction.Response.Headers.GetValues("Location").First());
420+
Assert.Equal("https://example.com/custom-denied-page?rurl=http%3A%2F%2Fwww.google.com%2F", transaction.Response.Headers.GetValues("Location").First());
421421
}
422422

423423
[Fact]

src/Security/Authentication/test/OAuthTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public async Task HandleRequestAsync_RedirectsToAccessDeniedPathWhenExplicitlySe
274274
".AspNetCore.Correlation.Weblie.correlationId=N");
275275

276276
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
277-
Assert.Equal("/access-denied?ReturnUrl=http%3A%2F%2Ftesthost%2Fredirect", transaction.Response.Headers.Location.ToString());
277+
Assert.Equal("https://www.example.com/access-denied?ReturnUrl=http%3A%2F%2Ftesthost%2Fredirect", transaction.Response.Headers.Location.ToString());
278278
}
279279

280280
[Fact]

src/Security/Authentication/test/TwitterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public async Task HandleRequestAsync_RedirectsToAccessDeniedPathWhenExplicitlySe
211211
var response = await client.SendAsync(request);
212212

213213
Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
214-
Assert.Equal("/access-denied?ReturnUrl=%2Fchallenge", response.Headers.Location.ToString());
214+
Assert.Equal("http://localhost/access-denied?ReturnUrl=%2Fchallenge", response.Headers.Location.ToString());
215215
}
216216

217217
[Fact]

0 commit comments

Comments
 (0)