mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 15:30:49 +08:00 
			
		
		
		
	bit more tidying
This commit is contained in:
		@@ -53,7 +53,7 @@ namespace Ocelot.Authentication.Middleware
 | 
			
		||||
                if (context.User.Identity.IsAuthenticated)
 | 
			
		||||
                {
 | 
			
		||||
                    _logger.LogDebug($"Client has been authenticated for {context.Request.Path}");
 | 
			
		||||
                    await _next.Invoke(context);
 | 
			
		||||
                    await _next.Invoke(context);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
@@ -72,7 +72,7 @@ namespace Ocelot.Authentication.Middleware
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogTrace($"No authentication needed for {context.Request.Path}");
 | 
			
		||||
 | 
			
		||||
                await _next.Invoke(context);
 | 
			
		||||
                await _next.Invoke(context);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,21 @@
 | 
			
		||||
using Ocelot.Configuration.Builder;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
using Ocelot.Creator.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    public class AuthenticationOptionsCreator : IAuthenticationOptionsCreator
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IAuthenticationProviderConfigCreator _creator;
 | 
			
		||||
 | 
			
		||||
        public AuthenticationOptionsCreator(IAuthenticationProviderConfigCreator creator)
 | 
			
		||||
        {
 | 
			
		||||
            _creator = creator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public AuthenticationOptions Create(FileReRoute fileReRoute)
 | 
			
		||||
        {
 | 
			
		||||
            var authenticationConfig = new ConfigCreator().Create(fileReRoute.AuthenticationOptions);
 | 
			
		||||
            var authenticationConfig = _creator.Create(fileReRoute.AuthenticationOptions);
 | 
			
		||||
 | 
			
		||||
            return new AuthenticationOptionsBuilder()
 | 
			
		||||
                .WithProvider(fileReRoute.AuthenticationOptions?.Provider)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,15 @@
 | 
			
		||||
using Ocelot.Creator.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
    public class ConfigCreator
 | 
			
		||||
    public class AuthenticationProviderConfigCreator : IAuthenticationProviderConfigCreator
 | 
			
		||||
    {
 | 
			
		||||
        public IAuthenticationConfig Create(FileAuthenticationOptions authenticationOptions)
 | 
			
		||||
        {
 | 
			
		||||
            if (authenticationOptions.Provider == "Jwt")
 | 
			
		||||
            if (authenticationOptions.Provider?.ToLower() == "jwt")
 | 
			
		||||
            {
 | 
			
		||||
                return CreateJwt(authenticationOptions);
 | 
			
		||||
            }
 | 
			
		||||
@@ -31,13 +31,13 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
        private readonly IQosProviderHouse _qosProviderHouse;
 | 
			
		||||
        private readonly IClaimsToThingCreator _claimsToThingCreator;
 | 
			
		||||
        private readonly IAuthenticationOptionsCreator _authOptionsCreator;
 | 
			
		||||
        private IUpstreamTemplatePatternCreator _upstreamTemplatePatternCreator;
 | 
			
		||||
        private IRequestIdKeyCreator _requestIdKeyCreator;
 | 
			
		||||
        private IServiceProviderConfigurationCreator _serviceProviderConfigCreator;
 | 
			
		||||
        private IQoSOptionsCreator _qosOptionsCreator;
 | 
			
		||||
        private IReRouteOptionsCreator _fileReRouteOptionsCreator;
 | 
			
		||||
        private IRateLimitOptionsCreator _rateLimitOptionsCreator;
 | 
			
		||||
        private IRegionCreator _regionCreator;
 | 
			
		||||
        private readonly IUpstreamTemplatePatternCreator _upstreamTemplatePatternCreator;
 | 
			
		||||
        private readonly IRequestIdKeyCreator _requestIdKeyCreator;
 | 
			
		||||
        private readonly IServiceProviderConfigurationCreator _serviceProviderConfigCreator;
 | 
			
		||||
        private readonly IQoSOptionsCreator _qosOptionsCreator;
 | 
			
		||||
        private readonly IReRouteOptionsCreator _fileReRouteOptionsCreator;
 | 
			
		||||
        private readonly IRateLimitOptionsCreator _rateLimitOptionsCreator;
 | 
			
		||||
        private readonly IRegionCreator _regionCreator;
 | 
			
		||||
 | 
			
		||||
        public FileOcelotConfigurationCreator(
 | 
			
		||||
            IOptions<FileConfiguration> options, 
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Creator.Configuration
 | 
			
		||||
{
 | 
			
		||||
    public interface IAuthenticationProviderConfigCreator
 | 
			
		||||
    {
 | 
			
		||||
        IAuthenticationConfig Create(FileAuthenticationOptions authenticationOptions);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -44,6 +44,7 @@ using System.Reflection;
 | 
			
		||||
using System.Security.Cryptography.X509Certificates;
 | 
			
		||||
using Microsoft.IdentityModel.Tokens;
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.Creator.Configuration;
 | 
			
		||||
using FileConfigurationProvider = Ocelot.Configuration.Provider.FileConfigurationProvider;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.DependencyInjection
 | 
			
		||||
@@ -71,6 +72,7 @@ namespace Ocelot.DependencyInjection
 | 
			
		||||
 | 
			
		||||
            services.Configure<FileConfiguration>(configurationRoot);
 | 
			
		||||
            services.TryAddSingleton<IOcelotConfigurationCreator, FileOcelotConfigurationCreator>();
 | 
			
		||||
            services.TryAddSingleton<IAuthenticationProviderConfigCreator, AuthenticationProviderConfigCreator>();
 | 
			
		||||
            services.TryAddSingleton<IOcelotConfigurationRepository, InMemoryOcelotConfigurationRepository>();
 | 
			
		||||
            services.TryAddSingleton<IConfigurationValidator, FileConfigurationValidator>();
 | 
			
		||||
            services.TryAddSingleton<IBaseUrlFinder, BaseUrlFinder>();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user