From a8f6f1bcfa9d7637920db9741876a7424e933ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rune=20T=C3=B8mmer=C3=A5s=20Larsen?= Date: Tue, 13 Dec 2022 16:54:42 +0100 Subject: [PATCH] Fixed path and autohandling of running access management (#9400) --- src/Controllers/HomeController.cs | 5 +++ .../LocalApp/Implementation/LocalAppFile.cs | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/Controllers/HomeController.cs b/src/Controllers/HomeController.cs index dcd8f1ff..aae1c814 100644 --- a/src/Controllers/HomeController.cs +++ b/src/Controllers/HomeController.cs @@ -118,6 +118,11 @@ public async Task LogInTestUser(StartAppModel startAppModel) CreateJwtCookieAndAppendToResponse(token); } + if (startAppModel.AppPathSelection.Equals("accessmanagement")) + { + return Redirect($"/accessmanagement/ui/api-delegations"); + } + Application app = await _localApp.GetApplicationMetadata(startAppModel.AppPathSelection); // Ensure that the documentstorage in LocalTestingStorageBasePath is updated with the most recent app data diff --git a/src/Services/LocalApp/Implementation/LocalAppFile.cs b/src/Services/LocalApp/Implementation/LocalAppFile.cs index c15e3678..96dd9296 100644 --- a/src/Services/LocalApp/Implementation/LocalAppFile.cs +++ b/src/Services/LocalApp/Implementation/LocalAppFile.cs @@ -13,6 +13,8 @@ using LocalTest.Configuration; using LocalTest.Helpers; using LocalTest.Services.LocalApp.Interface; +using System.Net.Http; +using System.Net; namespace LocalTest.Services.LocalApp.Implementation { @@ -44,6 +46,14 @@ public LocalAppFile(IOptions localPlatformSettings) public async Task> GetApplications() { var ret = new Dictionary(); + + Application accessManagement = await GetAccessManagment(); + if (accessManagement != null) + { + ret.Add("accessmanagement", accessManagement); + return ret; + } + // Get list of apps from the configured folder AppRepositoryBasePath string path = _localPlatformSettings.AppRepositoryBasePath; @@ -109,5 +119,28 @@ private string GetAppPath(string appId) { return Path.Join(_localPlatformSettings.AppRepositoryBasePath, appId.Split('/').Last()); } + + private async Task GetAccessManagment() + { + try + { + HttpClient client = new HttpClient(); + client.BaseAddress = new Uri("http://localhost:5117/"); + HttpResponseMessage respnse = await client.GetAsync("swagger/index.html"); + if (respnse.StatusCode.Equals(HttpStatusCode.OK)) + { + Dictionary title = new Dictionary(); + title.Add("nb", "Access Management"); + return new Application() { Id = "accessmanagement/ui", Title = title, Org="ALT" }; + } + + return null; + } + catch (Exception ex) + { + return null; + } + } + } }