bit more tidying

This commit is contained in:
TomPallister
2017-07-04 19:41:41 +01:00
parent 34cd2e1392
commit 09c9a25883
8 changed files with 42 additions and 17 deletions

View File

@ -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);
}
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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,

View File

@ -0,0 +1,10 @@
using Ocelot.Configuration;
using Ocelot.Configuration.File;
namespace Ocelot.Creator.Configuration
{
public interface IAuthenticationProviderConfigCreator
{
IAuthenticationConfig Create(FileAuthenticationOptions authenticationOptions);
}
}

View File

@ -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>();