mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-01 06:15:27 +08:00 
			
		
		
		
	can now use tokens from ocelot a on ocelot b when using admin area
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -183,6 +183,7 @@ ClientBin/ | ||||
| *.dbmdl | ||||
| *.dbproj.schemaview | ||||
| *.pfx | ||||
| !idsrv3test.pfx | ||||
| *.publishsettings | ||||
| node_modules/ | ||||
| orleans.codegen.cs | ||||
|   | ||||
| @@ -89,7 +89,10 @@ namespace Ocelot.DependencyInjection | ||||
|             { | ||||
|                 services.TryAddSingleton<IIdentityServerConfiguration>(identityServerConfiguration); | ||||
|                 services.TryAddSingleton<IHashMatcher, HashMatcher>(); | ||||
|                 var identityServerBuilder = services.AddIdentityServer() | ||||
|                 var identityServerBuilder = services | ||||
|                     .AddIdentityServer(options => { | ||||
|                         options.IssuerUri = "Ocelot"; | ||||
|                     }) | ||||
|                     .AddInMemoryApiResources(new List<ApiResource> | ||||
|                     { | ||||
|                         new ApiResource | ||||
|   | ||||
| @@ -181,7 +181,6 @@ namespace Ocelot.Middleware | ||||
|                 builder.Map(configuration.AdministrationPath, app => | ||||
|                 { | ||||
|                     var identityServerUrl = $"{baseSchemeUrlAndPort}/{configuration.AdministrationPath.Remove(0,1)}"; | ||||
|  | ||||
|                     app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions | ||||
|                     { | ||||
|                         Authority = identityServerUrl, | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <None Update="configuration.json;idsrv3test.pfx"> | ||||
|     <None Update="configuration.json;appsettings.json"> | ||||
|       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||
|     </None> | ||||
|   </ItemGroup> | ||||
|   | ||||
							
								
								
									
										10
									
								
								test/Ocelot.AcceptanceTests/appsettings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								test/Ocelot.AcceptanceTests/appsettings.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| { | ||||
|   "Logging": { | ||||
|     "IncludeScopes": true, | ||||
|     "LogLevel": { | ||||
|       "Default": "Error", | ||||
|       "System": "Error", | ||||
|       "Microsoft": "Error" | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @@ -86,9 +86,9 @@ namespace Ocelot.IntegrationTests | ||||
|             }; | ||||
|  | ||||
|             this.Given(x => GivenThereIsAConfiguration(configuration)) | ||||
|                 .And(x => GivenIdentityServerSigningEnvironmentalVariablesAreSet()) | ||||
|                 .And(x => GivenOcelotIsRunning()) | ||||
|                 .And(x => GivenIHaveAnOcelotToken("/administration")) | ||||
|                 .And(x => GivenIHaveAddedATokenToMyRequest()) | ||||
|                 .And(x => GivenAnotherOcelotIsRunning("http://localhost:5007")) | ||||
|                 .When(x => WhenIGetUrlOnTheSecondOcelot("/administration/configuration")) | ||||
|                 .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) | ||||
| @@ -227,7 +227,7 @@ namespace Ocelot.IntegrationTests | ||||
|                .UseKestrel() | ||||
|                .UseContentRoot(Directory.GetCurrentDirectory()) | ||||
|                .ConfigureServices(x => { | ||||
|                    x.AddSingleton(_webHostBuilder); | ||||
|                    x.AddSingleton(_webHostBuilderTwo); | ||||
|                }) | ||||
|                .UseStartup<Startup>(); | ||||
|  | ||||
| @@ -236,8 +236,15 @@ namespace Ocelot.IntegrationTests | ||||
|             _builderTwo.Start(); | ||||
|         } | ||||
|  | ||||
|         private void GivenIdentityServerSigningEnvironmentalVariablesAreSet() | ||||
|         { | ||||
|             Environment.SetEnvironmentVariable("OCELOT_CERTIFICATE", "idsrv3test.pfx"); | ||||
|             Environment.SetEnvironmentVariable("OCELOT_CERTIFICATE_PASSWORD", "idsrv3test"); | ||||
|         } | ||||
|  | ||||
|         private void WhenIGetUrlOnTheSecondOcelot(string url) | ||||
|         { | ||||
|             _httpClientTwo.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken); | ||||
|             _response = _httpClientTwo.GetAsync(url).Result; | ||||
|         } | ||||
|  | ||||
| @@ -353,6 +360,8 @@ namespace Ocelot.IntegrationTests | ||||
|  | ||||
|         public void Dispose() | ||||
|         { | ||||
|             Environment.SetEnvironmentVariable("OCELOT_CERTIFICATE", ""); | ||||
|             Environment.SetEnvironmentVariable("OCELOT_CERTIFICATE_PASSWORD", ""); | ||||
|             _builder?.Dispose(); | ||||
|             _httpClient?.Dispose(); | ||||
|         } | ||||
|   | ||||
| @@ -3,8 +3,8 @@ | ||||
|     "IncludeScopes": true, | ||||
|     "LogLevel": { | ||||
|       "Default": "Error", | ||||
|       "System": "Information", | ||||
|       "Microsoft": "Information" | ||||
|       "System": "Error", | ||||
|       "Microsoft": "Error" | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								test/Ocelot.IntegrationTests/idsrv3test.pfx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								test/Ocelot.IntegrationTests/idsrv3test.pfx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user
	 Tom Gardham-Pallister
					Tom Gardham-Pallister