diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Configuration/AdminConfiguration.cs b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Configuration/AdminConfiguration.cs index 7ee9664757340d18c14f11d3b29a391b1e4da592..700901de76ae73d60170dafc474c82c6cf5e08e1 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Configuration/AdminConfiguration.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Configuration/AdminConfiguration.cs @@ -5,7 +5,11 @@ public class AdminConfiguration public string PageTitle { get; set; } public string HomePageLogoUri { get; set; } public string FaviconUri { get; set; } - public string IdentityAdminBaseUrl { get; set; } + public string IdentityAdminBasePath { get; set; } + public string WebAdminBasePath { get; set; } + public string ProxyServerUrl { get; set; } + public string IdentityAdminBaseUrl => ProxyServerUrl + IdentityAdminBasePath; + public string WebAdminBaseUrl => ProxyServerUrl + WebAdminBasePath; public string AdministrationRole { get; set; } public string Theme { get; set; } diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/ViewComponents/IdentityServerAdminLinkViewComponent.cs b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/ViewComponents/IdentityServerAdminLinkViewComponent.cs index 003165d1b369a12c52349db8fa56b3fe766f97df..0bcbe42bab295e7641a838b5c0b46f1744010ba7 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/ViewComponents/IdentityServerAdminLinkViewComponent.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/ViewComponents/IdentityServerAdminLinkViewComponent.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using Idsrv4.Admin.STS.Identity.Configuration.Interfaces; namespace Idsrv4.Admin.STS.Identity.ViewComponents; @@ -14,8 +13,6 @@ public class IdentityServerAdminLinkViewComponent : ViewComponent public IViewComponentResult Invoke() { - var identityAdminUrl = _configuration.AdminConfiguration.IdentityAdminBaseUrl; - - return View(model: identityAdminUrl); + return View(model: _configuration.AdminConfiguration.IdentityAdminBaseUrl); } } \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/ViewComponents/WebAdminLinkViewComponent.cs b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/ViewComponents/WebAdminLinkViewComponent.cs new file mode 100644 index 0000000000000000000000000000000000000000..7c3f37f706c8bbd1185d55800473d7e437fab798 --- /dev/null +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/ViewComponents/WebAdminLinkViewComponent.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Idsrv4.Admin.STS.Identity.ViewComponents; + +public class WebAdminLinkViewComponent : ViewComponent +{ + private readonly IRootConfiguration _configuration; + + public WebAdminLinkViewComponent(IRootConfiguration configuration) + { + _configuration = configuration; + } + + public IViewComponentResult Invoke() + { + return View(model: _configuration.AdminConfiguration.WebAdminBaseUrl); + } +} \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Views/Shared/Components/WebAdminLink/Default.cshtml b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Views/Shared/Components/WebAdminLink/Default.cshtml new file mode 100644 index 0000000000000000000000000000000000000000..cc64cdf5ac5109870f2e568f7c686f29101d1299 --- /dev/null +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Views/Shared/Components/WebAdminLink/Default.cshtml @@ -0,0 +1,10 @@ +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Mvc.Localization +@using Idsrv4.Admin.STS.Identity.Configuration.Constants +@model string +@inject IAuthorizationService AuthorizationService + +@if ((await AuthorizationService.AuthorizeAsync(User, AuthorizationConsts.AdministrationPolicy)).Succeeded) +{ + WebAdmin +} \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Views/Shared/_Layout.cshtml b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Views/Shared/_Layout.cshtml index 384ed9aa142d06f2c408afce7d349ce1a523f573..b2b6e97ee59be1d29dff5430d805f0ded205c2c2 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Views/Shared/_Layout.cshtml +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Views/Shared/_Layout.cshtml @@ -55,6 +55,9 @@ @if (User.Identity.IsAuthenticated && !string.IsNullOrEmpty(name)) { + + + diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json index d80a55dc92a729ffb715aefe1d9cf7f507230579..6f885bc4dd342dbf311b90f7d9a772f93b83ba69 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json @@ -66,7 +66,9 @@ "FaviconUri": "~/favicon.ico", "Theme": null, "CustomThemeCss": null, - "IdentityAdminBaseUrl": "https://localhost:44303/auth/admin", + "IdentityAdminBasePath": "/auth/admin", + "WebAdminBasePath": "/admin", + "ProxyServerUrl": "https://localhost:44444", "AdministrationRole": "Administrator" }, "CspTrustedDomains": [ diff --git a/src/IdentityServer4/src/Idsrv4.Admin.UI/Areas/AdminUI/Views/Shared/Components/WebAdminLink/Default.cshtml b/src/IdentityServer4/src/Idsrv4.Admin.UI/Areas/AdminUI/Views/Shared/Components/WebAdminLink/Default.cshtml new file mode 100644 index 0000000000000000000000000000000000000000..f4f35c8e9d979fb8b4957159591cee8d3b177723 --- /dev/null +++ b/src/IdentityServer4/src/Idsrv4.Admin.UI/Areas/AdminUI/Views/Shared/Components/WebAdminLink/Default.cshtml @@ -0,0 +1,3 @@ +@model string + +WebAdmin \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.UI/Areas/AdminUI/Views/Shared/_Layout.cshtml b/src/IdentityServer4/src/Idsrv4.Admin.UI/Areas/AdminUI/Views/Shared/_Layout.cshtml index 9eec873f20c5b763ba673479d954eaec9a52bb18..eae5db6025fa79f9ae235e6aff1db8301bdc62ca 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.UI/Areas/AdminUI/Views/Shared/_Layout.cshtml +++ b/src/IdentityServer4/src/Idsrv4.Admin.UI/Areas/AdminUI/Views/Shared/_Layout.cshtml @@ -40,6 +40,9 @@ + + + diff --git a/src/IdentityServer4/src/Idsrv4.Admin.UI/Configuration/AdminConfiguration.cs b/src/IdentityServer4/src/Idsrv4.Admin.UI/Configuration/AdminConfiguration.cs index d343e7a7745ae73d8cd77e9ed4c8c128e22c0a01..90abd931be8eb6190b541eb0c07ff13a075eba4b 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.UI/Configuration/AdminConfiguration.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.UI/Configuration/AdminConfiguration.cs @@ -4,7 +4,6 @@ public class AdminConfiguration { public string PageTitle { get; set; } public string FaviconUri { get; set; } - public string IdentityAdminRedirectUri { get; set; } public string[] Scopes { get; set; } public string AdministrationRole { get; set; } public bool RequireHttpsMetadata { get; set; } @@ -12,12 +11,17 @@ public class AdminConfiguration public double IdentityAdminCookieExpiresUtcHours { get; set; } public string TokenValidationClaimName { get; set; } public string TokenValidationClaimRole { get; set; } - public string IdentityServerBaseUrl { get; set; } + public string IdentityAdminRedirectPath { get; set; } + public string IdentityServerBasePath { get; set; } + public string WebAdminBasePath { get; set; } + public string ProxyServerUrl { get; set; } + public string IdentityServerBaseUrl => ProxyServerUrl + IdentityServerBasePath; + public string WebAdminBaseUrl => ProxyServerUrl + WebAdminBasePath; + public string IdentityAdminRedirectUri => ProxyServerUrl + IdentityAdminRedirectPath; public string ClientId { get; set; } public string ClientSecret { get; set; } public string OidcResponseType { get; set; } public bool HideUIForMSSqlErrorLogging { get; set; } public string Theme { get; set; } - public string CustomThemeCss { get; set; } } \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.UI/ViewComponents/IdentityServerLinkViewComponent.cs b/src/IdentityServer4/src/Idsrv4.Admin.UI/ViewComponents/IdentityServerLinkViewComponent.cs index 7246e5ffa8c21b0b8a9e34ac896724d0eb5591eb..de7550f054342e91772f539b568452afe6df995a 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.UI/ViewComponents/IdentityServerLinkViewComponent.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.UI/ViewComponents/IdentityServerLinkViewComponent.cs @@ -14,8 +14,6 @@ public class IdentityServerLinkViewComponent : ViewComponent public IViewComponentResult Invoke() { - var identityServerUrl = _configuration.IdentityServerBaseUrl; - - return View(model: identityServerUrl); + return View(model: _configuration.IdentityServerBaseUrl); } -} \ No newline at end of file +} diff --git a/src/IdentityServer4/src/Idsrv4.Admin.UI/ViewComponents/WebAdminLinkViewComponent.cs b/src/IdentityServer4/src/Idsrv4.Admin.UI/ViewComponents/WebAdminLinkViewComponent.cs new file mode 100644 index 0000000000000000000000000000000000000000..f4cde4b213cad4d1de4853eec8f7d20e2fd43812 --- /dev/null +++ b/src/IdentityServer4/src/Idsrv4.Admin.UI/ViewComponents/WebAdminLinkViewComponent.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Mvc; +using Idsrv4.Admin.UI.Configuration; + +namespace Idsrv4.Admin.UI.ViewComponents; + +public class WebAdminLinkViewComponent : ViewComponent +{ + private readonly AdminConfiguration _configuration; + + public WebAdminLinkViewComponent(AdminConfiguration configuration) + { + _configuration = configuration; + } + + public IViewComponentResult Invoke() + { + return View(model: _configuration.WebAdminBaseUrl); + } +} \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json b/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json index 5ec2ec256047d3b25ed387fa8e2988475a1a2b20..ec0a33b2825be3630334fd4b00d00213b6abe2fb 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json +++ b/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json @@ -19,8 +19,10 @@ "AdminConfiguration": { "PageTitle": "IdentityServer4 Admin", "FaviconUri": "~/favicon.ico", - "IdentityAdminRedirectUri": "https://localhost:44444/auth/admin/signin-oidc", - "IdentityServerBaseUrl": "https://localhost:44444/auth", + "IdentityAdminRedirectPath": "/auth/admin/signin-oidc", + "IdentityServerBasePath": "/auth", + "WebAdminBasePath": "/admin", + "ProxyServerUrl": "https://localhost:44444", "IdentityAdminCookieName": "IdentityServerAdmin", "IdentityAdminCookieExpiresUtcHours": 12, "RequireHttpsMetadata": false,