Ocelot/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs
EL Aisati Ahmed 157737ef01 Revert "Merge branch 'feature/issue#1088'"
This reverts commit 914a386b0e79612a832a0ddc4c1b7fda7e8cf4a2.
2020-02-04 18:12:00 +01:00

38 lines
1.2 KiB
C#

namespace Ocelot.Administration
{
using Configuration.Repository;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Middleware;
using System.Threading.Tasks;
public static class IdentityServerMiddlewareConfigurationProvider
{
public static OcelotMiddlewareConfigurationDelegate Get = builder =>
{
var internalConfigRepo = builder.ApplicationServices.GetService<IInternalConfigurationRepository>();
var config = internalConfigRepo.Get();
if (!string.IsNullOrEmpty(config.Data.AdministrationPath))
{
builder.Map(config.Data.AdministrationPath, app =>
{
//todo - hack so we know that we are using internal identity server
var identityServerConfiguration = builder.ApplicationServices.GetService<IIdentityServerConfiguration>();
if (identityServerConfiguration != null)
{
app.UseIdentityServer();
}
app.UseAuthentication();
app.UseMvc();
});
}
return Task.CompletedTask;
};
}
}