mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-10-31 14:45:28 +08:00 
			
		
		
		
	tidy up and no longer hard code admin area...still one int test failing before we start looking at rebuilding auth stuff
This commit is contained in:
		| @@ -147,13 +147,13 @@ namespace Ocelot.DependencyInjection | ||||
|  | ||||
|             if (identityServerConfiguration != null) | ||||
|             { | ||||
|                 services.AddIdentityServer(identityServerConfiguration); | ||||
|                 services.AddIdentityServer(identityServerConfiguration, configurationRoot); | ||||
|             } | ||||
|  | ||||
|             return services; | ||||
|         } | ||||
|  | ||||
|         private static void AddIdentityServer(this IServiceCollection services, IIdentityServerConfiguration identityServerConfiguration)  | ||||
|         private static void AddIdentityServer(this IServiceCollection services, IIdentityServerConfiguration identityServerConfiguration, IConfigurationRoot configurationRoot)  | ||||
|         { | ||||
|             services.TryAddSingleton<IIdentityServerConfiguration>(identityServerConfiguration); | ||||
|             services.TryAddSingleton<IHashMatcher, HashMatcher>(); | ||||
| @@ -172,8 +172,8 @@ namespace Ocelot.DependencyInjection | ||||
|             services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme) | ||||
|                 .AddIdentityServerAuthentication(o => | ||||
|                 { | ||||
|                     //todo - this needs to come from the config so have to get it in here... | ||||
|                     o.Authority = baseSchemeUrlAndPort + "/administration"; | ||||
|                     var adminPath = configurationRoot.GetValue("GlobalConfiguration:AdministrationPath", string.Empty); | ||||
|                     o.Authority = baseSchemeUrlAndPort + adminPath; | ||||
|                     o.ApiName = identityServerConfiguration.ApiName; | ||||
|                     o.RequireHttpsMetadata = identityServerConfiguration.RequireHttps; | ||||
|                     o.SupportedTokens = SupportedTokens.Both; | ||||
|   | ||||
| @@ -41,9 +41,9 @@ namespace Ocelot.Middleware | ||||
|         /// </summary> | ||||
|         /// <param name="builder"></param> | ||||
|         /// <returns></returns> | ||||
|         public static async Task<IApplicationBuilder> UseOcelot(this IApplicationBuilder builder, IServiceCollection services) | ||||
|         public static async Task<IApplicationBuilder> UseOcelot(this IApplicationBuilder builder) | ||||
|         { | ||||
|             await builder.UseOcelot(new OcelotMiddlewareConfiguration(), services); | ||||
|             await builder.UseOcelot(new OcelotMiddlewareConfiguration()); | ||||
|  | ||||
|             return builder; | ||||
|         } | ||||
| @@ -54,9 +54,9 @@ namespace Ocelot.Middleware | ||||
|         /// <param name="builder"></param> | ||||
|         /// <param name="middlewareConfiguration"></param> | ||||
|         /// <returns></returns> | ||||
|         public static async Task<IApplicationBuilder> UseOcelot(this IApplicationBuilder builder, OcelotMiddlewareConfiguration middlewareConfiguration, IServiceCollection services) | ||||
|         public static async Task<IApplicationBuilder> UseOcelot(this IApplicationBuilder builder, OcelotMiddlewareConfiguration middlewareConfiguration) | ||||
|         { | ||||
|             await CreateAdministrationArea(builder, services); | ||||
|             await CreateAdministrationArea(builder); | ||||
|  | ||||
|             ConfigureDiagnosticListener(builder); | ||||
|  | ||||
| @@ -173,7 +173,7 @@ namespace Ocelot.Middleware | ||||
|             return ocelotConfiguration.Data; | ||||
|         } | ||||
|  | ||||
|         private static async Task CreateAdministrationArea(IApplicationBuilder builder, IServiceCollection services) | ||||
|         private static async Task CreateAdministrationArea(IApplicationBuilder builder) | ||||
|         { | ||||
|             var configuration = await CreateConfiguration(builder); | ||||
|  | ||||
| @@ -183,7 +183,6 @@ namespace Ocelot.Middleware | ||||
|             { | ||||
|                 builder.Map(configuration.AdministrationPath, app => | ||||
|                 { | ||||
|                     Console.WriteLine("SETTING UP ADMIN AREA"); | ||||
|                     app.UseIdentityServer(); | ||||
|                     app.UseAuthentication(); | ||||
|                     app.UseMvc(); | ||||
|   | ||||
| @@ -134,11 +134,8 @@ namespace Ocelot.AcceptanceTests | ||||
|                 .AddJsonFile("configuration.json") | ||||
|                 .AddEnvironmentVariables(); | ||||
|  | ||||
|             IServiceCollection serviceCollection = new ServiceCollection(); | ||||
|             var configuration = builder.Build(); | ||||
|  | ||||
|             _webHostBuilder = new WebHostBuilder(); | ||||
|              | ||||
|             _webHostBuilder.ConfigureServices(s =>  | ||||
|             { | ||||
|                 s.AddSingleton(_webHostBuilder); | ||||
| @@ -158,7 +155,6 @@ namespace Ocelot.AcceptanceTests | ||||
|                     }; | ||||
|                      | ||||
|                     s.AddOcelot(configuration, settings); | ||||
|                     serviceCollection = s; | ||||
|                 }) | ||||
|                 .ConfigureLogging(l => | ||||
|                 { | ||||
| @@ -167,7 +163,7 @@ namespace Ocelot.AcceptanceTests | ||||
|                 }) | ||||
|                 .Configure(a => | ||||
|                 { | ||||
|                     a.UseOcelot(ocelotMiddlewareConfig, serviceCollection).Wait(); | ||||
|                     a.UseOcelot(ocelotMiddlewareConfig).Wait(); | ||||
|                 })); | ||||
|  | ||||
|             _ocelotClient = _ocelotServer.CreateClient(); | ||||
|   | ||||
| @@ -59,7 +59,7 @@ namespace Ocelot.IntegrationTests | ||||
|          public void should_return_response_200_with_call_re_routes_controller() | ||||
|          { | ||||
|              var configuration = new FileConfiguration | ||||
|              { | ||||
|              {  | ||||
|                  GlobalConfiguration = new FileGlobalConfiguration | ||||
|                  { | ||||
|                      AdministrationPath = "/administration" | ||||
|   | ||||
| @@ -42,7 +42,7 @@ | ||||
|     <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" /> | ||||
|     <PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" /> | ||||
|     <PackageReference Include="xunit" Version="2.3.0-beta2-build3683" /> | ||||
|     <PackageReference Include="IdentityServer4" Version="2.0.0-rc1-update1" /> | ||||
|     <PackageReference Include="IdentityServer4" Version="2.0.1" /> | ||||
|     <PackageReference Include="Shouldly" Version="2.8.3" /> | ||||
|     <PackageReference Include="TestStack.BDDfy" Version="4.3.2" /> | ||||
|     <PackageReference Include="Consul" Version="0.7.2.3" /> | ||||
|   | ||||
| @@ -26,7 +26,6 @@ namespace Ocelot.ManualTest | ||||
|         } | ||||
|  | ||||
|         public IConfigurationRoot Configuration { get; } | ||||
|         public IServiceCollection Services { get; private set; } | ||||
|  | ||||
|         public void ConfigureServices(IServiceCollection services) | ||||
|         { | ||||
| @@ -40,14 +39,13 @@ namespace Ocelot.ManualTest | ||||
|             }; | ||||
|  | ||||
|             services.AddOcelot(Configuration, settings); | ||||
|             Services = services; | ||||
|         } | ||||
|  | ||||
|         public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | ||||
|         { | ||||
|             loggerFactory.AddConsole(Configuration.GetSection("Logging")); | ||||
|  | ||||
|             app.UseOcelot(Services).Wait(); | ||||
|             app.UseOcelot().Wait(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tom Gardham-Pallister
					Tom Gardham-Pallister