Skip to content

Commit 77e7fda

Browse files
redirect to other ms urls from returnUrl
1 parent 4860394 commit 77e7fda

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

Olive.Microservices/Microservice.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ public class Microservice
66
{
77
string _baseUrl, _baseResourceUrl, _baseS3BucketUrl, _accessKey;
88

9-
string BaseUrl =>
10-
_baseUrl ??= Config.GetOrThrow("Microservice:" + Name + ":Url").EnsureEndsWith("/");
11-
129
string BaseResourceUrl
1310
{
1411
get
@@ -36,6 +33,9 @@ string BaseResourceUrl
3633
_baseUrl = url;
3734
}
3835

36+
public string BaseUrl =>
37+
_baseUrl ??= Config.GetOrThrow("Microservice:" + Name + ":Url").EnsureEndsWith("/");
38+
3939
public string Name { get; private set; }
4040
public string Icon => Config.Get("Microservice:" + Name + ":icon").Or(Config.Get("Microservice:" + Name + ":Icon"));
4141
public bool Sso => Config.Get("Microservice:" + Name + ":Sso")?.ToLower() == "true";

Olive.Microservices/Olive.Microservices.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netstandard2.0</TargetFramework>
4-
<Version>8.0.4</Version>
4+
<Version>8.0.5</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

Olive.Mvc/Extentions/Extensions.UrlHelpers.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,15 @@ public static string ReturnUrl(this IUrlHelper @this)
9696
if (url.StartsWith("..."))
9797
url = url.FromSafeZippedUrl();
9898

99-
if (!@this.IsLocalUrl(url))
99+
if (!@this.IsLocalUrl(url) && !@this.IsMicroserviceUrl(url))
100100
throw new Exception(url + " is not a valid ReturnUrl as it's external and so unsafe.");
101101

102102
return url;
103103
}
104+
public static bool IsMicroserviceUrl(this IUrlHelper @this, string url)
105+
{
106+
return AllMicroservices.GetServices().Any(s => url.StartsWith(s.BaseUrl, StringComparison.OrdinalIgnoreCase));
107+
}
104108

105109
/// <summary>
106110
/// Returns the specified actionUrl. But it first adds the current route and query string query parameters, all as query string.

Olive.Mvc/Olive.Mvc.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
4-
<Version>8.1.5</Version>
4+
<Version>8.1.6</Version>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -11,6 +11,7 @@
1111
<ItemGroup>
1212
<ProjectReference Include="..\Olive.Audit\Olive.Audit.csproj" />
1313
<ProjectReference Include="..\Olive.Entities.Data\Olive.Entities.Data.csproj" />
14+
<ProjectReference Include="..\Olive.Microservices\Olive.Microservices.csproj" />
1415
<ProjectReference Include="..\Olive.Mvc.Security\Olive.Mvc.Security.csproj" />
1516
<ProjectReference Include="..\Olive\Olive.csproj" />
1617
</ItemGroup>

0 commit comments

Comments
 (0)