mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-05-04 12:02:52 +08:00
38 lines
1.2 KiB
C#
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;
|
|
};
|
|
}
|
|
}
|