Fixed Merge Conflicts

This commit is contained in:
Thiago Loureiro
2019-06-01 19:52:34 +08:00
545 changed files with 3522 additions and 3430 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ os:
# Ubuntu 14.04 # Ubuntu 14.04
sudo: required sudo: required
dist: trusty dist: bionic
# OS X 10.12 # OS X 10.12
osx_image: xcode9.2 osx_image: xcode9.2
@@ -13,7 +13,7 @@ osx_image: xcode9.2
mono: mono:
- 5.10.0 - 5.10.0
dotnet: 2.1.500 dotnet: 2.2.105
before_install: before_install:
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
+16
View File
@@ -0,0 +1,16 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/ThreeMammals/Ocelot</RepositoryUrl>
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/>
</ItemGroup>
</Project>
+9
View File
@@ -1,12 +1,21 @@
[<img src="http://threemammals.com/images/ocelot_logo.png">](http://threemammals.com/ocelot) [<img src="http://threemammals.com/images/ocelot_logo.png">](http://threemammals.com/ocelot)
[![Build status](https://ci.appveyor.com/api/projects/status/r6sv51qx36sis1je?branch=develop&svg=true)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) Windows (AppVeyor) [![Build status](https://ci.appveyor.com/api/projects/status/r6sv51qx36sis1je?branch=develop&svg=true)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) Windows (AppVeyor)
[![Build Status](https://travis-ci.org/ThreeMammals/Ocelot.svg?branch=develop)](https://travis-ci.org/ThreeMammals/Ocelot) Linux & OSX (Travis) [![Build Status](https://travis-ci.org/ThreeMammals/Ocelot.svg?branch=develop)](https://travis-ci.org/ThreeMammals/Ocelot) Linux & OSX (Travis)
[![Build Status](https://dev.azure.com/ThreeMammals/Ocelot/_apis/build/status/Ocelot%20-%20Windows?branchName=develop)](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=4&branchName=develop) Windows
[![Build Status](https://dev.azure.com/ThreeMammals/Ocelot/_apis/build/status/Ocelot%20-%20MacOS?branchName=develop)](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=3&branchName=develop) MacOS
[![Build Status](https://dev.azure.com/ThreeMammals/Ocelot/_apis/build/status/Ocelot%20-%20Linux?branchName=develop)](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=2&branchName=develop) Linux
[![Windows Build history](https://buildstats.info/appveyor/chart/TomPallister/ocelot-fcfpb?branch=develop&includeBuildsFromPullRequest=false)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop) [![Windows Build history](https://buildstats.info/appveyor/chart/TomPallister/ocelot-fcfpb?branch=develop&includeBuildsFromPullRequest=false)](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/ThreeMammals/Ocelot/badge.svg?branch=develop)](https://coveralls.io/github/ThreeMammals/Ocelot?branch=develop) [![Coverage Status](https://coveralls.io/repos/github/ThreeMammals/Ocelot/badge.svg?branch=develop)](https://coveralls.io/github/ThreeMammals/Ocelot?branch=develop)
# Ocelot # Ocelot
Ocelot is a .NET API Gateway. This project is aimed at people using .NET running Ocelot is a .NET API Gateway. This project is aimed at people using .NET running
+1 -1
View File
@@ -93,7 +93,7 @@ Then map the authentication provider key to a ReRoute in your configuration e.g.
Identity Server Bearer Tokens Identity Server Bearer Tokens
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In order to use IdentityServer bearer tokens register your IdentityServer services as usual in ConfigureServices with a scheme (key). If you don't understand how to do this please consult the IdentityServer documentation. In order to use IdentityServer bearer tokens, register your IdentityServer services as usual in ConfigureServices with a scheme (key). If you don't understand how to do this please consult the IdentityServer documentation.
.. code-block:: csharp .. code-block:: csharp
+3 -3
View File
@@ -26,15 +26,15 @@ Then add the following section to a ReRoute configuration.
"QoSOptions": { "QoSOptions": {
"ExceptionsAllowedBeforeBreaking":3, "ExceptionsAllowedBeforeBreaking":3,
"DurationOfBreak":5, "DurationOfBreak":1000,
"TimeoutValue":5000 "TimeoutValue":5000
} }
You must set a number greater than 0 against ExceptionsAllowedBeforeBreaking for this rule to be You must set a number greater than 0 against ExceptionsAllowedBeforeBreaking for this rule to be
implemented. Duration of break is how long the circuit breaker will stay open for after it is tripped. implemented. Duration of break means the circuit breaker will stay open for 1 second after it is tripped.
TimeoutValue means if a request takes more than 5 seconds it will automatically be timed out. TimeoutValue means if a request takes more than 5 seconds it will automatically be timed out.
You can set the TimeoutValue in isoldation of the ExceptionsAllowedBeforeBreaking and DurationOfBreak options. You can set the TimeoutValue in isolation of the ExceptionsAllowedBeforeBreaking and DurationOfBreak options.
.. code-block:: json .. code-block:: json
+8 -1
View File
@@ -18,9 +18,13 @@ OK so to get rate limiting working for a ReRoute you need to add the following j
} }
ClientWhitelist - This is an array that contains the whitelist of the client. It means that the client in this array will not be affected by the rate limiting. ClientWhitelist - This is an array that contains the whitelist of the client. It means that the client in this array will not be affected by the rate limiting.
EnableRateLimiting - This value specifies enable endpoint rate limiting. EnableRateLimiting - This value specifies enable endpoint rate limiting.
Period - This value specifies the period that the limit applies to, such as 1s, 5m, 1h,1d and so on. If you make more requests in the period than the limit allows then you need to wait for PeriodTimespan to elapse before you make another request. Period - This value specifies the period that the limit applies to, such as 1s, 5m, 1h,1d and so on. If you make more requests in the period than the limit allows then you need to wait for PeriodTimespan to elapse before you make another request.
PeriodTimespan - This value specifies that we can retry after a certain number of seconds. PeriodTimespan - This value specifies that we can retry after a certain number of seconds.
Limit - This value specifies the maximum number of requests that a client can make in a defined period. Limit - This value specifies the maximum number of requests that a client can make in a defined period.
You can also set the following in the GlobalConfiguration part of ocelot.json You can also set the following in the GlobalConfiguration part of ocelot.json
@@ -34,7 +38,10 @@ You can also set the following in the GlobalConfiguration part of ocelot.json
"ClientIdHeader" : "Test" "ClientIdHeader" : "Test"
} }
DisableRateLimitHeaders - This value specifies whether X-Rate-Limit and Rety-After headers are disabled. DisableRateLimitHeaders - This value specifies whether X-Rate-Limit and Retry-After headers are disabled.
QuotaExceededMessage - This value specifies the exceeded message. QuotaExceededMessage - This value specifies the exceeded message.
HttpStatusCode - This value specifies the returned HTTP Status code when rate limiting occurs. HttpStatusCode - This value specifies the returned HTTP Status code when rate limiting occurs.
ClientIdHeader - Allows you to specifiy the header that should be used to identify clients. By default it is "ClientId" ClientIdHeader - Allows you to specifiy the header that should be used to identify clients. By default it is "ClientId"
+1 -1
View File
@@ -37,7 +37,7 @@ The DownstreamPathTemplate, DownstreamScheme and DownstreamHostAndPorts define t
DownstreamHostAndPorts is a collection that defines the host and port of any downstream services that you wish to forward requests to. DownstreamHostAndPorts is a collection that defines the host and port of any downstream services that you wish to forward requests to.
Usually this will just contain a single entry but sometimes you might want to load balance requests to your downstream services and Ocelot allows you add more than one entry and then select a load balancer. Usually this will just contain a single entry but sometimes you might want to load balance requests to your downstream services and Ocelot allows you add more than one entry and then select a load balancer.
The UpstreamPathTemplate is the URL that Ocelot will use to identity which DownstreamPathTemplate to use for a given request. The UpstreamPathTemplate is the URL that Ocelot will use to identify which DownstreamPathTemplate to use for a given request.
The UpstreamHttpMethod is used so Ocelot can distinguish between requests with different HTTP verbs to the same URL. You can set a specific list of HTTP Methods or set an empty list to allow any of them. The UpstreamHttpMethod is used so Ocelot can distinguish between requests with different HTTP verbs to the same URL. You can set a specific list of HTTP Methods or set an empty list to allow any of them.
In Ocelot you can add placeholders for variables to your Templates in the form of {something}. In Ocelot you can add placeholders for variables to your Templates in the form of {something}.
-6
View File
@@ -1,6 +0,0 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "2.1.500"
}
}
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -15,8 +15,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
<PackageReference Include="Ocelot" Version="5.5.7" /> <PackageReference Include="Ocelot" Version="13.5.1" />
<PackageReference Include="Ocelot.Provider.Eureka" Version="13.5.1" />
<PackageReference Include="Ocelot.Provider.Polly" Version="13.5.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+7 -2
View File
@@ -1,4 +1,7 @@
namespace ApiGateway using Ocelot.Provider.Eureka;
using Ocelot.Provider.Polly;
namespace ApiGateway
{ {
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@@ -27,7 +30,9 @@
}) })
.ConfigureServices(s => .ConfigureServices(s =>
{ {
s.AddOcelot(); s.AddOcelot()
.AddEureka()
.AddPolly();
}) })
.Configure(a => .Configure(a =>
{ {
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -9,7 +9,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
<PackageReference Include="Steeltoe.Discovery.Client" Version="1.1.0" /> <PackageReference Include="Steeltoe.Discovery.Client" Version="1.1.0" />
</ItemGroup> </ItemGroup>
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotGraphQL", "OcelotGraphQL.csproj", "{5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5762C36C-EA4B-44D9-9DAA-2F7C3FC98692}
EndGlobalSection
EndGlobal
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53639/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OcelotGraphQL": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:53640/"
}
}
}
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.1" PrivateAssets="All" /> <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.1.1" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.9" />
<PackageReference Include="Ocelot" Version="13.6.0-alpha0010"/> <PackageReference Include="Ocelot" Version="13.5.1" />
<PackageReference Include="Ocelot.Provider.Kubernetes" Version="13.6.0-alpha0010"/> <PackageReference Include="Ocelot.Provider.Kubernetes" Version="13.5.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -1,10 +1,5 @@
using System; using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection; using Ocelot.DependencyInjection;
using Ocelot.Middleware; using Ocelot.Middleware;
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" /> <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.1.1" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.9" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -1,11 +1,10 @@
namespace Ocelot.Administration namespace Ocelot.Administration
{ {
using System.Threading.Tasks;
using Configuration;
using Configuration.Repository; using Configuration.Repository;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Ocelot.Middleware; using Ocelot.Middleware;
using System.Threading.Tasks;
public static class IdentityServerMiddlewareConfigurationProvider public static class IdentityServerMiddlewareConfigurationProvider
{ {
@@ -29,10 +29,10 @@
<ProjectReference Include="..\Ocelot\Ocelot.csproj" /> <ProjectReference Include="..\Ocelot\Ocelot.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" /> <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
<PackageReference Include="IdentityServer4" Version="2.2.0" /> <PackageReference Include="IdentityServer4" Version="2.4.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -1,14 +1,6 @@
namespace Ocelot.Administration namespace Ocelot.Administration
{ {
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Configuration;
using Configuration.Creator;
using DependencyInjection; using DependencyInjection;
using IdentityModel;
using IdentityServer4.AccessTokenValidation; using IdentityServer4.AccessTokenValidation;
using IdentityServer4.Models; using IdentityServer4.Models;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
@@ -16,6 +8,10 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Ocelot.Middleware; using Ocelot.Middleware;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Cryptography.X509Certificates;
public static class OcelotBuilderExtensions public static class OcelotBuilderExtensions
{ {
@@ -61,7 +57,8 @@
{ {
builder.Services.TryAddSingleton<IIdentityServerConfiguration>(identityServerConfiguration); builder.Services.TryAddSingleton<IIdentityServerConfiguration>(identityServerConfiguration);
var identityServerBuilder = builder.Services var identityServerBuilder = builder.Services
.AddIdentityServer(o => { .AddIdentityServer(o =>
{
o.IssuerUri = "Ocelot"; o.IssuerUri = "Ocelot";
}) })
.AddInMemoryApiResources(Resources(identityServerConfiguration)) .AddInMemoryApiResources(Resources(identityServerConfiguration))
@@ -28,11 +28,11 @@
<ProjectReference Include="..\Ocelot\Ocelot.csproj" /> <ProjectReference Include="..\Ocelot\Ocelot.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="CacheManager.Core" Version="1.1.2" /> <PackageReference Include="CacheManager.Core" Version="1.2.0" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.1.2" /> <PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.2.0" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.1.2" /> <PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.2.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -1,12 +1,12 @@
namespace Ocelot.Cache.CacheManager namespace Ocelot.Cache.CacheManager
{ {
using System;
using Configuration; using Configuration;
using Configuration.File; using Configuration.File;
using DependencyInjection; using DependencyInjection;
using global::CacheManager.Core; using global::CacheManager.Core;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
public static class OcelotBuilderExtensions public static class OcelotBuilderExtensions
{ {
@@ -1,7 +1,7 @@
namespace Ocelot.Cache.CacheManager namespace Ocelot.Cache.CacheManager
{ {
using System;
using global::CacheManager.Core; using global::CacheManager.Core;
using System;
public class OcelotCacheManagerCache<T> : IOcelotCache<T> public class OcelotCacheManagerCache<T> : IOcelotCache<T>
{ {
+16 -8
View File
@@ -1,16 +1,15 @@
namespace Ocelot.Provider.Consul namespace Ocelot.Provider.Consul
{ {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using global::Consul; using global::Consul;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using Logging; using Logging;
using ServiceDiscovery.Providers; using ServiceDiscovery.Providers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Values; using Values;
public class Consul : IServiceDiscoveryProvider public class Consul : IServiceDiscoveryProvider
{ {
private readonly ConsulRegistryConfiguration _config; private readonly ConsulRegistryConfiguration _config;
@@ -35,7 +34,16 @@
{ {
if (IsValid(serviceEntry)) if (IsValid(serviceEntry))
{ {
services.Add(BuildService(serviceEntry)); var nodes = await _consul.Catalog.Nodes();
if (nodes.Response == null)
{
services.Add(BuildService(serviceEntry, null));
}
else
{
var serviceNode = nodes.Response.FirstOrDefault(n => n.Address == serviceEntry.Service.Address);
services.Add(BuildService(serviceEntry, serviceNode));
}
} }
else else
{ {
@@ -46,11 +54,11 @@
return services.ToList(); return services.ToList();
} }
private Service BuildService(ServiceEntry serviceEntry) private Service BuildService(ServiceEntry serviceEntry, Node serviceNode)
{ {
return new Service( return new Service(
serviceEntry.Service.Service, serviceEntry.Service.Service,
new ServiceHostAndPort(serviceEntry.Service.Address, serviceEntry.Service.Port), new ServiceHostAndPort(serviceNode == null ? serviceEntry.Service.Address : serviceNode.Name, serviceEntry.Service.Port),
serviceEntry.Service.ID, serviceEntry.Service.ID,
GetVersionFromStrings(serviceEntry.Service.Tags), GetVersionFromStrings(serviceEntry.Service.Tags),
serviceEntry.Service.Tags ?? Enumerable.Empty<string>()); serviceEntry.Service.Tags ?? Enumerable.Empty<string>());
@@ -1,7 +1,7 @@
namespace Ocelot.Provider.Consul namespace Ocelot.Provider.Consul
{ {
using System;
using global::Consul; using global::Consul;
using System;
public class ConsulClientFactory : IConsulClientFactory public class ConsulClientFactory : IConsulClientFactory
{ {
@@ -1,14 +1,14 @@
namespace Ocelot.Provider.Consul namespace Ocelot.Provider.Consul
{ {
using System;
using System.Text;
using System.Threading.Tasks;
using Configuration.File; using Configuration.File;
using Configuration.Repository; using Configuration.Repository;
using global::Consul; using global::Consul;
using Logging; using Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Responses; using Responses;
using System;
using System.Text;
using System.Threading.Tasks;
public class ConsulFileConfigurationRepository : IFileConfigurationRepository public class ConsulFileConfigurationRepository : IFileConfigurationRepository
{ {
@@ -1,8 +1,5 @@
namespace Ocelot.Provider.Consul namespace Ocelot.Provider.Consul
{ {
using System;
using System.Linq;
using System.Threading.Tasks;
using Configuration.Creator; using Configuration.Creator;
using Configuration.File; using Configuration.File;
using Configuration.Repository; using Configuration.Repository;
@@ -11,6 +8,9 @@
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Middleware; using Middleware;
using Responses; using Responses;
using System;
using System.Linq;
using System.Threading.Tasks;
public static class ConsulMiddlewareConfigurationProvider public static class ConsulMiddlewareConfigurationProvider
{ {
@@ -1,8 +1,6 @@
namespace Ocelot.Provider.Consul namespace Ocelot.Provider.Consul
{ {
using System.Threading.Tasks;
using Logging; using Logging;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using ServiceDiscovery; using ServiceDiscovery;
@@ -30,7 +30,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Consul" Version="0.7.2.6" /> <PackageReference Include="Consul" Version="0.7.2.6" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
@@ -3,6 +3,7 @@
using Configuration.Repository; using Configuration.Repository;
using DependencyInjection; using DependencyInjection;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Middleware; using Middleware;
using ServiceDiscovery; using ServiceDiscovery;
@@ -12,6 +13,8 @@
{ {
builder.Services.AddSingleton<ServiceDiscoveryFinderDelegate>(ConsulProviderFactory.Get); builder.Services.AddSingleton<ServiceDiscoveryFinderDelegate>(ConsulProviderFactory.Get);
builder.Services.AddSingleton<IConsulClientFactory, ConsulClientFactory>(); builder.Services.AddSingleton<IConsulClientFactory, ConsulClientFactory>();
builder.Services.RemoveAll(typeof(IFileConfigurationPollerOptions));
builder.Services.AddSingleton<IFileConfigurationPollerOptions, ConsulFileConfigurationPollerOption>();
return builder; return builder;
} }
@@ -1,10 +1,10 @@
namespace Ocelot.Provider.Consul namespace Ocelot.Provider.Consul
{ {
using Logging;
using ServiceDiscovery.Providers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Logging;
using ServiceDiscovery.Providers;
using Values; using Values;
public class PollConsul : IServiceDiscoveryProvider public class PollConsul : IServiceDiscoveryProvider
+2 -2
View File
@@ -1,10 +1,10 @@
namespace Ocelot.Provider.Eureka namespace Ocelot.Provider.Eureka
{ {
using ServiceDiscovery.Providers;
using Steeltoe.Common.Discovery;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ServiceDiscovery.Providers;
using Steeltoe.Common.Discovery;
using Values; using Values;
public class Eureka : IServiceDiscoveryProvider public class Eureka : IServiceDiscoveryProvider
@@ -1,11 +1,11 @@
namespace Ocelot.Provider.Eureka namespace Ocelot.Provider.Eureka
{ {
using System.Threading.Tasks;
using Configuration; using Configuration;
using Configuration.Repository; using Configuration.Repository;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Middleware; using Middleware;
using Steeltoe.Discovery.Client; using Steeltoe.Discovery.Client;
using System.Threading.Tasks;
public class EurekaMiddlewareConfigurationProvider public class EurekaMiddlewareConfigurationProvider
{ {
@@ -2,7 +2,6 @@
{ {
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using ServiceDiscovery; using ServiceDiscovery;
using ServiceDiscovery.Providers;
using Steeltoe.Common.Discovery; using Steeltoe.Common.Discovery;
public static class EurekaProviderFactory public static class EurekaProviderFactory
@@ -30,7 +30,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="2.2.0" /> <PackageReference Include="Steeltoe.Discovery.ClientCore" Version="2.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
@@ -1,12 +1,12 @@
namespace Ocelot.Provider.Eureka namespace Ocelot.Provider.Eureka
{ {
using System.Linq;
using DependencyInjection; using DependencyInjection;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Middleware; using Middleware;
using Steeltoe.Discovery.Client;
using ServiceDiscovery; using ServiceDiscovery;
using Steeltoe.Discovery.Client;
using System.Linq;
public static class OcelotBuilderExtensions public static class OcelotBuilderExtensions
{ {
@@ -1,7 +1,4 @@
using KubeClient; namespace Ocelot.Provider.Kubernetes
using System;
namespace Ocelot.Provider.Kubernetes
{ {
public class KubeRegistryConfiguration public class KubeRegistryConfiguration
{ {
@@ -30,8 +30,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="KubeClient" Version="2.2.11" /> <PackageReference Include="KubeClient" Version="2.2.12" />
<PackageReference Include="KubeClient.Extensions.DependencyInjection" Version="2.2.11" /> <PackageReference Include="KubeClient.Extensions.DependencyInjection" Version="2.2.12" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+1 -3
View File
@@ -1,8 +1,6 @@
using Polly;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Polly;
using Polly.CircuitBreaker;
using Polly.Timeout;
namespace Ocelot.Provider.Polly namespace Ocelot.Provider.Polly
{ {
@@ -29,9 +29,9 @@
<ProjectReference Include="..\Ocelot\Ocelot.csproj" /> <ProjectReference Include="..\Ocelot\Ocelot.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Polly" Version="6.0.1" /> <PackageReference Include="Polly" Version="7.1.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -1,9 +1,5 @@
namespace Ocelot.Provider.Polly namespace Ocelot.Provider.Polly
{ {
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Configuration; using Configuration;
using DependencyInjection; using DependencyInjection;
using Errors; using Errors;
@@ -12,6 +8,10 @@
using Logging; using Logging;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Requester; using Requester;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
public static class OcelotBuilderExtensions public static class OcelotBuilderExtensions
{ {
@@ -1,9 +1,9 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Ocelot.Logging; using Ocelot.Logging;
using Polly; using Polly;
using Polly.CircuitBreaker; using Polly.CircuitBreaker;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace Ocelot.Provider.Polly namespace Ocelot.Provider.Polly
{ {
@@ -1,17 +1,17 @@
namespace Ocelot.Provider.Polly namespace Ocelot.Provider.Polly
{ {
using System;
using System.Net.Http;
using global::Polly; using global::Polly;
using global::Polly.CircuitBreaker; using global::Polly.CircuitBreaker;
using global::Polly.Timeout; using global::Polly.Timeout;
using Ocelot.Configuration; using Ocelot.Configuration;
using Ocelot.Logging; using Ocelot.Logging;
using System;
using System.Net.Http;
public class PollyQoSProvider public class PollyQoSProvider
{ {
private readonly CircuitBreakerPolicy _circuitBreakerPolicy; private readonly AsyncCircuitBreakerPolicy _circuitBreakerPolicy;
private readonly TimeoutPolicy _timeoutPolicy; private readonly AsyncTimeoutPolicy _timeoutPolicy;
private readonly IOcelotLogger _logger; private readonly IOcelotLogger _logger;
public PollyQoSProvider(DownstreamReRoute reRoute, IOcelotLoggerFactory loggerFactory) public PollyQoSProvider(DownstreamReRoute reRoute, IOcelotLoggerFactory loggerFactory)
@@ -1,7 +1,7 @@
namespace Ocelot.Provider.Polly namespace Ocelot.Provider.Polly
{ {
using System;
using Errors; using Errors;
using System;
public class RequestTimedOutError : Error public class RequestTimedOutError : Error
{ {
@@ -1,14 +1,13 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using System.Net.Http; using Administration;
using Configuration;
using Configuration.Repository; using Configuration.Repository;
using global::Rafty.Concensus.Peers; using global::Rafty.Concensus.Peers;
using global::Rafty.Infrastructure; using global::Rafty.Infrastructure;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Middleware; using Middleware;
using System.Collections.Generic; using System.Collections.Generic;
using Administration; using System.Net.Http;
public class FilePeersProvider : IPeersProvider public class FilePeersProvider : IPeersProvider
{ {
+3 -3
View File
@@ -1,7 +1,6 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using System.Net.Http; using Administration;
using System.Threading.Tasks;
using Configuration; using Configuration;
using global::Rafty.Concensus.Messages; using global::Rafty.Concensus.Messages;
using global::Rafty.Concensus.Peers; using global::Rafty.Concensus.Peers;
@@ -11,7 +10,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Administration; using System.Net.Http;
using System.Threading.Tasks;
public class HttpPeer : IPeer public class HttpPeer : IPeer
{ {
@@ -30,9 +30,9 @@
<ProjectReference Include="..\Ocelot.Administration\Ocelot.Administration.csproj" /> <ProjectReference Include="..\Ocelot.Administration\Ocelot.Administration.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Data.SQLite" Version="2.2.0"/> <PackageReference Include="Microsoft.Data.SQLite" Version="2.2.4" />
<PackageReference Include="Rafty" Version="0.4.4" /> <PackageReference Include="Rafty" Version="0.4.4" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
@@ -1,9 +1,9 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using System.Threading.Tasks;
using Configuration.Setter; using Configuration.Setter;
using global::Rafty.FiniteStateMachine; using global::Rafty.FiniteStateMachine;
using global::Rafty.Log; using global::Rafty.Log;
using System.Threading.Tasks;
public class OcelotFiniteStateMachine : IFiniteStateMachine public class OcelotFiniteStateMachine : IFiniteStateMachine
{ {
+3 -3
View File
@@ -1,8 +1,5 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using System;
using System.IO;
using System.Threading.Tasks;
using global::Rafty.Concensus.Messages; using global::Rafty.Concensus.Messages;
using global::Rafty.Concensus.Node; using global::Rafty.Concensus.Node;
using global::Rafty.FiniteStateMachine; using global::Rafty.FiniteStateMachine;
@@ -11,6 +8,9 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Middleware; using Middleware;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.IO;
using System.Threading.Tasks;
[Authorize] [Authorize]
[Route("raft")] [Route("raft")]
@@ -1,10 +1,10 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using System.Threading.Tasks;
using Configuration.File; using Configuration.File;
using Configuration.Setter; using Configuration.Setter;
using global::Rafty.Concensus.Node; using global::Rafty.Concensus.Node;
using global::Rafty.Infrastructure; using global::Rafty.Infrastructure;
using System.Threading.Tasks;
public class RaftyFileConfigurationSetter : IFileConfigurationSetter public class RaftyFileConfigurationSetter : IFileConfigurationSetter
{ {
@@ -1,12 +1,12 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using System.Threading.Tasks;
using global::Rafty.Concensus.Node; using global::Rafty.Concensus.Node;
using global::Rafty.Infrastructure; using global::Rafty.Infrastructure;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Middleware; using Middleware;
using Microsoft.AspNetCore.Hosting; using System.Threading.Tasks;
public static class RaftyMiddlewareConfigurationProvider public static class RaftyMiddlewareConfigurationProvider
{ {
+5 -5
View File
@@ -1,15 +1,15 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using global::Rafty.Infrastructure; using global::Rafty.Infrastructure;
using global::Rafty.Log; using global::Rafty.Log;
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
public class SqlLiteLog : ILog public class SqlLiteLog : ILog
{ {
@@ -1,6 +1,7 @@
namespace Ocelot.Provider.Rafty namespace Ocelot.Provider.Rafty
{ {
using Errors; using Errors;
public class UnableToSaveAcceptCommand : Error public class UnableToSaveAcceptCommand : Error
{ {
public UnableToSaveAcceptCommand(string message) public UnableToSaveAcceptCommand(string message)
@@ -1,17 +1,17 @@
namespace Ocelot.Tracing.Butterfly namespace Ocelot.Tracing.Butterfly
{ {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using global::Butterfly.Client.AspNetCore; using global::Butterfly.Client.AspNetCore;
using global::Butterfly.Client.Tracing; using global::Butterfly.Client.Tracing;
using global::Butterfly.OpenTracing; using global::Butterfly.OpenTracing;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
public class ButterflyTracer : DelegatingHandler, Logging.ITracer public class ButterflyTracer : DelegatingHandler, Logging.ITracer
{ {
@@ -1,10 +1,10 @@
namespace Ocelot.Tracing.Butterfly namespace Ocelot.Tracing.Butterfly
{ {
using System;
using DependencyInjection; using DependencyInjection;
using global::Butterfly.Client.AspNetCore; using global::Butterfly.Client.AspNetCore;
using Logging; using Logging;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System;
public static class OcelotBuilderExtensions public static class OcelotBuilderExtensions
{ {
@@ -1,11 +1,8 @@
using System.Collections.Generic; using Microsoft.AspNetCore.Authentication;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Ocelot.Configuration; using Ocelot.Configuration;
using Ocelot.Errors;
using Ocelot.Infrastructure.Extensions;
using Ocelot.Logging; using Ocelot.Logging;
using Ocelot.Middleware; using Ocelot.Middleware;
using System.Threading.Tasks;
namespace Ocelot.Authentication.Middleware namespace Ocelot.Authentication.Middleware
{ {
+4 -8
View File
@@ -1,14 +1,10 @@
using System; using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
namespace Ocelot.Authorisation namespace Ocelot.Authorisation
{ {
using Infrastructure.Claims.Parser; using Infrastructure.Claims.Parser;
@@ -26,7 +22,8 @@ namespace Ocelot.Authorisation
ClaimsPrincipal claimsPrincipal, ClaimsPrincipal claimsPrincipal,
Dictionary<string, string> routeClaimsRequirement, Dictionary<string, string> routeClaimsRequirement,
List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
){ )
{
foreach (var required in routeClaimsRequirement) foreach (var required in routeClaimsRequirement)
{ {
var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key); var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key);
@@ -70,7 +67,6 @@ namespace Ocelot.Authorisation
$"config error: requires variable claim value: {required.Value} but placeholders are ambiguous: {string.Join(", ", urlPathPlaceholderNameAndValues.Where(p => p.Name.Equals(variableName)).Select(p => p.Value))}")); $"config error: requires variable claim value: {required.Value} but placeholders are ambiguous: {string.Join(", ", urlPathPlaceholderNameAndValues.Where(p => p.Name.Equals(variableName)).Select(p => p.Value))}"));
} }
} }
} }
else else
{ {
@@ -1,9 +1,6 @@
using System.Security.Claims; using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Configuration;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses; using Ocelot.Responses;
using Ocelot.Values; using System.Security.Claims;
namespace Ocelot.Authorisation namespace Ocelot.Authorisation
{ {
@@ -1,5 +1,5 @@
using System.Security.Claims; using Ocelot.Responses;
using Ocelot.Responses; using System.Security.Claims;
namespace Ocelot.Authorisation namespace Ocelot.Authorisation
{ {
@@ -1,12 +1,10 @@
namespace Ocelot.Authorisation.Middleware namespace Ocelot.Authorisation.Middleware
{ {
using System.Collections.Generic;
using System.Threading.Tasks;
using Errors;
using Ocelot.Middleware;
using Logging;
using Responses;
using Configuration; using Configuration;
using Logging;
using Ocelot.Middleware;
using Responses;
using System.Threading.Tasks;
public class AuthorisationMiddleware : OcelotMiddleware public class AuthorisationMiddleware : OcelotMiddleware
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
using Ocelot.Responses; using Ocelot.Responses;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Claims;
using System.Linq; using System.Linq;
using System.Security.Claims;
namespace Ocelot.Authorisation namespace Ocelot.Authorisation
{ {
+10 -6
View File
@@ -1,13 +1,17 @@
using System.Text; using Ocelot.Middleware;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ocelot.Middleware;
namespace Ocelot.Cache { namespace Ocelot.Cache
public class CacheKeyGenerator : ICacheKeyGenerator { {
public string GenerateRequestCacheKey(DownstreamContext context) { public class CacheKeyGenerator : ICacheKeyGenerator
{
public string GenerateRequestCacheKey(DownstreamContext context)
{
string hashedContent = null; string hashedContent = null;
StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}"); StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}");
if (context.DownstreamRequest.Content != null) { if (context.DownstreamRequest.Content != null)
{
string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content.ReadAsStringAsync()).Result; string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content.ReadAsStringAsync()).Result;
downStreamUrlKeyBuilder.Append(requestContentString); downStreamUrlKeyBuilder.Append(requestContentString);
} }
+1 -1
View File
@@ -2,7 +2,7 @@
{ {
using System; using System;
class CacheObject<T> internal class CacheObject<T>
{ {
public CacheObject(T value, DateTime expires) public CacheObject(T value, DateTime expires)
{ {
+4 -2
View File
@@ -1,7 +1,9 @@
using Ocelot.Middleware; using Ocelot.Middleware;
namespace Ocelot.Cache { namespace Ocelot.Cache
public interface ICacheKeyGenerator { {
public interface ICacheKeyGenerator
{
string GenerateRequestCacheKey(DownstreamContext context); string GenerateRequestCacheKey(DownstreamContext context);
} }
} }
+3
View File
@@ -5,8 +5,11 @@ namespace Ocelot.Cache
public interface IOcelotCache<T> public interface IOcelotCache<T>
{ {
void Add(string key, T value, TimeSpan ttl, string region); void Add(string key, T value, TimeSpan ttl, string region);
T Get(string key, string region); T Get(string key, string region);
void ClearRegion(string region); void ClearRegion(string region);
void AddAndDelete(string key, T value, TimeSpan ttl, string region); void AddAndDelete(string key, T value, TimeSpan ttl, string region);
} }
} }
+10 -5
View File
@@ -1,20 +1,25 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
namespace Ocelot.Cache { namespace Ocelot.Cache
public static class MD5Helper { {
public static string GenerateMd5(byte[] contentBytes) { public static class MD5Helper
{
public static string GenerateMd5(byte[] contentBytes)
{
MD5 md5 = MD5.Create(); MD5 md5 = MD5.Create();
byte[] hash = md5.ComputeHash(contentBytes); byte[] hash = md5.ComputeHash(contentBytes);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++) { for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2")); sb.Append(hash[i].ToString("X2"));
} }
return sb.ToString(); return sb.ToString();
} }
public static string GenerateMd5(string contentString) { public static string GenerateMd5(string contentString)
{
byte[] contentBytes = Encoding.Unicode.GetBytes(contentString); byte[] contentBytes = Encoding.Unicode.GetBytes(contentString);
return GenerateMd5(contentBytes); return GenerateMd5(contentBytes);
} }
@@ -1,13 +1,13 @@
namespace Ocelot.Cache.Middleware namespace Ocelot.Cache.Middleware
{ {
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Ocelot.Logging; using Ocelot.Logging;
using Ocelot.Middleware; using Ocelot.Middleware;
using System;
using System.IO; using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks;
public class OutputCacheMiddleware : OcelotMiddleware public class OutputCacheMiddleware : OcelotMiddleware
{ {
@@ -77,6 +77,20 @@
context.DownstreamResponse = response; context.DownstreamResponse = response;
} }
private string GenerateRequestCacheKey(DownstreamContext context)
{
string hashedContent = null;
StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}");
if (context.DownstreamRequest.Content != null)
{
string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content?.ReadAsStringAsync()).Result;
downStreamUrlKeyBuilder.Append(requestContentString);
}
hashedContent = MD5Helper.GenerateMd5(downStreamUrlKeyBuilder.ToString());
return hashedContent;
}
internal DownstreamResponse CreateHttpResponseMessage(CachedResponse cached) internal DownstreamResponse CreateHttpResponseMessage(CachedResponse cached)
{ {
if (cached == null) if (cached == null)
+1 -2
View File
@@ -1,6 +1,5 @@
using System.Linq;
using Ocelot.Configuration;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
using System.Linq;
namespace Ocelot.Cache namespace Ocelot.Cache
{ {
+4 -4
View File
@@ -1,10 +1,10 @@
using System.Collections.Generic; using Microsoft.AspNetCore.Http;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration; using Ocelot.Configuration;
using Ocelot.Infrastructure.Claims.Parser; using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Responses; using Ocelot.Responses;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
namespace Ocelot.Claims namespace Ocelot.Claims
{ {
+2 -2
View File
@@ -1,7 +1,7 @@
using System.Collections.Generic; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration; using Ocelot.Configuration;
using Ocelot.Responses; using Ocelot.Responses;
using System.Collections.Generic;
namespace Ocelot.Claims namespace Ocelot.Claims
{ {
@@ -1,10 +1,7 @@
using System.Linq; using Ocelot.Logging;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Logging;
using Ocelot.Middleware; using Ocelot.Middleware;
using System.Linq;
using System.Threading.Tasks;
namespace Ocelot.Claims.Middleware namespace Ocelot.Claims.Middleware
{ {
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Net.Http;
using Ocelot.Values;
using System.Linq;
using Ocelot.Configuration.Creator; using Ocelot.Configuration.Creator;
using Ocelot.Values;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
namespace Ocelot.Configuration.Builder namespace Ocelot.Configuration.Builder
{ {
@@ -39,6 +39,7 @@ namespace Ocelot.Configuration.Builder
private List<AddHeader> _addHeadersToUpstream; private List<AddHeader> _addHeadersToUpstream;
private bool _dangerousAcceptAnyServerCertificateValidator; private bool _dangerousAcceptAnyServerCertificateValidator;
private SecurityOptions _securityOptions; private SecurityOptions _securityOptions;
public DownstreamReRouteBuilder() public DownstreamReRouteBuilder()
{ {
_downstreamAddresses = new List<DownstreamHostAndPort>(); _downstreamAddresses = new List<DownstreamHostAndPort>();
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Builder namespace Ocelot.Configuration.Builder
{ {
using System.Collections.Generic;
using System.Net.Http;
using Ocelot.Values;
using System.Linq;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
using Ocelot.Values;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
public class ReRouteBuilder public class ReRouteBuilder
{ {
@@ -1,9 +1,9 @@
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
using System.Collections.Generic;
using System.Linq;
using Builder; using Builder;
using File; using File;
using System.Collections.Generic;
using System.Linq;
public class AggregatesCreator : IAggregatesCreator public class AggregatesCreator : IAggregatesCreator
{ {
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Ocelot.Configuration.Parser; using Ocelot.Configuration.Parser;
using Ocelot.Logging; using Ocelot.Logging;
using System.Collections.Generic;
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
using DependencyInjection;
using File;
using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using File;
using DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
public class ConfigurationCreator : IConfigurationCreator public class ConfigurationCreator : IConfigurationCreator
{ {
@@ -1,6 +1,6 @@
using Ocelot.Configuration.File;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Ocelot.Configuration.File;
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
@@ -1,9 +1,9 @@
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
using System.Collections.Generic;
using System.Linq;
using Builder; using Builder;
using File; using File;
using System.Collections.Generic;
using System.Linq;
public class DynamicsCreator : IDynamicsCreator public class DynamicsCreator : IDynamicsCreator
{ {
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
using File;
using Responses;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using File;
using Validator; using Validator;
using Responses;
public class FileInternalConfigurationCreator : IInternalConfigurationCreator public class FileInternalConfigurationCreator : IInternalConfigurationCreator
{ {
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
using Ocelot.Infrastructure; using Ocelot.Infrastructure;
using Ocelot.Infrastructure.Extensions; using Ocelot.Infrastructure.Extensions;
using Ocelot.Logging; using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Responses; using Ocelot.Responses;
using System.Collections.Generic;
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
@@ -1,9 +1,9 @@
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
using System;
using Logging; using Logging;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
using System;
public class HttpHandlerOptionsCreator : IHttpHandlerOptionsCreator public class HttpHandlerOptionsCreator : IHttpHandlerOptionsCreator
{ {
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
using System.Collections.Generic;
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
using System.Collections.Generic;
namespace Ocelot.Configuration.Creator namespace Ocelot.Configuration.Creator
{ {

Some files were not shown because too many files have changed in this diff Show More