can now use tokens from ocelot a on ocelot b when using admin area

This commit is contained in:
Tom Gardham-Pallister 2017-06-23 15:17:40 +01:00
parent 2d94884c6f
commit 6cdf4e67df
8 changed files with 29 additions and 7 deletions

1
.gitignore vendored
View File

@ -183,6 +183,7 @@ ClientBin/
*.dbmdl
*.dbproj.schemaview
*.pfx
!idsrv3test.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

View File

@ -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

View File

@ -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,

View File

@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<None Update="configuration.json;idsrv3test.pfx">
<None Update="configuration.json;appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

View File

@ -0,0 +1,10 @@
{
"Logging": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Error",
"System": "Error",
"Microsoft": "Error"
}
}
}

View File

@ -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();
}

View File

@ -3,8 +3,8 @@
"IncludeScopes": true,
"LogLevel": {
"Default": "Error",
"System": "Information",
"Microsoft": "Information"
"System": "Error",
"Microsoft": "Error"
}
}
}

Binary file not shown.