mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-23 00:32:50 +08:00
started working on stripping claims from token
This commit is contained in:
parent
3d60602c7e
commit
2395736b6b
@ -42,7 +42,7 @@ ReRoutes:
|
||||
UpstreamTemplate: /
|
||||
UpstreamHttpMethod: Post
|
||||
AuthenticationOptions:
|
||||
Provider: IdentityServer.AccessToken
|
||||
Provider: IdentityServer
|
||||
ProviderRootUrl: http://localhost:51888
|
||||
ScopeName: api
|
||||
AdditionalScopes: []
|
||||
|
@ -1,10 +1,18 @@
|
||||
namespace Ocelot.Library.Configuration.Yaml
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class YamlReRoute
|
||||
{
|
||||
public YamlReRoute()
|
||||
{
|
||||
AddHeadersToRequest = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public string DownstreamTemplate { get; set; }
|
||||
public string UpstreamTemplate { get; set; }
|
||||
public string UpstreamHttpMethod { get; set; }
|
||||
public YamlAuthenticationOptions AuthenticationOptions { get; set; }
|
||||
public Dictionary<string,string> AddHeadersToRequest { get; set; }
|
||||
}
|
||||
}
|
@ -144,6 +144,47 @@ namespace Ocelot.AcceptanceTests
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_return_response_200_and_foward_claim_as_header()
|
||||
{
|
||||
|
||||
this.Given(x => x.GivenThereIsAnIdentityServerOn("http://localhost:51888", "api", AccessTokenType.Jwt))
|
||||
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51876", 200, "Hello from Laura"))
|
||||
.And(x => x.GivenIHaveAToken("http://localhost:51888"))
|
||||
.And(x => x.GivenThereIsAConfiguration(new YamlConfiguration
|
||||
{
|
||||
ReRoutes = new List<YamlReRoute>
|
||||
{
|
||||
new YamlReRoute
|
||||
{
|
||||
DownstreamTemplate = "http://localhost:51876/",
|
||||
UpstreamTemplate = "/",
|
||||
UpstreamHttpMethod = "Get",
|
||||
AuthenticationOptions = new YamlAuthenticationOptions
|
||||
{
|
||||
AdditionalScopes = new List<string>(),
|
||||
Provider = "IdentityServer",
|
||||
ProviderRootUrl = "http://localhost:51888",
|
||||
RequireHttps = false,
|
||||
ScopeName = "api",
|
||||
ScopeSecret = "secret"
|
||||
},
|
||||
AddHeadersToRequest =
|
||||
{
|
||||
{ "CustomerId","Claims[CustomerId] > long" },
|
||||
{ "LocationId","Claims[LocationId] > int" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
.And(x => x.GivenTheApiGatewayIsRunning())
|
||||
.And(x => x.GivenIHaveAddedATokenToMyRequest())
|
||||
.When(x => x.WhenIGetUrlOnTheApiGateway("/"))
|
||||
.Then(x => x.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||
.And(x => x.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_return_201_using_identity_server_access_token()
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
DownstreamTemplate = "http://localhost:51879/",
|
||||
UpstreamTemplate = "/",
|
||||
UpstreamHttpMethod = "Get"
|
||||
UpstreamHttpMethod = "Get",
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
@ -1,5 +1,13 @@
|
||||
ReRoutes:
|
||||
- DownstreamTemplate: http://localhost:51879/
|
||||
- DownstreamTemplate: http://localhost:51876/
|
||||
UpstreamTemplate: /
|
||||
UpstreamHttpMethod: Get
|
||||
Authentication: IdentityServer.AccessToken
|
||||
UpstreamHttpMethod: Post
|
||||
AuthenticationOptions:
|
||||
Provider: IdentityServer
|
||||
ProviderRootUrl: http://localhost:51888
|
||||
ScopeName: api
|
||||
AdditionalScopes: []
|
||||
ScopeSecret: secret
|
||||
ProxyRequestHeaders:
|
||||
- CustomerId: Claims[CustomerId]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user