Renamed ScopeName to ApiName, ScopeSecret to ApiSecret, and

AdditionalScopes to Allowed Scoped in order to be more consistent with
Identity Server naming conventions.
This commit is contained in:
David Derman 2017-03-14 16:54:55 -04:00
parent 3e8a296631
commit a3b387aeb1
17 changed files with 100 additions and 100 deletions

View File

@ -22,13 +22,13 @@
"AuthenticationOptions": { "AuthenticationOptions": {
"Provider": "IdentityServer", "Provider": "IdentityServer",
"ProviderRootUrl": "http://localhost:52888", "ProviderRootUrl": "http://localhost:52888",
"ScopeName": "api", "ApiName": "api",
"AdditionalScopes": [ "AllowedScopes": [
"openid", "openid",
"offline_access" "offline_access"
], ],
# Required if using reference tokens # Required if using reference tokens
"ScopeSecret": "secret" "ApiSecret": "secret"
}, },
# WARNING - will overwrite any headers already in the request with these values. # WARNING - will overwrite any headers already in the request with these values.
# Ocelot will look in the user claims for the key in [] then return the value and save # Ocelot will look in the user claims for the key in [] then return the value and save

File diff suppressed because one or more lines are too long

View File

@ -19,11 +19,11 @@ namespace Ocelot.Authentication.Handler.Creator
builder.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions builder.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{ {
Authority = authOptions.ProviderRootUrl, Authority = authOptions.ProviderRootUrl,
ApiName = authOptions.ScopeName, ApiName = authOptions.ApiName,
RequireHttpsMetadata = authOptions.RequireHttps, RequireHttpsMetadata = authOptions.RequireHttps,
AllowedScopes = authOptions.AdditionalScopes, AllowedScopes = authOptions.AllowedScopes,
SupportedTokens = SupportedTokens.Both, SupportedTokens = SupportedTokens.Both,
ApiSecret = authOptions.ScopeSecret ApiSecret = authOptions.ApiSecret
}); });
var authenticationNext = builder.Build(); var authenticationNext = builder.Build();

View File

@ -4,22 +4,22 @@ namespace Ocelot.Configuration
{ {
public class AuthenticationOptions public class AuthenticationOptions
{ {
public AuthenticationOptions(string provider, string providerRootUrl, string scopeName, bool requireHttps, List<string> additionalScopes, string scopeSecret) public AuthenticationOptions(string provider, string providerRootUrl, string apiName, bool requireHttps, List<string> allowedScopes, string apiSecret)
{ {
Provider = provider; Provider = provider;
ProviderRootUrl = providerRootUrl; ProviderRootUrl = providerRootUrl;
ScopeName = scopeName; ApiName = apiName;
RequireHttps = requireHttps; RequireHttps = requireHttps;
AdditionalScopes = additionalScopes; AllowedScopes = allowedScopes;
ScopeSecret = scopeSecret; ApiSecret = apiSecret;
} }
public string Provider { get; private set; } public string Provider { get; private set; }
public string ProviderRootUrl { get; private set; } public string ProviderRootUrl { get; private set; }
public string ScopeName { get; private set; } public string ApiName { get; private set; }
public string ScopeSecret { get; private set; } public string ApiSecret { get; private set; }
public bool RequireHttps { get; private set; } public bool RequireHttps { get; private set; }
public List<string> AdditionalScopes { get; private set; } public List<string> AllowedScopes { get; private set; }
} }
} }

View File

@ -7,10 +7,10 @@ namespace Ocelot.Configuration.Builder
private string _provider; private string _provider;
private string _providerRootUrl; private string _providerRootUrl;
private string _scopeName; private string _apiName;
private string _scopeSecret; private string _apiSecret;
private bool _requireHttps; private bool _requireHttps;
private List<string> _additionalScopes; private List<string> _allowedScopes;
public AuthenticationOptionsBuilder WithProvider(string provider) public AuthenticationOptionsBuilder WithProvider(string provider)
{ {
@ -24,15 +24,15 @@ namespace Ocelot.Configuration.Builder
return this; return this;
} }
public AuthenticationOptionsBuilder WithScopeName(string scopeName) public AuthenticationOptionsBuilder WithApiName(string apiName)
{ {
_scopeName = scopeName; _apiName = apiName;
return this; return this;
} }
public AuthenticationOptionsBuilder WithScopeSecret(string scopeSecret) public AuthenticationOptionsBuilder WithApiSecret(string apiSecret)
{ {
_scopeSecret = scopeSecret; _apiSecret = apiSecret;
return this; return this;
} }
@ -42,15 +42,15 @@ namespace Ocelot.Configuration.Builder
return this; return this;
} }
public AuthenticationOptionsBuilder WithAdditionalScopes(List<string> additionalScopes) public AuthenticationOptionsBuilder WithAllowedScopes(List<string> allowedScopes)
{ {
_additionalScopes = additionalScopes; _allowedScopes = allowedScopes;
return this; return this;
} }
public AuthenticationOptions Build() public AuthenticationOptions Build()
{ {
return new AuthenticationOptions(_provider, _providerRootUrl, _scopeName, _requireHttps, _additionalScopes, _scopeSecret); return new AuthenticationOptions(_provider, _providerRootUrl, _apiName, _requireHttps, _allowedScopes, _apiSecret);
} }
} }
} }

View File

@ -10,10 +10,10 @@ namespace Ocelot.Configuration.Creator
return new AuthenticationOptionsBuilder() return new AuthenticationOptionsBuilder()
.WithProvider(fileReRoute.AuthenticationOptions?.Provider) .WithProvider(fileReRoute.AuthenticationOptions?.Provider)
.WithProviderRootUrl(fileReRoute.AuthenticationOptions?.ProviderRootUrl) .WithProviderRootUrl(fileReRoute.AuthenticationOptions?.ProviderRootUrl)
.WithScopeName(fileReRoute.AuthenticationOptions?.ScopeName) .WithApiName(fileReRoute.AuthenticationOptions?.ApiName)
.WithRequireHttps(fileReRoute.AuthenticationOptions.RequireHttps) .WithRequireHttps(fileReRoute.AuthenticationOptions.RequireHttps)
.WithAdditionalScopes(fileReRoute.AuthenticationOptions?.AdditionalScopes) .WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes)
.WithScopeSecret(fileReRoute.AuthenticationOptions?.ScopeSecret) .WithApiSecret(fileReRoute.AuthenticationOptions?.ApiSecret)
.Build(); .Build();
} }
} }

View File

@ -6,14 +6,14 @@ namespace Ocelot.Configuration.File
{ {
public FileAuthenticationOptions() public FileAuthenticationOptions()
{ {
AdditionalScopes = new List<string>(); AllowedScopes = new List<string>();
} }
public string Provider { get; set; } public string Provider { get; set; }
public string ProviderRootUrl { get; set; } public string ProviderRootUrl { get; set; }
public string ScopeName { get; set; } public string ApiName { get; set; }
public bool RequireHttps { get; set; } public bool RequireHttps { get; set; }
public List<string> AdditionalScopes { get; set; } public List<string> AllowedScopes { get; set; }
public string ScopeSecret { get; set; } public string ApiSecret { get; set; }
} }
} }

View File

@ -51,12 +51,12 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Post", UpstreamHttpMethod = "Post",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = _identityServerRootUrl, ProviderRootUrl = _identityServerRootUrl,
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret" ApiSecret = "secret"
} }
} }
} }
@ -89,12 +89,12 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Post", UpstreamHttpMethod = "Post",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = _identityServerRootUrl, ProviderRootUrl = _identityServerRootUrl,
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret" ApiSecret = "secret"
} }
} }
} }
@ -127,12 +127,12 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = _identityServerRootUrl, ProviderRootUrl = _identityServerRootUrl,
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret" ApiSecret = "secret"
} }
} }
} }
@ -168,12 +168,12 @@ namespace Ocelot.AcceptanceTests
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = _identityServerRootUrl, ProviderRootUrl = _identityServerRootUrl,
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret" ApiSecret = "secret"
} }
} }
} }
@ -208,12 +208,12 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Post", UpstreamHttpMethod = "Post",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = _identityServerRootUrl, ProviderRootUrl = _identityServerRootUrl,
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret" ApiSecret = "secret"
} }
} }
} }
@ -252,7 +252,7 @@ namespace Ocelot.AcceptanceTests
_servicebuilder.Start(); _servicebuilder.Start();
} }
private void GivenThereIsAnIdentityServerOn(string url, string scopeName, AccessTokenType tokenType) private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType)
{ {
_identityServerBuilder = new WebHostBuilder() _identityServerBuilder = new WebHostBuilder()
.UseUrls(url) .UseUrls(url)
@ -269,7 +269,7 @@ namespace Ocelot.AcceptanceTests
{ {
new ApiResource new ApiResource
{ {
Name = scopeName, Name = apiName,
Description = "My API", Description = "My API",
Enabled = true, Enabled = true,
DisplayName = "test", DisplayName = "test",
@ -299,7 +299,7 @@ namespace Ocelot.AcceptanceTests
ClientId = "client", ClientId = "client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
ClientSecrets = new List<Secret> {new Secret("secret".Sha256())}, ClientSecrets = new List<Secret> {new Secret("secret".Sha256())},
AllowedScopes = new List<string> { scopeName, "openid", "offline_access" }, AllowedScopes = new List<string> { apiName, "openid", "offline_access" },
AccessTokenType = tokenType, AccessTokenType = tokenType,
Enabled = true, Enabled = true,
RequireClientSecret = false RequireClientSecret = false

View File

@ -45,12 +45,12 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = "http://localhost:51888", ProviderRootUrl = "http://localhost:51888",
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret" ApiSecret = "secret"
}, },
AddHeadersToRequest = AddHeadersToRequest =
{ {
@ -102,12 +102,12 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = "http://localhost:51888", ProviderRootUrl = "http://localhost:51888",
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret" ApiSecret = "secret"
}, },
AddHeadersToRequest = AddHeadersToRequest =
{ {
@ -161,7 +161,7 @@ namespace Ocelot.AcceptanceTests
_servicebuilder.Start(); _servicebuilder.Start();
} }
private void GivenThereIsAnIdentityServerOn(string url, string scopeName, AccessTokenType tokenType) private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType)
{ {
_identityServerBuilder = new WebHostBuilder() _identityServerBuilder = new WebHostBuilder()
.UseUrls(url) .UseUrls(url)
@ -178,7 +178,7 @@ namespace Ocelot.AcceptanceTests
{ {
new ApiResource new ApiResource
{ {
Name = scopeName, Name = apiName,
Description = "My API", Description = "My API",
Enabled = true, Enabled = true,
DisplayName = "test", DisplayName = "test",
@ -209,7 +209,7 @@ namespace Ocelot.AcceptanceTests
ClientId = "client", ClientId = "client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
ClientSecrets = new List<Secret> {new Secret("secret".Sha256())}, ClientSecrets = new List<Secret> {new Secret("secret".Sha256())},
AllowedScopes = new List<string> { scopeName, "openid", "offline_access" }, AllowedScopes = new List<string> { apiName, "openid", "offline_access" },
AccessTokenType = tokenType, AccessTokenType = tokenType,
Enabled = true, Enabled = true,
RequireClientSecret = false RequireClientSecret = false

View File

@ -59,15 +59,15 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string> AllowedScopes = new List<string>
{ {
"openid", "offline_access" "openid", "offline_access"
}, },
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = "http://localhost:52888", ProviderRootUrl = "http://localhost:52888",
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret", ApiSecret = "secret",
}, },
AddHeadersToRequest = AddHeadersToRequest =
{ {
@ -119,7 +119,7 @@ namespace Ocelot.AcceptanceTests
_servicebuilder.Start(); _servicebuilder.Start();
} }
private void GivenThereIsAnIdentityServerOn(string url, string scopeName, AccessTokenType tokenType, TestUser user) private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
{ {
_identityServerBuilder = new WebHostBuilder() _identityServerBuilder = new WebHostBuilder()
.UseUrls(url) .UseUrls(url)
@ -136,7 +136,7 @@ namespace Ocelot.AcceptanceTests
{ {
new ApiResource new ApiResource
{ {
Name = scopeName, Name = apiName,
Description = "My API", Description = "My API",
Enabled = true, Enabled = true,
DisplayName = "test", DisplayName = "test",
@ -166,7 +166,7 @@ namespace Ocelot.AcceptanceTests
ClientId = "client", ClientId = "client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
ClientSecrets = new List<Secret> {new Secret("secret".Sha256())}, ClientSecrets = new List<Secret> {new Secret("secret".Sha256())},
AllowedScopes = new List<string> { scopeName, "openid", "offline_access" }, AllowedScopes = new List<string> { apiName, "openid", "offline_access" },
AccessTokenType = tokenType, AccessTokenType = tokenType,
Enabled = true, Enabled = true,
RequireClientSecret = false RequireClientSecret = false

View File

@ -59,15 +59,15 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string> AllowedScopes = new List<string>
{ {
"openid", "offline_access" "openid", "offline_access"
}, },
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = "http://localhost:57888", ProviderRootUrl = "http://localhost:57888",
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName = "api",
ScopeSecret = "secret", ApiSecret = "secret",
}, },
AddQueriesToRequest = AddQueriesToRequest =
{ {
@ -126,7 +126,7 @@ namespace Ocelot.AcceptanceTests
_servicebuilder.Start(); _servicebuilder.Start();
} }
private void GivenThereIsAnIdentityServerOn(string url, string scopeName, AccessTokenType tokenType, TestUser user) private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
{ {
_identityServerBuilder = new WebHostBuilder() _identityServerBuilder = new WebHostBuilder()
.UseUrls(url) .UseUrls(url)
@ -143,7 +143,7 @@ namespace Ocelot.AcceptanceTests
{ {
new ApiResource new ApiResource
{ {
Name = scopeName, Name = apiName,
Description = "My API", Description = "My API",
Enabled = true, Enabled = true,
DisplayName = "test", DisplayName = "test",
@ -173,7 +173,7 @@ namespace Ocelot.AcceptanceTests
ClientId = "client", ClientId = "client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
ClientSecrets = new List<Secret> {new Secret("secret".Sha256())}, ClientSecrets = new List<Secret> {new Secret("secret".Sha256())},
AllowedScopes = new List<string> { scopeName, "openid", "offline_access" }, AllowedScopes = new List<string> { apiName, "openid", "offline_access" },
AccessTokenType = tokenType, AccessTokenType = tokenType,
Enabled = true, Enabled = true,
RequireClientSecret = false RequireClientSecret = false

View File

@ -1 +1 @@
{"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamPathTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null,"RateLimitOptions":{"ClientWhitelist":[],"EnableRateLimiting":false,"Period":null,"PeriodTimespan":0.0,"Limit":0}}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0},"AdministrationPath":null,"RateLimitOptions":{"ClientIdHeader":"ClientId","QuotaExceededMessage":null,"RateLimitCounterPrefix":"ocelot","DisableRateLimitHeaders":false,"HttpStatusCode":429}}} {"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamPathTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ApiName":null,"RequireHttps":false,"AllowedScopes":[],"ApiSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null,"RateLimitOptions":{"ClientWhitelist":[],"EnableRateLimiting":false,"Period":null,"PeriodTimespan":0.0,"Limit":0}}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0},"AdministrationPath":null,"RateLimitOptions":{"ClientIdHeader":"ClientId","QuotaExceededMessage":null,"RateLimitCounterPrefix":"ocelot","DisableRateLimitHeaders":false,"HttpStatusCode":429}}}

View File

@ -1 +1 @@
{"ReRoutes":[{"DownstreamPathTemplate":"/","UpstreamPathTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":51879,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null,"RateLimitOptions":{"ClientWhitelist":[],"EnableRateLimiting":false,"Period":null,"PeriodTimespan":0.0,"Limit":0}}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0},"AdministrationPath":null,"RateLimitOptions":{"ClientIdHeader":"ClientId","QuotaExceededMessage":null,"RateLimitCounterPrefix":"ocelot","DisableRateLimitHeaders":false,"HttpStatusCode":429}}} {"ReRoutes":[{"DownstreamPathTemplate":"/","UpstreamPathTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ApiName":null,"RequireHttps":false,"AllowedScopes":[],"ApiSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":51879,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null,"RateLimitOptions":{"ClientWhitelist":[],"EnableRateLimiting":false,"Period":null,"PeriodTimespan":0.0,"Limit":0}}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0},"AdministrationPath":null,"RateLimitOptions":{"ClientIdHeader":"ClientId","QuotaExceededMessage":null,"RateLimitCounterPrefix":"ocelot","DisableRateLimitHeaders":false,"HttpStatusCode":429}}}

View File

@ -15,12 +15,12 @@
"AuthenticationOptions": { "AuthenticationOptions": {
"Provider": "IdentityServer", "Provider": "IdentityServer",
"ProviderRootUrl": "http://localhost:52888", "ProviderRootUrl": "http://localhost:52888",
"ScopeName": "api", "ApiName": "api",
"AdditionalScopes": [ "AllowedScopes": [
"openid", "openid",
"offline_access" "offline_access"
], ],
"ScopeSecret": "secret" "ApiSecret": "secret"
}, },
"AddHeadersToRequest": { "AddHeadersToRequest": {
"CustomerId": "Claims[CustomerId] > value", "CustomerId": "Claims[CustomerId] > value",

View File

@ -29,20 +29,20 @@ namespace Ocelot.UnitTests.Configuration
{ {
Provider = "Geoff", Provider = "Geoff",
ProviderRootUrl = "http://www.bbc.co.uk/", ProviderRootUrl = "http://www.bbc.co.uk/",
ScopeName = "Laura", ApiName = "Laura",
RequireHttps = true, RequireHttps = true,
AdditionalScopes = new List<string> {"cheese"}, AllowedScopes = new List<string> {"cheese"},
ScopeSecret = "secret" ApiSecret = "secret"
} }
}; };
var expected = new AuthenticationOptionsBuilder() var expected = new AuthenticationOptionsBuilder()
.WithProvider(fileReRoute.AuthenticationOptions?.Provider) .WithProvider(fileReRoute.AuthenticationOptions?.Provider)
.WithProviderRootUrl(fileReRoute.AuthenticationOptions?.ProviderRootUrl) .WithProviderRootUrl(fileReRoute.AuthenticationOptions?.ProviderRootUrl)
.WithScopeName(fileReRoute.AuthenticationOptions?.ScopeName) .WithApiName(fileReRoute.AuthenticationOptions?.ApiName)
.WithRequireHttps(fileReRoute.AuthenticationOptions.RequireHttps) .WithRequireHttps(fileReRoute.AuthenticationOptions.RequireHttps)
.WithAdditionalScopes(fileReRoute.AuthenticationOptions?.AdditionalScopes) .WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes)
.WithScopeSecret(fileReRoute.AuthenticationOptions?.ScopeSecret) .WithApiSecret(fileReRoute.AuthenticationOptions?.ApiSecret)
.Build(); .Build();
this.Given(x => x.GivenTheFollowing(fileReRoute)) this.Given(x => x.GivenTheFollowing(fileReRoute))
@ -63,12 +63,12 @@ namespace Ocelot.UnitTests.Configuration
private void ThenTheFollowingIsReturned(AuthenticationOptions expected) private void ThenTheFollowingIsReturned(AuthenticationOptions expected)
{ {
_result.AdditionalScopes.ShouldBe(expected.AdditionalScopes); _result.AllowedScopes.ShouldBe(expected.AllowedScopes);
_result.Provider.ShouldBe(expected.Provider); _result.Provider.ShouldBe(expected.Provider);
_result.ProviderRootUrl.ShouldBe(expected.ProviderRootUrl); _result.ProviderRootUrl.ShouldBe(expected.ProviderRootUrl);
_result.RequireHttps.ShouldBe(expected.RequireHttps); _result.RequireHttps.ShouldBe(expected.RequireHttps);
_result.ScopeName.ShouldBe(expected.ScopeName); _result.ApiName.ShouldBe(expected.ApiName);
_result.ScopeSecret.ShouldBe(expected.ScopeSecret); _result.ApiSecret.ShouldBe(expected.ApiSecret);
} }
} }
} }

View File

@ -403,9 +403,9 @@ namespace Ocelot.UnitTests.Configuration
.WithProvider("IdentityServer") .WithProvider("IdentityServer")
.WithProviderRootUrl("http://localhost:51888") .WithProviderRootUrl("http://localhost:51888")
.WithRequireHttps(false) .WithRequireHttps(false)
.WithScopeSecret("secret") .WithApiSecret("secret")
.WithScopeName("api") .WithApiName("api")
.WithAdditionalScopes(new List<string>()) .WithAllowedScopes(new List<string>())
.Build(); .Build();
var expected = new List<ReRoute> var expected = new List<ReRoute>
@ -434,12 +434,12 @@ namespace Ocelot.UnitTests.Configuration
ReRouteIsCaseSensitive = true, ReRouteIsCaseSensitive = true,
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes= new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = "http://localhost:51888", ProviderRootUrl = "http://localhost:51888",
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName= "api",
ScopeSecret = "secret" ApiSecret = "secret"
}, },
AddHeadersToRequest = AddHeadersToRequest =
{ {
@ -471,9 +471,9 @@ namespace Ocelot.UnitTests.Configuration
.WithProvider("IdentityServer") .WithProvider("IdentityServer")
.WithProviderRootUrl("http://localhost:51888") .WithProviderRootUrl("http://localhost:51888")
.WithRequireHttps(false) .WithRequireHttps(false)
.WithScopeSecret("secret") .WithApiSecret("secret")
.WithScopeName("api") .WithApiName("api")
.WithAdditionalScopes(new List<string>()) .WithAllowedScopes(new List<string>())
.Build(); .Build();
var expected = new List<ReRoute> var expected = new List<ReRoute>
@ -498,12 +498,12 @@ namespace Ocelot.UnitTests.Configuration
ReRouteIsCaseSensitive = true, ReRouteIsCaseSensitive = true,
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
AdditionalScopes = new List<string>(), AllowedScopes = new List<string>(),
Provider = "IdentityServer", Provider = "IdentityServer",
ProviderRootUrl = "http://localhost:51888", ProviderRootUrl = "http://localhost:51888",
RequireHttps = false, RequireHttps = false,
ScopeName = "api", ApiName= "api",
ScopeSecret = "secret" ApiSecret = "secret"
} }
} }
} }
@ -592,12 +592,12 @@ namespace Ocelot.UnitTests.Configuration
var result = _config.Data.ReRoutes[i].AuthenticationOptions; var result = _config.Data.ReRoutes[i].AuthenticationOptions;
var expected = expectedReRoutes[i].AuthenticationOptions; var expected = expectedReRoutes[i].AuthenticationOptions;
result.AdditionalScopes.ShouldBe(expected.AdditionalScopes); result.AllowedScopes.ShouldBe(expected.AllowedScopes);
result.Provider.ShouldBe(expected.Provider); result.Provider.ShouldBe(expected.Provider);
result.ProviderRootUrl.ShouldBe(expected.ProviderRootUrl); result.ProviderRootUrl.ShouldBe(expected.ProviderRootUrl);
result.RequireHttps.ShouldBe(expected.RequireHttps); result.RequireHttps.ShouldBe(expected.RequireHttps);
result.ScopeName.ShouldBe(expected.ScopeName); result.ApiName.ShouldBe(expected.ApiName);
result.ScopeSecret.ShouldBe(expected.ScopeSecret); result.ApiSecret.ShouldBe(expected.ApiSecret);
} }
} }

View File

@ -1 +1 @@
{"ReRoutes":[{"DownstreamPathTemplate":"/test/test/{test}","UpstreamPathTemplate":null,"UpstreamHttpMethod":null,"AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"https","DownstreamHost":"localhost","DownstreamPort":80,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":"consul","Host":"blah","Port":198},"AdministrationPath":"testy"}} {"ReRoutes":[{"DownstreamPathTemplate":"/test/test/{test}","UpstreamPathTemplate":null,"UpstreamHttpMethod":null,"AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ApiName":null,"RequireHttps":false,"AllowedScopes":[],"ApiSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"https","DownstreamHost":"localhost","DownstreamPort":80,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":"consul","Host":"blah","Port":198},"AdministrationPath":"testy"}}