mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:42:50 +08:00
few things to remove i missed
This commit is contained in:
parent
3f2af85969
commit
b512875062
@ -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)
|
private void SetInternalServerErrorOnResponse(HttpContext context)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = 500;
|
context.Response.StatusCode = 500;
|
||||||
/* context.Response.OnStarting(x =>
|
|
||||||
{
|
|
||||||
context.Response.StatusCode = 500;
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}, context);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CreateMessage(HttpContext context, Exception e)
|
private string CreateMessage(HttpContext context, Exception e)
|
||||||
|
@ -44,21 +44,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
{
|
{
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
/* AuthenticationOptions = new List<FileAuthenticationOptions>
|
|
||||||
{
|
|
||||||
new FileAuthenticationOptions
|
|
||||||
{
|
|
||||||
AllowedScopes = new List<string>(),
|
|
||||||
Provider = "IdentityServer",
|
|
||||||
IdentityServerConfig = new FileIdentityServerConfig{
|
|
||||||
ProviderRootUrl = "http://localhost:51888",
|
|
||||||
RequireHttps = false,
|
|
||||||
ApiName = "api",
|
|
||||||
ApiSecret = "secret"
|
|
||||||
},
|
|
||||||
AuthenticationProviderKey = "Test"
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
ReRoutes = new List<FileReRoute>
|
ReRoutes = new List<FileReRoute>
|
||||||
{
|
{
|
||||||
new FileReRoute
|
new FileReRoute
|
||||||
@ -111,21 +96,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
{
|
{
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
/* AuthenticationOptions = new List<FileAuthenticationOptions>
|
|
||||||
{
|
|
||||||
new FileAuthenticationOptions
|
|
||||||
{
|
|
||||||
AllowedScopes = new List<string>(),
|
|
||||||
Provider = "IdentityServer",
|
|
||||||
IdentityServerConfig = new FileIdentityServerConfig{
|
|
||||||
ProviderRootUrl = "http://localhost:51888",
|
|
||||||
RequireHttps = false,
|
|
||||||
ApiName = "api",
|
|
||||||
ApiSecret = "secret"
|
|
||||||
},
|
|
||||||
AuthenticationProviderKey = "Test"
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
ReRoutes = new List<FileReRoute>
|
ReRoutes = new List<FileReRoute>
|
||||||
{
|
{
|
||||||
new FileReRoute
|
new FileReRoute
|
||||||
@ -176,21 +146,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
{
|
{
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
/* AuthenticationOptions = new List<FileAuthenticationOptions>
|
|
||||||
{
|
|
||||||
new FileAuthenticationOptions
|
|
||||||
{
|
|
||||||
AllowedScopes = new List<string>{ "api", "api.readOnly", "openid", "offline_access" },
|
|
||||||
Provider = "IdentityServer",
|
|
||||||
IdentityServerConfig = new FileIdentityServerConfig{
|
|
||||||
ProviderRootUrl = "http://localhost:51888",
|
|
||||||
RequireHttps = false,
|
|
||||||
ApiName = "api",
|
|
||||||
ApiSecret = "secret"
|
|
||||||
},
|
|
||||||
AuthenticationProviderKey = "Test"
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
ReRoutes = new List<FileReRoute>
|
ReRoutes = new List<FileReRoute>
|
||||||
{
|
{
|
||||||
new FileReRoute
|
new FileReRoute
|
||||||
@ -226,21 +181,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
{
|
{
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
/* AuthenticationOptions = new List<FileAuthenticationOptions>
|
|
||||||
{
|
|
||||||
new FileAuthenticationOptions
|
|
||||||
{
|
|
||||||
AllowedScopes = new List<string>{ "api", "openid", "offline_access" },
|
|
||||||
Provider = "IdentityServer",
|
|
||||||
IdentityServerConfig = new FileIdentityServerConfig{
|
|
||||||
ProviderRootUrl = "http://localhost:51888",
|
|
||||||
RequireHttps = false,
|
|
||||||
ApiName = "api",
|
|
||||||
ApiSecret = "secret"
|
|
||||||
},
|
|
||||||
AuthenticationProviderKey = "Test"
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
ReRoutes = new List<FileReRoute>
|
ReRoutes = new List<FileReRoute>
|
||||||
{
|
{
|
||||||
new FileReRoute
|
new FileReRoute
|
||||||
|
@ -58,24 +58,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
/* AuthenticationOptions = new List<FileAuthenticationOptions>
|
|
||||||
{
|
|
||||||
new FileAuthenticationOptions
|
|
||||||
{
|
|
||||||
AllowedScopes = new List<string>
|
|
||||||
{
|
|
||||||
"openid", "offline_access", "api"
|
|
||||||
},
|
|
||||||
Provider = "IdentityServer",
|
|
||||||
IdentityServerConfig = new FileIdentityServerConfig{
|
|
||||||
ProviderRootUrl = "http://localhost:52888",
|
|
||||||
RequireHttps = false,
|
|
||||||
ApiName = "api",
|
|
||||||
ApiSecret = "secret"
|
|
||||||
},
|
|
||||||
AuthenticationProviderKey = "Test"
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
ReRoutes = new List<FileReRoute>
|
ReRoutes = new List<FileReRoute>
|
||||||
{
|
{
|
||||||
new FileReRoute
|
new FileReRoute
|
||||||
|
@ -58,24 +58,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
/* AuthenticationOptions = new List<FileAuthenticationOptions>
|
|
||||||
{
|
|
||||||
new FileAuthenticationOptions
|
|
||||||
{
|
|
||||||
AllowedScopes = new List<string>
|
|
||||||
{
|
|
||||||
"openid", "offline_access", "api"
|
|
||||||
},
|
|
||||||
Provider = "IdentityServer",
|
|
||||||
IdentityServerConfig = new FileIdentityServerConfig{
|
|
||||||
ProviderRootUrl = "http://localhost:57888",
|
|
||||||
RequireHttps = false,
|
|
||||||
ApiName = "api",
|
|
||||||
ApiSecret = "secret"
|
|
||||||
},
|
|
||||||
AuthenticationProviderKey = "Test"
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
ReRoutes = new List<FileReRoute>
|
ReRoutes = new List<FileReRoute>
|
||||||
{
|
{
|
||||||
new FileReRoute
|
new FileReRoute
|
||||||
|
Loading…
x
Reference in New Issue
Block a user