Skip to content

Commit

Permalink
Fixed path and autohandling of running access management (#9400)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechArch authored Dec 13, 2022
1 parent 354baa1 commit a8f6f1b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public async Task<ActionResult> 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
Expand Down
33 changes: 33 additions & 0 deletions src/Services/LocalApp/Implementation/LocalAppFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -44,6 +46,14 @@ public LocalAppFile(IOptions<LocalPlatformSettings> localPlatformSettings)
public async Task<Dictionary<string, Application>> GetApplications()
{
var ret = new Dictionary<string, Application>();

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;

Expand Down Expand Up @@ -109,5 +119,28 @@ private string GetAppPath(string appId)
{
return Path.Join(_localPlatformSettings.AppRepositoryBasePath, appId.Split('/').Last());
}

private async Task<Application> 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<string, string> title = new Dictionary<string, string>();
title.Add("nb", "Access Management");
return new Application() { Id = "accessmanagement/ui", Title = title, Org="ALT" };
}

return null;
}
catch (Exception ex)
{
return null;
}
}

}
}

0 comments on commit a8f6f1b

Please sign in to comment.