mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 15:30:49 +08:00 
			
		
		
		
	Fixed Merge Conflicts
This commit is contained in:
		@@ -4,10 +4,10 @@ namespace Ocelot.Administration
 | 
			
		||||
 | 
			
		||||
    public interface IIdentityServerConfiguration
 | 
			
		||||
    {
 | 
			
		||||
        string ApiName { get;  }
 | 
			
		||||
        string ApiSecret { get;  }
 | 
			
		||||
        bool RequireHttps { get;  }
 | 
			
		||||
        List<string> AllowedScopes { get;  }
 | 
			
		||||
        string ApiName { get; }
 | 
			
		||||
        string ApiSecret { get; }
 | 
			
		||||
        bool RequireHttps { get; }
 | 
			
		||||
        List<string> AllowedScopes { get; }
 | 
			
		||||
        string CredentialsSigningCertificateLocation { get; }
 | 
			
		||||
        string CredentialsSigningCertificatePassword { get; }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,11 +5,11 @@ namespace Ocelot.Administration
 | 
			
		||||
    public class IdentityServerConfiguration : IIdentityServerConfiguration
 | 
			
		||||
    {
 | 
			
		||||
        public IdentityServerConfiguration(
 | 
			
		||||
            string apiName, 
 | 
			
		||||
            bool requireHttps, 
 | 
			
		||||
            string apiName,
 | 
			
		||||
            bool requireHttps,
 | 
			
		||||
            string apiSecret,
 | 
			
		||||
            List<string> allowedScopes,
 | 
			
		||||
            string credentialsSigningCertificateLocation, 
 | 
			
		||||
            string credentialsSigningCertificateLocation,
 | 
			
		||||
            string credentialsSigningCertificatePassword)
 | 
			
		||||
        {
 | 
			
		||||
            ApiName = apiName;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,10 @@
 | 
			
		||||
namespace Ocelot.Administration
 | 
			
		||||
{
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using Configuration.Repository;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public static class IdentityServerMiddlewareConfigurationProvider
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -29,10 +29,10 @@
 | 
			
		||||
    <ProjectReference Include="..\Ocelot\Ocelot.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
 | 
			
		||||
      <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
    <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" />
 | 
			
		||||
    <PackageReference Include="IdentityServer4" Version="2.2.0" />
 | 
			
		||||
    <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
 | 
			
		||||
    <PackageReference Include="IdentityServer4" Version="2.4.0" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,6 @@
 | 
			
		||||
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 IdentityModel;
 | 
			
		||||
    using IdentityServer4.AccessTokenValidation;
 | 
			
		||||
    using IdentityServer4.Models;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
@@ -16,6 +8,10 @@
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection.Extensions;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.IdentityModel.Tokens.Jwt;
 | 
			
		||||
    using System.Security.Cryptography.X509Certificates;
 | 
			
		||||
 | 
			
		||||
    public static class OcelotBuilderExtensions
 | 
			
		||||
    {
 | 
			
		||||
@@ -61,7 +57,8 @@
 | 
			
		||||
        {
 | 
			
		||||
            builder.Services.TryAddSingleton<IIdentityServerConfiguration>(identityServerConfiguration);
 | 
			
		||||
            var identityServerBuilder = builder.Services
 | 
			
		||||
                .AddIdentityServer(o => {
 | 
			
		||||
                .AddIdentityServer(o =>
 | 
			
		||||
                {
 | 
			
		||||
                    o.IssuerUri = "Ocelot";
 | 
			
		||||
                })
 | 
			
		||||
                .AddInMemoryApiResources(Resources(identityServerConfiguration))
 | 
			
		||||
 
 | 
			
		||||
@@ -28,11 +28,11 @@
 | 
			
		||||
    <ProjectReference Include="..\Ocelot\Ocelot.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
 | 
			
		||||
      <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
    <PackageReference Include="CacheManager.Core" Version="1.1.2" />
 | 
			
		||||
    <PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.1.2" />
 | 
			
		||||
    <PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.1.2" />
 | 
			
		||||
    <PackageReference Include="CacheManager.Core" Version="1.2.0" />
 | 
			
		||||
    <PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.2.0" />
 | 
			
		||||
    <PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.2.0" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,12 @@
 | 
			
		||||
namespace Ocelot.Cache.CacheManager
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using Configuration.File;
 | 
			
		||||
    using DependencyInjection;
 | 
			
		||||
    using global::CacheManager.Core;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection.Extensions;
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public static class OcelotBuilderExtensions
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
namespace Ocelot.Cache.CacheManager
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using global::CacheManager.Core;
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public class OcelotCacheManagerCache<T> : IOcelotCache<T>
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,15 @@
 | 
			
		||||
namespace Ocelot.Provider.Consul
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using global::Consul;
 | 
			
		||||
    using Infrastructure.Extensions;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using ServiceDiscovery.Providers;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Values;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public class Consul : IServiceDiscoveryProvider
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ConsulRegistryConfiguration _config;
 | 
			
		||||
@@ -35,7 +34,16 @@
 | 
			
		||||
            {
 | 
			
		||||
                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
 | 
			
		||||
                {
 | 
			
		||||
@@ -46,11 +54,11 @@
 | 
			
		||||
            return services.ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Service BuildService(ServiceEntry serviceEntry)
 | 
			
		||||
        private Service BuildService(ServiceEntry serviceEntry, Node serviceNode)
 | 
			
		||||
        {
 | 
			
		||||
            return new 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,
 | 
			
		||||
                GetVersionFromStrings(serviceEntry.Service.Tags),
 | 
			
		||||
                serviceEntry.Service.Tags ?? Enumerable.Empty<string>());
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
namespace Ocelot.Provider.Consul
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using global::Consul;
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public class ConsulClientFactory : IConsulClientFactory
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,14 @@
 | 
			
		||||
namespace Ocelot.Provider.Consul
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Text;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Configuration.File;
 | 
			
		||||
    using Configuration.Repository;
 | 
			
		||||
    using global::Consul;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using Newtonsoft.Json;
 | 
			
		||||
    using Responses;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Text;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class ConsulFileConfigurationRepository : IFileConfigurationRepository
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,5 @@
 | 
			
		||||
namespace Ocelot.Provider.Consul
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Configuration.Creator;
 | 
			
		||||
    using Configuration.File;
 | 
			
		||||
    using Configuration.Repository;
 | 
			
		||||
@@ -11,6 +8,9 @@
 | 
			
		||||
    using Microsoft.Extensions.Options;
 | 
			
		||||
    using Middleware;
 | 
			
		||||
    using Responses;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public static class ConsulMiddlewareConfigurationProvider
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,6 @@
 | 
			
		||||
namespace Ocelot.Provider.Consul
 | 
			
		||||
{
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using ServiceDiscovery;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <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>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@
 | 
			
		||||
    using Configuration.Repository;
 | 
			
		||||
    using DependencyInjection;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection.Extensions;
 | 
			
		||||
    using Middleware;
 | 
			
		||||
    using ServiceDiscovery;
 | 
			
		||||
 | 
			
		||||
@@ -12,6 +13,8 @@
 | 
			
		||||
        {
 | 
			
		||||
            builder.Services.AddSingleton<ServiceDiscoveryFinderDelegate>(ConsulProviderFactory.Get);
 | 
			
		||||
            builder.Services.AddSingleton<IConsulClientFactory, ConsulClientFactory>();
 | 
			
		||||
            builder.Services.RemoveAll(typeof(IFileConfigurationPollerOptions));
 | 
			
		||||
            builder.Services.AddSingleton<IFileConfigurationPollerOptions, ConsulFileConfigurationPollerOption>();
 | 
			
		||||
            return builder;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
namespace Ocelot.Provider.Consul
 | 
			
		||||
{
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using ServiceDiscovery.Providers;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Threading;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using ServiceDiscovery.Providers;
 | 
			
		||||
    using Values;
 | 
			
		||||
 | 
			
		||||
    public class PollConsul : IServiceDiscoveryProvider
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
 | 
			
		||||
    public class UnableToSetConfigInConsulError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public UnableToSetConfigInConsulError(string s) 
 | 
			
		||||
        public UnableToSetConfigInConsulError(string s)
 | 
			
		||||
            : base(s, OcelotErrorCode.UnknownError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
namespace Ocelot.Provider.Eureka
 | 
			
		||||
{
 | 
			
		||||
    using ServiceDiscovery.Providers;
 | 
			
		||||
    using Steeltoe.Common.Discovery;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using ServiceDiscovery.Providers;
 | 
			
		||||
    using Steeltoe.Common.Discovery;
 | 
			
		||||
    using Values;
 | 
			
		||||
 | 
			
		||||
    public class Eureka : IServiceDiscoveryProvider
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
namespace Ocelot.Provider.Eureka
 | 
			
		||||
{
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using Configuration.Repository;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Middleware;
 | 
			
		||||
    using Steeltoe.Discovery.Client;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class EurekaMiddlewareConfigurationProvider
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@
 | 
			
		||||
{
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using ServiceDiscovery;
 | 
			
		||||
    using ServiceDiscovery.Providers;
 | 
			
		||||
    using Steeltoe.Common.Discovery;
 | 
			
		||||
 | 
			
		||||
    public static class EurekaProviderFactory
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <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>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,12 @@
 | 
			
		||||
namespace Ocelot.Provider.Eureka
 | 
			
		||||
{
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using DependencyInjection;
 | 
			
		||||
    using Microsoft.Extensions.Configuration;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Middleware;
 | 
			
		||||
    using Steeltoe.Discovery.Client;
 | 
			
		||||
    using ServiceDiscovery;
 | 
			
		||||
    using Steeltoe.Discovery.Client;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
 | 
			
		||||
    public static class OcelotBuilderExtensions
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,4 @@
 | 
			
		||||
using KubeClient;
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Provider.Kubernetes
 | 
			
		||||
namespace Ocelot.Provider.Kubernetes
 | 
			
		||||
{
 | 
			
		||||
    public class KubeRegistryConfiguration
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,8 +30,8 @@
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="KubeClient" Version="2.2.11" />
 | 
			
		||||
    <PackageReference Include="KubeClient.Extensions.DependencyInjection" Version="2.2.11" />
 | 
			
		||||
    <PackageReference Include="KubeClient" Version="2.2.12" />
 | 
			
		||||
    <PackageReference Include="KubeClient.Extensions.DependencyInjection" Version="2.2.12" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,13 @@
 | 
			
		||||
using Polly;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Polly;
 | 
			
		||||
using Polly.CircuitBreaker;
 | 
			
		||||
using Polly.Timeout;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Provider.Polly
 | 
			
		||||
{
 | 
			
		||||
    public class CircuitBreaker
 | 
			
		||||
    {
 | 
			
		||||
        private readonly List<IAsyncPolicy> _policies = new List<IAsyncPolicy>();
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        public CircuitBreaker(params IAsyncPolicy[] policies)
 | 
			
		||||
        {
 | 
			
		||||
            foreach (var policy in policies.Where(p => p != null))
 | 
			
		||||
@@ -17,7 +15,7 @@ namespace Ocelot.Provider.Polly
 | 
			
		||||
                this._policies.Add(policy);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        public IAsyncPolicy[] Policies => this._policies.ToArray();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,9 +29,9 @@
 | 
			
		||||
    <ProjectReference Include="..\Ocelot\Ocelot.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
 | 
			
		||||
      <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
    <PackageReference Include="Polly" Version="6.0.1" />
 | 
			
		||||
    <PackageReference Include="Polly" Version="7.1.0" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,5 @@
 | 
			
		||||
namespace Ocelot.Provider.Polly
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using DependencyInjection;
 | 
			
		||||
    using Errors;
 | 
			
		||||
@@ -12,6 +8,10 @@
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Requester;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public static class OcelotBuilderExtensions
 | 
			
		||||
    {
 | 
			
		||||
@@ -31,7 +31,7 @@
 | 
			
		||||
                return new PollyCircuitBreakingDelegatingHandler(new PollyQoSProvider(reRoute, logger), logger);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            builder.Services.AddSingleton((QosDelegatingHandlerDelegate) QosDelegatingHandlerDelegate);
 | 
			
		||||
            builder.Services.AddSingleton((QosDelegatingHandlerDelegate)QosDelegatingHandlerDelegate);
 | 
			
		||||
            return builder;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
using System.Net.Http;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Ocelot.Logging;
 | 
			
		||||
using Polly;
 | 
			
		||||
using Polly.CircuitBreaker;
 | 
			
		||||
using System.Net.Http;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Provider.Polly
 | 
			
		||||
{
 | 
			
		||||
@@ -26,11 +26,11 @@ namespace Ocelot.Provider.Polly
 | 
			
		||||
            {
 | 
			
		||||
                return await Policy
 | 
			
		||||
                    .WrapAsync(_qoSProvider.CircuitBreaker.Policies)
 | 
			
		||||
                    .ExecuteAsync(() => base.SendAsync(request,cancellationToken));
 | 
			
		||||
                    .ExecuteAsync(() => base.SendAsync(request, cancellationToken));
 | 
			
		||||
            }
 | 
			
		||||
            catch (BrokenCircuitException ex)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError($"Reached to allowed number of exceptions. Circuit is open",ex);
 | 
			
		||||
                _logger.LogError($"Reached to allowed number of exceptions. Circuit is open", ex);
 | 
			
		||||
                throw;
 | 
			
		||||
            }
 | 
			
		||||
            catch (HttpRequestException ex)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,17 +1,17 @@
 | 
			
		||||
namespace Ocelot.Provider.Polly
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using global::Polly;
 | 
			
		||||
    using global::Polly.CircuitBreaker;
 | 
			
		||||
    using global::Polly.Timeout;
 | 
			
		||||
    using Ocelot.Configuration;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
 | 
			
		||||
    public class PollyQoSProvider
 | 
			
		||||
    {
 | 
			
		||||
        private readonly CircuitBreakerPolicy _circuitBreakerPolicy;
 | 
			
		||||
        private readonly TimeoutPolicy _timeoutPolicy;
 | 
			
		||||
        private readonly AsyncCircuitBreakerPolicy _circuitBreakerPolicy;
 | 
			
		||||
        private readonly AsyncTimeoutPolicy _timeoutPolicy;
 | 
			
		||||
        private readonly IOcelotLogger _logger;
 | 
			
		||||
 | 
			
		||||
        public PollyQoSProvider(DownstreamReRoute reRoute, IOcelotLoggerFactory loggerFactory)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
namespace Ocelot.Provider.Polly
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using Errors;
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public class RequestTimedOutError : Error
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,13 @@
 | 
			
		||||
namespace Ocelot.Provider.Rafty
 | 
			
		||||
{
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using Administration;
 | 
			
		||||
    using Configuration.Repository;
 | 
			
		||||
    using global::Rafty.Concensus.Peers;
 | 
			
		||||
    using global::Rafty.Infrastructure;
 | 
			
		||||
    using Microsoft.Extensions.Options;
 | 
			
		||||
    using Middleware;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using Administration;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
 | 
			
		||||
    public class FilePeersProvider : IPeersProvider
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
namespace Ocelot.Provider.Rafty
 | 
			
		||||
{
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Administration;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using global::Rafty.Concensus.Messages;
 | 
			
		||||
    using global::Rafty.Concensus.Peers;
 | 
			
		||||
@@ -11,7 +10,8 @@
 | 
			
		||||
    using Newtonsoft.Json;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using Administration;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class HttpPeer : IPeer
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,9 +30,9 @@
 | 
			
		||||
    <ProjectReference Include="..\Ocelot.Administration\Ocelot.Administration.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="Microsoft.Data.SQLite" Version="2.2.0"/>
 | 
			
		||||
    <PackageReference Include="Rafty" Version="0.4.4"/>
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
 | 
			
		||||
    <PackageReference Include="Microsoft.Data.SQLite" Version="2.2.4" />
 | 
			
		||||
    <PackageReference Include="Rafty" Version="0.4.4" />
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
 | 
			
		||||
      <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
namespace Ocelot.Provider.Rafty
 | 
			
		||||
{
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Configuration.Setter;
 | 
			
		||||
    using global::Rafty.FiniteStateMachine;
 | 
			
		||||
    using global::Rafty.Log;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class OcelotFiniteStateMachine : IFiniteStateMachine
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,5 @@
 | 
			
		||||
namespace Ocelot.Provider.Rafty
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using global::Rafty.Concensus.Messages;
 | 
			
		||||
    using global::Rafty.Concensus.Node;
 | 
			
		||||
    using global::Rafty.FiniteStateMachine;
 | 
			
		||||
@@ -11,6 +8,9 @@
 | 
			
		||||
    using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
    using Middleware;
 | 
			
		||||
    using Newtonsoft.Json;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    [Authorize]
 | 
			
		||||
    [Route("raft")]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
namespace Ocelot.Provider.Rafty
 | 
			
		||||
{
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Configuration.File;
 | 
			
		||||
    using Configuration.Setter;
 | 
			
		||||
    using global::Rafty.Concensus.Node;
 | 
			
		||||
    using global::Rafty.Infrastructure;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class RaftyFileConfigurationSetter : IFileConfigurationSetter
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,12 @@
 | 
			
		||||
namespace Ocelot.Provider.Rafty
 | 
			
		||||
{
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using global::Rafty.Concensus.Node;
 | 
			
		||||
    using global::Rafty.Infrastructure;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Middleware;
 | 
			
		||||
    using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public static class RaftyMiddlewareConfigurationProvider
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,15 @@
 | 
			
		||||
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.Log;
 | 
			
		||||
    using Microsoft.Data.Sqlite;
 | 
			
		||||
    using Microsoft.Extensions.Logging;
 | 
			
		||||
    using Newtonsoft.Json;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using System.Threading;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class SqlLiteLog : ILog
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
namespace Ocelot.Provider.Rafty
 | 
			
		||||
{
 | 
			
		||||
    using Errors;
 | 
			
		||||
 | 
			
		||||
    public class UnableToSaveAcceptCommand : Error
 | 
			
		||||
    {
 | 
			
		||||
        public UnableToSaveAcceptCommand(string message) 
 | 
			
		||||
        public UnableToSaveAcceptCommand(string message)
 | 
			
		||||
            : base(message, OcelotErrorCode.UnknownError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,17 +1,17 @@
 | 
			
		||||
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.Tracing;
 | 
			
		||||
    using global::Butterfly.OpenTracing;
 | 
			
		||||
    using Infrastructure.Extensions;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    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
 | 
			
		||||
    {
 | 
			
		||||
@@ -25,7 +25,7 @@
 | 
			
		||||
 | 
			
		||||
        public void Event(HttpContext httpContext, string @event)
 | 
			
		||||
        {
 | 
			
		||||
            // todo - if the user isnt using tracing the code gets here and will blow up on 
 | 
			
		||||
            // todo - if the user isnt using tracing the code gets here and will blow up on
 | 
			
		||||
            // _tracer.Tracer.TryExtract..
 | 
			
		||||
            if (_tracer == null)
 | 
			
		||||
            {
 | 
			
		||||
@@ -52,8 +52,8 @@
 | 
			
		||||
 | 
			
		||||
        public Task<HttpResponseMessage> SendAsync(
 | 
			
		||||
            HttpRequestMessage request,
 | 
			
		||||
            CancellationToken cancellationToken, 
 | 
			
		||||
            Action<string> addTraceIdToRepo, 
 | 
			
		||||
            CancellationToken cancellationToken,
 | 
			
		||||
            Action<string> addTraceIdToRepo,
 | 
			
		||||
            Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> baseSendAsync)
 | 
			
		||||
        {
 | 
			
		||||
            return _tracer.ChildTraceAsync($"httpclient {request.Method}", DateTimeOffset.UtcNow, span => TracingSendAsync(span, request, cancellationToken, addTraceIdToRepo, baseSendAsync));
 | 
			
		||||
@@ -62,8 +62,8 @@
 | 
			
		||||
        protected virtual async Task<HttpResponseMessage> TracingSendAsync(
 | 
			
		||||
            ISpan span,
 | 
			
		||||
            HttpRequestMessage request,
 | 
			
		||||
            CancellationToken cancellationToken, 
 | 
			
		||||
            Action<string> addTraceIdToRepo, 
 | 
			
		||||
            CancellationToken cancellationToken,
 | 
			
		||||
            Action<string> addTraceIdToRepo,
 | 
			
		||||
            Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> baseSendAsync)
 | 
			
		||||
        {
 | 
			
		||||
            if (request.Headers.Contains(PrefixSpanId))
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
namespace Ocelot.Tracing.Butterfly
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using DependencyInjection;
 | 
			
		||||
    using global::Butterfly.Client.AspNetCore;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public static class OcelotBuilderExtensions
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,8 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Microsoft.AspNetCore.Authentication;
 | 
			
		||||
using Microsoft.AspNetCore.Authentication;
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.Errors;
 | 
			
		||||
using Ocelot.Infrastructure.Extensions;
 | 
			
		||||
using Ocelot.Logging;
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Authentication.Middleware
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -9,4 +9,4 @@ namespace Ocelot.Authentication.Middleware
 | 
			
		||||
            return builder.UseMiddleware<AuthenticationMiddleware>();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
    public class ClaimValueNotAuthorisedError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public ClaimValueNotAuthorisedError(string message) 
 | 
			
		||||
        public ClaimValueNotAuthorisedError(string message)
 | 
			
		||||
            : base(message, OcelotErrorCode.ClaimValueNotAuthorisedError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,10 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
using System.Text.RegularExpressions;
 | 
			
		||||
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using Ocelot.Values;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
    using Infrastructure.Claims.Parser;
 | 
			
		||||
@@ -26,7 +22,8 @@ namespace Ocelot.Authorisation
 | 
			
		||||
            ClaimsPrincipal claimsPrincipal,
 | 
			
		||||
            Dictionary<string, string> routeClaimsRequirement,
 | 
			
		||||
            List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
 | 
			
		||||
        ){
 | 
			
		||||
        )
 | 
			
		||||
        {
 | 
			
		||||
            foreach (var required in routeClaimsRequirement)
 | 
			
		||||
            {
 | 
			
		||||
                var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key);
 | 
			
		||||
@@ -62,15 +59,14 @@ namespace Ocelot.Authorisation
 | 
			
		||||
                            if (matchingPlaceholders.Length == 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
 | 
			
		||||
                                    $"config error: requires variable claim value: {variableName} placeholders does not contain that variable: {string.Join(", ", urlPathPlaceholderNameAndValues.Select(p=>p.Name))}"));
 | 
			
		||||
                                    $"config error: requires variable claim value: {variableName} placeholders does not contain that variable: {string.Join(", ", urlPathPlaceholderNameAndValues.Select(p => p.Name))}"));
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
 | 
			
		||||
                                    $"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
 | 
			
		||||
                    {
 | 
			
		||||
@@ -92,4 +88,4 @@ namespace Ocelot.Authorisation
 | 
			
		||||
            return new OkResponse<bool>(true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,6 @@
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using Ocelot.Values;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
@@ -17,4 +14,4 @@ namespace Ocelot.Authorisation
 | 
			
		||||
            List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
@@ -9,4 +9,4 @@ namespace Ocelot.Authorisation
 | 
			
		||||
    {
 | 
			
		||||
        Response<bool> Authorise(ClaimsPrincipal claimsPrincipal, List<string> routeAllowedScopes);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,10 @@
 | 
			
		||||
namespace Ocelot.Authorisation.Middleware
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Errors;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using Responses;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
    using Responses;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class AuthorisationMiddleware : OcelotMiddleware
 | 
			
		||||
    {
 | 
			
		||||
@@ -18,7 +16,7 @@
 | 
			
		||||
            IClaimsAuthoriser claimsAuthoriser,
 | 
			
		||||
            IScopesAuthoriser scopesAuthoriser,
 | 
			
		||||
            IOcelotLoggerFactory loggerFactory)
 | 
			
		||||
            :base(loggerFactory.CreateLogger<AuthorisationMiddleware>())
 | 
			
		||||
            : base(loggerFactory.CreateLogger<AuthorisationMiddleware>())
 | 
			
		||||
        {
 | 
			
		||||
            _next = next;
 | 
			
		||||
            _claimsAuthoriser = claimsAuthoriser;
 | 
			
		||||
@@ -102,4 +100,4 @@
 | 
			
		||||
            return reRoute.IsAuthorised;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,4 +9,4 @@ namespace Ocelot.Authorisation.Middleware
 | 
			
		||||
            return builder.UseMiddleware<AuthorisationMiddleware>();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
    public class ScopeNotAuthorisedError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public ScopeNotAuthorisedError(string message) 
 | 
			
		||||
        public ScopeNotAuthorisedError(string message)
 | 
			
		||||
            : base(message, OcelotErrorCode.ScopeNotAuthorisedError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
    public class UnauthorisedError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public UnauthorisedError(string message) 
 | 
			
		||||
        public UnauthorisedError(string message)
 | 
			
		||||
            : base(message, OcelotErrorCode.UnauthorizedError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
 | 
			
		||||
{
 | 
			
		||||
    public class UserDoesNotHaveClaimError : Error
 | 
			
		||||
    {
 | 
			
		||||
        public UserDoesNotHaveClaimError(string message) 
 | 
			
		||||
        public UserDoesNotHaveClaimError(string message)
 | 
			
		||||
            : base(message, OcelotErrorCode.UserDoesNotHaveClaimError)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,17 @@
 | 
			
		||||
using System.Text;
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Cache {
 | 
			
		||||
    public class CacheKeyGenerator : ICacheKeyGenerator {
 | 
			
		||||
        public string GenerateRequestCacheKey(DownstreamContext context) {
 | 
			
		||||
namespace Ocelot.Cache
 | 
			
		||||
{
 | 
			
		||||
    public class CacheKeyGenerator : ICacheKeyGenerator
 | 
			
		||||
    {
 | 
			
		||||
        public string GenerateRequestCacheKey(DownstreamContext context)
 | 
			
		||||
        {
 | 
			
		||||
            string hashedContent = null;
 | 
			
		||||
            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;
 | 
			
		||||
                downStreamUrlKeyBuilder.Append(requestContentString);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    class CacheObject<T>
 | 
			
		||||
    internal class CacheObject<T>
 | 
			
		||||
    {
 | 
			
		||||
        public CacheObject(T value, DateTime expires)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ namespace Ocelot.Cache
 | 
			
		||||
        public Dictionary<string, IEnumerable<string>> ContentHeaders { get; private set; }
 | 
			
		||||
 | 
			
		||||
        public string Body { get; private set; }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        public string ReasonPhrase { get; private set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Cache {
 | 
			
		||||
    public interface ICacheKeyGenerator {
 | 
			
		||||
namespace Ocelot.Cache
 | 
			
		||||
{
 | 
			
		||||
    public interface ICacheKeyGenerator
 | 
			
		||||
    {
 | 
			
		||||
        string GenerateRequestCacheKey(DownstreamContext context);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,11 @@ namespace Ocelot.Cache
 | 
			
		||||
    public interface IOcelotCache<T>
 | 
			
		||||
    {
 | 
			
		||||
        void Add(string key, T value, TimeSpan ttl, string region);
 | 
			
		||||
 | 
			
		||||
        T Get(string key, string region);
 | 
			
		||||
 | 
			
		||||
        void ClearRegion(string region);
 | 
			
		||||
 | 
			
		||||
        void AddAndDelete(string key, T value, TimeSpan ttl, string region);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                _regions.Add(region, new List<string>{ key });
 | 
			
		||||
                _regions.Add(region, new List<string> { key });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,20 +1,25 @@
 | 
			
		||||
using System.Security.Cryptography;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Cache {
 | 
			
		||||
    public static class MD5Helper {
 | 
			
		||||
        public static string GenerateMd5(byte[] contentBytes) {
 | 
			
		||||
namespace Ocelot.Cache
 | 
			
		||||
{
 | 
			
		||||
    public static class MD5Helper
 | 
			
		||||
    {
 | 
			
		||||
        public static string GenerateMd5(byte[] contentBytes)
 | 
			
		||||
        {
 | 
			
		||||
            MD5 md5 = MD5.Create();
 | 
			
		||||
            byte[] hash = md5.ComputeHash(contentBytes);
 | 
			
		||||
            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"));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return sb.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string GenerateMd5(string contentString) {
 | 
			
		||||
        public static string GenerateMd5(string contentString)
 | 
			
		||||
        {
 | 
			
		||||
            byte[] contentBytes = Encoding.Unicode.GetBytes(contentString);
 | 
			
		||||
            return GenerateMd5(contentBytes);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,13 @@
 | 
			
		||||
namespace Ocelot.Cache.Middleware
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Text;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class OutputCacheMiddleware : OcelotMiddleware
 | 
			
		||||
    {
 | 
			
		||||
@@ -19,7 +19,7 @@
 | 
			
		||||
            IOcelotLoggerFactory loggerFactory,
 | 
			
		||||
            IOcelotCache<CachedResponse> outputCache,
 | 
			
		||||
            ICacheKeyGenerator cacheGeneratot)
 | 
			
		||||
                :base(loggerFactory.CreateLogger<OutputCacheMiddleware>())
 | 
			
		||||
                : base(loggerFactory.CreateLogger<OutputCacheMiddleware>())
 | 
			
		||||
        {
 | 
			
		||||
            _next = next;
 | 
			
		||||
            _outputCache = outputCache;
 | 
			
		||||
@@ -71,12 +71,26 @@
 | 
			
		||||
            Logger.LogDebug($"finished response added to cache for {downstreamUrlKey}");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void SetHttpResponseMessageThisRequest(DownstreamContext context, 
 | 
			
		||||
        private void SetHttpResponseMessageThisRequest(DownstreamContext 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)
 | 
			
		||||
        {
 | 
			
		||||
            if (cached == null)
 | 
			
		||||
 
 | 
			
		||||
@@ -10,4 +10,4 @@ namespace Ocelot.Cache.Middleware
 | 
			
		||||
            return builder.UseMiddleware<OutputCacheMiddleware>();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,4 +22,4 @@ namespace Ocelot.Cache
 | 
			
		||||
            return new NoContentResult();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,5 @@
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Cache
 | 
			
		||||
{
 | 
			
		||||
@@ -8,16 +7,16 @@ namespace Ocelot.Cache
 | 
			
		||||
    {
 | 
			
		||||
        public string Create(FileReRoute reRoute)
 | 
			
		||||
        {
 | 
			
		||||
            if(!string.IsNullOrEmpty(reRoute?.FileCacheOptions?.Region))
 | 
			
		||||
            if (!string.IsNullOrEmpty(reRoute?.FileCacheOptions?.Region))
 | 
			
		||||
            {
 | 
			
		||||
                return reRoute?.FileCacheOptions?.Region;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var methods = string.Join("", reRoute.UpstreamHttpMethod.Select(m => m));
 | 
			
		||||
 | 
			
		||||
            var region = $"{methods}{reRoute.UpstreamPathTemplate.Replace("/", "")}";
 | 
			
		||||
            
 | 
			
		||||
            var region = $"{methods}{reRoute.UpstreamPathTemplate.Replace("/", "")}";
 | 
			
		||||
 | 
			
		||||
            return region;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,4 +11,4 @@ namespace Ocelot.Cache
 | 
			
		||||
 | 
			
		||||
        public List<string> Value { get; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.Infrastructure.Claims.Parser;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Claims
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Claims
 | 
			
		||||
{
 | 
			
		||||
@@ -10,4 +10,4 @@ namespace Ocelot.Claims
 | 
			
		||||
        Response SetClaimsOnContext(List<ClaimToThing> claimsToThings,
 | 
			
		||||
            HttpContext context);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,7 @@
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.Middleware;
 | 
			
		||||
using Ocelot.Infrastructure.RequestData;
 | 
			
		||||
using Ocelot.Logging;
 | 
			
		||||
using Ocelot.Logging;
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Claims.Middleware
 | 
			
		||||
{
 | 
			
		||||
@@ -13,10 +10,10 @@ namespace Ocelot.Claims.Middleware
 | 
			
		||||
        private readonly OcelotRequestDelegate _next;
 | 
			
		||||
        private readonly IAddClaimsToRequest _addClaimsToRequest;
 | 
			
		||||
 | 
			
		||||
        public ClaimsToClaimsMiddleware(OcelotRequestDelegate next, 
 | 
			
		||||
        public ClaimsToClaimsMiddleware(OcelotRequestDelegate next,
 | 
			
		||||
            IOcelotLoggerFactory loggerFactory,
 | 
			
		||||
            IAddClaimsToRequest addClaimsToRequest) 
 | 
			
		||||
                :base(loggerFactory.CreateLogger<ClaimsToClaimsMiddleware>())
 | 
			
		||||
            IAddClaimsToRequest addClaimsToRequest)
 | 
			
		||||
                : base(loggerFactory.CreateLogger<ClaimsToClaimsMiddleware>())
 | 
			
		||||
        {
 | 
			
		||||
            _next = next;
 | 
			
		||||
            _addClaimsToRequest = addClaimsToRequest;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,4 +13,4 @@ namespace Ocelot.Configuration
 | 
			
		||||
        public List<string> AllowedScopes { get; private set; }
 | 
			
		||||
        public string AuthenticationProviderKey { get; private set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Net.Http;
 | 
			
		||||
using Ocelot.Values;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Ocelot.Configuration.Creator;
 | 
			
		||||
using Ocelot.Values;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Net.Http;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Builder
 | 
			
		||||
{
 | 
			
		||||
@@ -39,6 +39,7 @@ namespace Ocelot.Configuration.Builder
 | 
			
		||||
        private List<AddHeader> _addHeadersToUpstream;
 | 
			
		||||
        private bool _dangerousAcceptAnyServerCertificateValidator;
 | 
			
		||||
        private SecurityOptions _securityOptions;
 | 
			
		||||
 | 
			
		||||
        public DownstreamReRouteBuilder()
 | 
			
		||||
        {
 | 
			
		||||
            _downstreamAddresses = new List<DownstreamHostAndPort>();
 | 
			
		||||
@@ -55,7 +56,7 @@ namespace Ocelot.Configuration.Builder
 | 
			
		||||
 | 
			
		||||
        public DownstreamReRouteBuilder WithLoadBalancerOptions(LoadBalancerOptions loadBalancerOptions)
 | 
			
		||||
        {
 | 
			
		||||
          _loadBalancerOptions = loadBalancerOptions;
 | 
			
		||||
            _loadBalancerOptions = loadBalancerOptions;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -142,7 +143,7 @@ namespace Ocelot.Configuration.Builder
 | 
			
		||||
            _qosOptions = input;
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
        public DownstreamReRouteBuilder WithLoadBalancerKey(string loadBalancerKey)
 | 
			
		||||
        {
 | 
			
		||||
            _loadBalancerKey = loadBalancerKey;
 | 
			
		||||
@@ -239,26 +240,26 @@ namespace Ocelot.Configuration.Builder
 | 
			
		||||
                _key,
 | 
			
		||||
                _upstreamTemplatePattern,
 | 
			
		||||
                _upstreamHeaderFindAndReplace,
 | 
			
		||||
                _downstreamHeaderFindAndReplace, 
 | 
			
		||||
                _downstreamHeaderFindAndReplace,
 | 
			
		||||
                _downstreamAddresses,
 | 
			
		||||
                _serviceName, 
 | 
			
		||||
                _httpHandlerOptions, 
 | 
			
		||||
                _useServiceDiscovery, 
 | 
			
		||||
                _enableRateLimiting, 
 | 
			
		||||
                _serviceName,
 | 
			
		||||
                _httpHandlerOptions,
 | 
			
		||||
                _useServiceDiscovery,
 | 
			
		||||
                _enableRateLimiting,
 | 
			
		||||
                _qosOptions,
 | 
			
		||||
                _downstreamScheme, 
 | 
			
		||||
                _requestIdHeaderKey, 
 | 
			
		||||
                _isCached, 
 | 
			
		||||
                _fileCacheOptions, 
 | 
			
		||||
                _loadBalancerOptions, 
 | 
			
		||||
                _downstreamScheme,
 | 
			
		||||
                _requestIdHeaderKey,
 | 
			
		||||
                _isCached,
 | 
			
		||||
                _fileCacheOptions,
 | 
			
		||||
                _loadBalancerOptions,
 | 
			
		||||
                _rateLimitOptions,
 | 
			
		||||
                _routeClaimRequirement, 
 | 
			
		||||
                _claimToQueries, 
 | 
			
		||||
                _claimsToHeaders, 
 | 
			
		||||
                _routeClaimRequirement,
 | 
			
		||||
                _claimToQueries,
 | 
			
		||||
                _claimsToHeaders,
 | 
			
		||||
                _claimToClaims,
 | 
			
		||||
                _isAuthenticated, 
 | 
			
		||||
                _isAuthorised, 
 | 
			
		||||
                _authenticationOptions, 
 | 
			
		||||
                _isAuthenticated,
 | 
			
		||||
                _isAuthorised,
 | 
			
		||||
                _authenticationOptions,
 | 
			
		||||
                new DownstreamPathTemplate(_downstreamPathTemplate),
 | 
			
		||||
                _loadBalancerKey,
 | 
			
		||||
                _delegatingHandlers,
 | 
			
		||||
 
 | 
			
		||||
@@ -39,4 +39,4 @@
 | 
			
		||||
            return new QoSOptions(_exceptionsAllowedBeforeBreaking, _durationOfBreak, _timeoutValue, _key);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -63,9 +63,9 @@ namespace Ocelot.Configuration.Builder
 | 
			
		||||
 | 
			
		||||
        public RateLimitOptions Build()
 | 
			
		||||
        {
 | 
			
		||||
            return new RateLimitOptions(_enableRateLimiting, _clientIdHeader, _clientWhitelist, 
 | 
			
		||||
                _disableRateLimitHeaders, _quotaExceededMessage, _rateLimitCounterPrefix, 
 | 
			
		||||
            return new RateLimitOptions(_enableRateLimiting, _clientIdHeader, _clientWhitelist,
 | 
			
		||||
                _disableRateLimitHeaders, _quotaExceededMessage, _rateLimitCounterPrefix,
 | 
			
		||||
                _rateLimitRule, _httpStatusCode);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
namespace Ocelot.Configuration.Builder
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Ocelot.Values;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using Ocelot.Configuration.File;
 | 
			
		||||
    using Ocelot.Values;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
 | 
			
		||||
    public class ReRouteBuilder
 | 
			
		||||
    {
 | 
			
		||||
@@ -68,11 +68,11 @@
 | 
			
		||||
            return new ReRoute(
 | 
			
		||||
                _downstreamReRoutes,
 | 
			
		||||
                _downstreamReRoutesConfig,
 | 
			
		||||
                _upstreamHttpMethod, 
 | 
			
		||||
                _upstreamTemplatePattern, 
 | 
			
		||||
                _upstreamHttpMethod,
 | 
			
		||||
                _upstreamTemplatePattern,
 | 
			
		||||
                _upstreamHost,
 | 
			
		||||
                _aggregator
 | 
			
		||||
                );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,4 +12,4 @@
 | 
			
		||||
 | 
			
		||||
        public string Region { get; private set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -15,4 +15,4 @@
 | 
			
		||||
        public string Delimiter { get; private set; }
 | 
			
		||||
        public int Index { get; private set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using Builder;
 | 
			
		||||
    using File;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
 | 
			
		||||
    public class AggregatesCreator : IAggregatesCreator
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,6 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
        public AuthenticationOptions Create(FileReRoute reRoute)
 | 
			
		||||
        {
 | 
			
		||||
            return new AuthenticationOptions(reRoute.AuthenticationOptions.AllowedScopes, reRoute.AuthenticationOptions.AuthenticationProviderKey);
 | 
			
		||||
        } 
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.Parser;
 | 
			
		||||
using Ocelot.Logging;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
@@ -14,9 +14,9 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
        {
 | 
			
		||||
            _logger = loggerFactory.CreateLogger<ClaimsToThingCreator>();
 | 
			
		||||
            _claimToThingConfigParser = claimToThingConfigurationParser;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        public List<ClaimToThing> Create(Dictionary<string,string> inputToBeParsed)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public List<ClaimToThing> Create(Dictionary<string, string> inputToBeParsed)
 | 
			
		||||
        {
 | 
			
		||||
            var claimsToThings = new List<ClaimToThing>();
 | 
			
		||||
 | 
			
		||||
@@ -37,4 +37,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            return claimsToThings;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    using DependencyInjection;
 | 
			
		||||
    using File;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using File;
 | 
			
		||||
    using DependencyInjection;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
 | 
			
		||||
    public class ConfigurationCreator : IConfigurationCreator
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
@@ -11,4 +11,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            return reRoute.DownstreamHostAndPorts.Select(hostAndPort => new DownstreamHostAndPort(hostAndPort.Host, hostAndPort.Port)).ToList();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using Builder;
 | 
			
		||||
    using File;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
 | 
			
		||||
    public class DynamicsCreator : IDynamicsCreator
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    using File;
 | 
			
		||||
    using Responses;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using File;
 | 
			
		||||
    using Validator;
 | 
			
		||||
    using Responses;
 | 
			
		||||
 | 
			
		||||
    public class FileInternalConfigurationCreator : IInternalConfigurationCreator
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,9 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using Ocelot.Infrastructure;
 | 
			
		||||
using Ocelot.Infrastructure.Extensions;
 | 
			
		||||
using Ocelot.Logging;
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
@@ -25,7 +23,7 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            var upstream = new List<HeaderFindAndReplace>();
 | 
			
		||||
            var addHeadersToUpstream = new List<AddHeader>();
 | 
			
		||||
 | 
			
		||||
            foreach(var input in fileReRoute.UpstreamHeaderTransform)
 | 
			
		||||
            foreach (var input in fileReRoute.UpstreamHeaderTransform)
 | 
			
		||||
            {
 | 
			
		||||
                if (input.Value.Contains(","))
 | 
			
		||||
                {
 | 
			
		||||
@@ -46,14 +44,14 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var downstream = new List<HeaderFindAndReplace>();
 | 
			
		||||
            var addHeadersToDownstream = new List<AddHeader>();
 | 
			
		||||
            
 | 
			
		||||
            foreach(var input in fileReRoute.DownstreamHeaderTransform)
 | 
			
		||||
            var addHeadersToDownstream = new List<AddHeader>();
 | 
			
		||||
 | 
			
		||||
            foreach (var input in fileReRoute.DownstreamHeaderTransform)
 | 
			
		||||
            {
 | 
			
		||||
                if(input.Value.Contains(","))
 | 
			
		||||
                if (input.Value.Contains(","))
 | 
			
		||||
                {
 | 
			
		||||
                    var hAndr = Map(input);
 | 
			
		||||
                    if(!hAndr.IsError)
 | 
			
		||||
                    if (!hAndr.IsError)
 | 
			
		||||
                    {
 | 
			
		||||
                        downstream.Add(hAndr.Data);
 | 
			
		||||
                    }
 | 
			
		||||
@@ -66,27 +64,27 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
                {
 | 
			
		||||
                    addHeadersToDownstream.Add(new AddHeader(input.Key, input.Value));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return new HeaderTransformations(upstream, downstream, addHeadersToDownstream, addHeadersToUpstream);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private Response<HeaderFindAndReplace> Map(KeyValuePair<string,string> input)
 | 
			
		||||
        private Response<HeaderFindAndReplace> Map(KeyValuePair<string, string> input)
 | 
			
		||||
        {
 | 
			
		||||
            var findAndReplace = input.Value.Split(",");
 | 
			
		||||
 | 
			
		||||
            var replace = findAndReplace[1].TrimStart();
 | 
			
		||||
 | 
			
		||||
            var startOfPlaceholder = replace.IndexOf("{");
 | 
			
		||||
            if(startOfPlaceholder > -1)
 | 
			
		||||
            if (startOfPlaceholder > -1)
 | 
			
		||||
            {
 | 
			
		||||
                var endOfPlaceholder = replace.IndexOf("}", startOfPlaceholder);
 | 
			
		||||
                
 | 
			
		||||
                var endOfPlaceholder = replace.IndexOf("}", startOfPlaceholder);
 | 
			
		||||
 | 
			
		||||
                var placeholder = replace.Substring(startOfPlaceholder, startOfPlaceholder + (endOfPlaceholder + 1));
 | 
			
		||||
 | 
			
		||||
                var value = _placeholders.Get(placeholder);
 | 
			
		||||
 | 
			
		||||
                if(value.IsError)
 | 
			
		||||
                if (value.IsError)
 | 
			
		||||
                {
 | 
			
		||||
                    return new ErrorResponse<HeaderFindAndReplace>(value.Errors);
 | 
			
		||||
                }
 | 
			
		||||
@@ -94,9 +92,9 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
                replace = replace.Replace(placeholder, value.Data);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var hAndr = new HeaderFindAndReplace(input.Key, findAndReplace[0], replace, 0);
 | 
			
		||||
            
 | 
			
		||||
            var hAndr = new HeaderFindAndReplace(input.Key, findAndReplace[0], replace, 0);
 | 
			
		||||
 | 
			
		||||
            return new OkResponse<HeaderFindAndReplace>(hAndr);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    public class HeaderTransformations
 | 
			
		||||
    {
 | 
			
		||||
        public HeaderTransformations(
 | 
			
		||||
            List<HeaderFindAndReplace> upstream, 
 | 
			
		||||
            List<HeaderFindAndReplace> upstream,
 | 
			
		||||
            List<HeaderFindAndReplace> downstream,
 | 
			
		||||
            List<AddHeader> addHeaderToDownstream,
 | 
			
		||||
            List<AddHeader> addHeaderToUpstream)
 | 
			
		||||
@@ -23,4 +23,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
        public List<AddHeader> AddHeadersToDownstream { get; }
 | 
			
		||||
        public List<AddHeader> AddHeadersToUpstream { get; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using Logging;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Ocelot.Configuration.File;
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public class HttpHandlerOptionsCreator : IHttpHandlerOptionsCreator
 | 
			
		||||
    {
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
 | 
			
		||||
        public HttpHandlerOptions Create(FileHttpHandlerOptions options)
 | 
			
		||||
        {
 | 
			
		||||
            var useTracing = _tracer!= null && options.UseTracing;
 | 
			
		||||
            var useTracing = _tracer != null && options.UseTracing;
 | 
			
		||||
 | 
			
		||||
            return new HttpHandlerOptions(options.AllowAutoRedirect,
 | 
			
		||||
                options.UseCookieContainer, useTracing, options.UseProxy);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
@@ -7,4 +6,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    {
 | 
			
		||||
        AuthenticationOptions Create(FileReRoute reRoute);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,6 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    public interface IClaimsToThingCreator
 | 
			
		||||
    {
 | 
			
		||||
        List<ClaimToThing> Create(Dictionary<string,string> thingsBeingAdded);
 | 
			
		||||
        List<ClaimToThing> Create(Dictionary<string, string> thingsBeingAdded);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
@@ -7,4 +7,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    {
 | 
			
		||||
        List<DownstreamHostAndPort> Create(FileReRoute reRoute);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
@@ -7,4 +6,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    {
 | 
			
		||||
        HeaderTransformations Create(FileReRoute fileReRoute);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,4 +9,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    {
 | 
			
		||||
        HttpHandlerOptions Create(FileHttpHandlerOptions fileReRoute);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using Ocelot.Responses;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,14 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    public interface IQoSOptionsCreator
 | 
			
		||||
    {
 | 
			
		||||
        QoSOptions Create(FileQoSOptions options);
 | 
			
		||||
 | 
			
		||||
        QoSOptions Create(FileQoSOptions options, string pathTemplate, List<string> httpMethods);
 | 
			
		||||
 | 
			
		||||
        QoSOptions Create(QoSOptions options, string pathTemplate, List<string> httpMethods);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,4 +6,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    {
 | 
			
		||||
        ReRouteOptions Create(FileReRoute fileReRoute);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,4 @@
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -7,4 +7,4 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    {
 | 
			
		||||
        UpstreamPathTemplate Create(IReRoute reRoute);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using Ocelot.LoadBalancer.LoadBalancers;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
@@ -12,14 +12,14 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            {
 | 
			
		||||
                return $"{nameof(CookieStickySessions)}:{fileReRoute.LoadBalancerOptions.Key}";
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            return $"{fileReRoute.UpstreamPathTemplate}|{string.Join(",", fileReRoute.UpstreamHttpMethod)}|{string.Join(",", fileReRoute.DownstreamHostAndPorts.Select(x => $"{x.Host}:{x.Port}"))}";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private bool IsStickySession(FileReRoute fileReRoute)
 | 
			
		||||
        {
 | 
			
		||||
            if (!string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Type) 
 | 
			
		||||
                && !string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Key) 
 | 
			
		||||
            if (!string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Type)
 | 
			
		||||
                && !string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Key)
 | 
			
		||||
                && fileReRoute.LoadBalancerOptions.Type == nameof(CookieStickySessions))
 | 
			
		||||
            {
 | 
			
		||||
                return true;
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user