Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@ internal ConsentPageResult(
public override async Task ExecuteAsync(HttpContext context)
{
Init(context);
var returnUrl = await BuildReturnUrl(context);

var consentUrl = Options.UserInteraction.ConsentUrl;
if (!consentUrl.IsLocalUrl())
{
// this converts the relative redirect path to an absolute one if we're
// redirecting to a different server
returnUrl = context.GetIdentityServerHost().EnsureTrailingSlash() + returnUrl.RemoveLeadingSlash();
}
var returnUrl = await BuildReturnUrl(context, consentUrl.IsLocalUrl());

var url = consentUrl.AddQueryString(Options.UserInteraction.ConsentReturnUrlParameter, returnUrl);
context.Response.RedirectToAbsoluteUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@ internal CustomRedirectResult(
public override async Task ExecuteAsync(HttpContext context)
{
Init(context);
var returnUrl = await BuildReturnUrl(context);

if (!_url.IsLocalUrl())
{
// this converts the relative redirect path to an absolute one if we're
// redirecting to a different server
returnUrl = context.GetIdentityServerHost().EnsureTrailingSlash() + returnUrl.RemoveLeadingSlash();
}
var returnUrl = await BuildReturnUrl(context, _url.IsLocalUrl());

var url = _url.AddQueryString(Options.UserInteraction.CustomRedirectReturnUrlParameter, returnUrl);
context.Response.RedirectToAbsoluteUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@ internal LoginPageResult(
public override async Task ExecuteAsync(HttpContext context)
{
Init(context);
var returnUrl = await BuildReturnUrl(context);

var loginUrl = Options.UserInteraction.LoginUrl;
if (!loginUrl.IsLocalUrl())
{
// this converts the relative redirect path to an absolute one if we're
// redirecting to a different server
returnUrl = context.GetIdentityServerHost().EnsureTrailingSlash() + returnUrl.RemoveLeadingSlash();
}
var returnUrl = await BuildReturnUrl(context, loginUrl.IsLocalUrl());

var url = loginUrl.AddQueryString(Options.UserInteraction.LoginReturnUrlParameter, returnUrl);
context.Response.RedirectToAbsoluteUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ protected void Init(HttpContext context)
/// Builds a returnUrl using <see cref="IAuthorizationParametersMessageStore"/> if registered, and fallback
/// </summary>
/// <param name="context">The HTTP context.</param>
/// <param name="localUrl">Indicates whether the return URL should be local.</param>
/// <returns>built return url</returns>
protected async Task<string> BuildReturnUrl(HttpContext context)
protected async Task<string> BuildReturnUrl(HttpContext context, bool localUrl)
{
var returnUrl = context.GetIdentityServerBasePath().EnsureTrailingSlash() + Constants.ProtocolRoutePaths.AuthorizeCallback;
if (AuthorizationParametersMessageStore != null)
Expand All @@ -82,6 +83,13 @@ protected async Task<string> BuildReturnUrl(HttpContext context)
returnUrl = returnUrl.AddQueryString(Request.Raw.ToQueryString());
}

if (!localUrl)
{
// this converts the relative redirect path to an absolute one if we're
// redirecting to a different server
returnUrl = context.GetIdentityServerHost().EnsureTrailingSlash() + returnUrl.RemoveLeadingSlash();
}

return returnUrl;
}

Expand Down
Loading