mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	few things to remove i missed
This commit is contained in:
		@@ -1,61 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
using System;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using Newtonsoft.Json.Linq;
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Authentication.JsonConverters
 | 
			
		||||
{
 | 
			
		||||
    public class AuthenticationConfigConverter : JsonConverter
 | 
			
		||||
    {
 | 
			
		||||
        public override bool CanWrite => false;
 | 
			
		||||
 | 
			
		||||
        public override bool CanRead => true;
 | 
			
		||||
        
 | 
			
		||||
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            throw new InvalidOperationException("Use default serialization.");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            var jsonObject = JObject.Load(reader);
 | 
			
		||||
            var setting = default(IAuthenticationConfig);
 | 
			
		||||
 | 
			
		||||
            if (jsonObject["Provider"] != null)
 | 
			
		||||
            {
 | 
			
		||||
                switch (jsonObject["Provider"].Value<string>())
 | 
			
		||||
                {
 | 
			
		||||
                    case "Jwt":
 | 
			
		||||
                        setting = new JwtConfig(
 | 
			
		||||
                            jsonObject["Authority"].Value<string>(),
 | 
			
		||||
                            jsonObject["Audience"].Value<string>());
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
                    default:
 | 
			
		||||
                        setting = new IdentityServerConfig(
 | 
			
		||||
                            jsonObject["ProviderRootUrl"].Value<string>(),
 | 
			
		||||
                            jsonObject["ApiName"].Value<string>(),
 | 
			
		||||
                            jsonObject["RequireHttps"].Value<bool>(),
 | 
			
		||||
                            jsonObject["ApiSecret"].Value<string>());
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                setting = new IdentityServerConfig(string.Empty, string.Empty, false, string.Empty);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            serializer.Populate(jsonObject.CreateReader(), setting);
 | 
			
		||||
            return setting;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override bool CanConvert(Type objectType)
 | 
			
		||||
        {
 | 
			
		||||
            return objectType == typeof(IAuthenticationConfig);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
/*using Ocelot.Creator.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration.Creator
 | 
			
		||||
{
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
    public class AuthenticationProviderConfigCreator : IAuthenticationProviderConfigCreator
 | 
			
		||||
    {
 | 
			
		||||
        public IAuthenticationConfig Create(FileAuthenticationOptions authenticationOptions)
 | 
			
		||||
        {
 | 
			
		||||
            if (authenticationOptions.Provider?.ToLower() == "jwt")
 | 
			
		||||
            {
 | 
			
		||||
                return CreateJwt(authenticationOptions);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return CreateIdentityServer(authenticationOptions);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private JwtConfig CreateJwt(FileAuthenticationOptions authenticationOptions)
 | 
			
		||||
        {
 | 
			
		||||
            return new JwtConfigBuilder()
 | 
			
		||||
                .WithAudience(authenticationOptions.JwtConfig?.Audience)
 | 
			
		||||
                .WithAuthority(authenticationOptions.JwtConfig?.Authority)
 | 
			
		||||
                .Build();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private IdentityServerConfig CreateIdentityServer(FileAuthenticationOptions authenticationOptions)
 | 
			
		||||
        {
 | 
			
		||||
            return new IdentityServerConfigBuilder()
 | 
			
		||||
                .WithApiName(authenticationOptions.IdentityServerConfig?.ApiName)
 | 
			
		||||
                .WithApiSecret(authenticationOptions.IdentityServerConfig?.ApiSecret)
 | 
			
		||||
                .WithProviderRootUrl(authenticationOptions.IdentityServerConfig?.ProviderRootUrl)
 | 
			
		||||
                .WithRequireHttps(authenticationOptions.IdentityServerConfig.RequireHttps).Build();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}*/
 | 
			
		||||
@@ -1,10 +0,0 @@
 | 
			
		||||
/*using Ocelot.Configuration;
 | 
			
		||||
using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Creator.Configuration
 | 
			
		||||
{
 | 
			
		||||
    public interface IAuthenticationProviderConfigCreator
 | 
			
		||||
    {
 | 
			
		||||
        IAuthenticationConfig Create(FileAuthenticationOptions authenticationOptions);
 | 
			
		||||
    }
 | 
			
		||||
}*/
 | 
			
		||||
@@ -51,11 +51,6 @@ namespace Ocelot.Errors.Middleware
 | 
			
		||||
        private void SetInternalServerErrorOnResponse(HttpContext context)
 | 
			
		||||
        {
 | 
			
		||||
            context.Response.StatusCode = 500;
 | 
			
		||||
          /*  context.Response.OnStarting(x =>
 | 
			
		||||
            {
 | 
			
		||||
                context.Response.StatusCode = 500;
 | 
			
		||||
                return Task.CompletedTask;
 | 
			
		||||
            }, context);*/
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string CreateMessage(HttpContext context, Exception e)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user