Skip to content

Commit

Permalink
Merge pull request #11611 from abpframework/RedirectAllowedUrls
Browse files Browse the repository at this point in the history
Output error log when RedirectUrl is invalid.
  • Loading branch information
realLiangshiwei authored Feb 17, 2022
2 parents 4a000bc + 72ea5b7 commit 12864d1
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit 12864d1

Please sign in to comment.