mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 18:32:51 +08:00
started working on stripping claims from token
This commit is contained in:
parent
3d60602c7e
commit
2395736b6b
@ -42,7 +42,7 @@ ReRoutes:
|
|||||||
UpstreamTemplate: /
|
UpstreamTemplate: /
|
||||||
UpstreamHttpMethod: Post
|
UpstreamHttpMethod: Post
|
||||||
AuthenticationOptions:
|
AuthenticationOptions:
|
||||||
Provider: IdentityServer.AccessToken
|
Provider: IdentityServer
|
||||||
ProviderRootUrl: http://localhost:51888
|
ProviderRootUrl: http://localhost:51888
|
||||||
ScopeName: api
|
ScopeName: api
|
||||||
AdditionalScopes: []
|
AdditionalScopes: []
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
namespace Ocelot.Library.Configuration.Yaml
|
namespace Ocelot.Library.Configuration.Yaml
|
||||||
{
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class YamlReRoute
|
public class YamlReRoute
|
||||||
{
|
{
|
||||||
|
public YamlReRoute()
|
||||||
|
{
|
||||||
|
AddHeadersToRequest = new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
public string DownstreamTemplate { get; set; }
|
public string DownstreamTemplate { get; set; }
|
||||||
public string UpstreamTemplate { get; set; }
|
public string UpstreamTemplate { get; set; }
|
||||||
public string UpstreamHttpMethod { get; set; }
|
public string UpstreamHttpMethod { get; set; }
|
||||||
public YamlAuthenticationOptions AuthenticationOptions { get; set; }
|
public YamlAuthenticationOptions AuthenticationOptions { get; set; }
|
||||||
|
public Dictionary<string,string> AddHeadersToRequest { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -144,6 +144,47 @@ namespace Ocelot.AcceptanceTests
|
|||||||
.BDDfy();
|
.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]
|
[Fact]
|
||||||
public void should_return_201_using_identity_server_access_token()
|
public void should_return_201_using_identity_server_access_token()
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
{
|
{
|
||||||
DownstreamTemplate = "http://localhost:51879/",
|
DownstreamTemplate = "http://localhost:51879/",
|
||||||
UpstreamTemplate = "/",
|
UpstreamTemplate = "/",
|
||||||
UpstreamHttpMethod = "Get"
|
UpstreamHttpMethod = "Get",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
ReRoutes:
|
ReRoutes:
|
||||||
- DownstreamTemplate: http://localhost:51879/
|
- DownstreamTemplate: http://localhost:51876/
|
||||||
UpstreamTemplate: /
|
UpstreamTemplate: /
|
||||||
UpstreamHttpMethod: Get
|
UpstreamHttpMethod: Post
|
||||||
Authentication: IdentityServer.AccessToken
|
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