Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output error log when RedirectUrl is invalid. #11611

Merged
merged 1 commit into from
Feb 17, 2022
Merged
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 @@ -3,6 +3,8 @@
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
Expand All @@ -18,6 +20,8 @@ public class AppUrlProvider : IAppUrlProvider, ITransientDependency
protected ICurrentTenant CurrentTenant { get; }
protected ITenantStore TenantStore { get; }

public ILogger<AppUrlProvider> Logger { get; set; }

public AppUrlProvider(
IOptions<AppUrlOptions> options,
ICurrentTenant currentTenant,
Expand All @@ -26,6 +30,7 @@ public AppUrlProvider(
CurrentTenant = currentTenant;
TenantStore = tenantStore;
Options = options.Value;
Logger = NullLogger<AppUrlProvider>.Instance;
}

public virtual async Task<string> GetUrlAsync(string appName, string urlName = null)
Expand All @@ -40,7 +45,12 @@ await GetConfiguredUrl(

public bool IsRedirectAllowedUrl(string url)
{
return Options.RedirectAllowedUrls.Any(url.StartsWith);
var allow = Options.RedirectAllowedUrls.Any(url.StartsWith);
if (!allow)
{
Logger.LogError($"Invalid RedirectUrl: {url}, Use {nameof(AppUrlProvider)} to configure it!");
}
return allow;
}

protected virtual async Task<string> GetConfiguredUrl(string appName, string urlName)
Expand Down