diff --git a/src/Ocelot/Authentication/Handler/Creator/AuthenticationHandlerCreator.cs b/src/Ocelot/Authentication/Handler/Creator/AuthenticationHandlerCreator.cs index 910b99e4..5015fefa 100644 --- a/src/Ocelot/Authentication/Handler/Creator/AuthenticationHandlerCreator.cs +++ b/src/Ocelot/Authentication/Handler/Creator/AuthenticationHandlerCreator.cs @@ -19,7 +19,7 @@ namespace Ocelot.Authentication.Handler.Creator { var builder = app.New(); - var authenticationConfig = authOptions.Config as IdentityServerConfig; + var authenticationConfig = authOptions.Config; builder.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions { diff --git a/src/Ocelot/Configuration/AuthenticationOptions.cs b/src/Ocelot/Configuration/AuthenticationOptions.cs index cfb76fe4..25b65fe9 100644 --- a/src/Ocelot/Configuration/AuthenticationOptions.cs +++ b/src/Ocelot/Configuration/AuthenticationOptions.cs @@ -2,9 +2,11 @@ namespace Ocelot.Configuration { + using Newtonsoft.Json; + public class AuthenticationOptions { - public AuthenticationOptions(string provider, List allowedScopes, IAuthenticationConfig config) + public AuthenticationOptions(string provider, List allowedScopes, IdentityServerConfig config) { Provider = provider; AllowedScopes = allowedScopes; @@ -15,15 +17,10 @@ namespace Ocelot.Configuration public List AllowedScopes { get; private set; } - public IAuthenticationConfig Config { get; } + public IdentityServerConfig Config { get; private set; } } - - public interface IAuthenticationConfig - { - } - - public class IdentityServerConfig : IAuthenticationConfig + public class IdentityServerConfig { public IdentityServerConfig(string providerRootUrl, string apiName, bool requireHttps, string apiSecret) { diff --git a/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs b/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs index bd20717c..3f83d3a3 100644 --- a/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs +++ b/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs @@ -9,7 +9,7 @@ namespace Ocelot.Configuration.Builder private List _allowedScopes; - private IAuthenticationConfig _config; + private IdentityServerConfig _identityServerConfig; public AuthenticationOptionsBuilder WithProvider(string provider) { @@ -23,15 +23,15 @@ namespace Ocelot.Configuration.Builder return this; } - public AuthenticationOptionsBuilder WithConfiguration(IAuthenticationConfig config) + public AuthenticationOptionsBuilder WithIdntityServerConfigConfiguration(IdentityServerConfig config) { - _config = config; + _identityServerConfig = config; return this; } public AuthenticationOptions Build() { - return new AuthenticationOptions(_provider, _allowedScopes, _config); + return new AuthenticationOptions(_provider, _allowedScopes, _identityServerConfig); } } diff --git a/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs b/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs index ac185cdf..7f3f34a3 100644 --- a/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs +++ b/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs @@ -7,19 +7,19 @@ namespace Ocelot.Configuration.Creator { public AuthenticationOptions Create(FileReRoute fileReRoute) { - var authenticationConfig = new AuthenticationConfigCreator().Create(fileReRoute.AuthenticationOptions); + var authenticationConfig = new IdentityServerConfigCreator().Create(fileReRoute.AuthenticationOptions); return new AuthenticationOptionsBuilder() .WithProvider(fileReRoute.AuthenticationOptions?.Provider) .WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes) - .WithConfiguration(authenticationConfig) + .WithIdntityServerConfigConfiguration(authenticationConfig) .Build(); } } - public class AuthenticationConfigCreator + public class IdentityServerConfigCreator { - public IAuthenticationConfig Create(FileAuthenticationOptions authenticationOptions) + public IdentityServerConfig Create(FileAuthenticationOptions authenticationOptions) { return new IdentityServerConfigBuilder() .WithApiName(authenticationOptions.IdentityServerConfig?.ApiName) diff --git a/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs b/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs index 0ab4cc6a..88301610 100644 --- a/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs +++ b/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs @@ -29,7 +29,6 @@ namespace Ocelot.AcceptanceTests _steps = new Steps(); } - [Fact] public void should_return_response_200_with_simple_url() {