From c1cfaf0fbb4d87b8047f0b21d5cd52bdbb4ef2a7 Mon Sep 17 00:00:00 2001 From: Tom Gardham-Pallister Date: Mon, 30 Oct 2017 19:57:11 +0000 Subject: [PATCH] messing around on mac trying to get something working.. --- .../Middleware/AuthenticationMiddleware.cs | 3 ++- .../ServiceCollectionExtensions.cs | 27 +++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs index ac7a5964..d8fca9ab 100644 --- a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs +++ b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs @@ -102,7 +102,8 @@ namespace Ocelot.Authentication.Middleware //auth.AddScheme(scheme); //todo - call the next middleware to authenticate? Does this need to be on a different branch so it doesnt call any further middlewares? - var result = await context.AuthenticateAsync(DownstreamRoute.ReRoute.AuthenticationOptions.Provider); + var scheme = await auth.GetSchemeAsync("IdentityServer"); + var result = await context.AuthenticateAsync("IdentityServer"); context.User = result.Principal; if (context.User.Identity.IsAuthenticated) diff --git a/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs b/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs index 0a64beee..3bbc8aa1 100644 --- a/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs @@ -150,27 +150,20 @@ namespace Ocelot.DependencyInjection { services.AddIdentityServer(identityServerConfiguration, configurationRoot); } - services.AddSingleton(services); - - Action builder = schemeBuilder => + // public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureOptions) + Action options = o => { - - } + o.Authority = "http://localhost:51888"; + o.ApiName = "api"; + o.RequireHttpsMetadata = false; + o.SupportedTokens = SupportedTokens.Both; + o.ApiSecret = "secret"; + }; - services.AddAuthentication(x => - { - x.AddScheme("", ); - }) - .AddIdentityServerAuthentication(o => - { - o.Authority = "http://localhost:51888"; - o.ApiName = "api"; - o.RequireHttpsMetadata = false; - o.SupportedTokens = SupportedTokens.Both; - o.ApiSecret = "secret"; - }); + services.AddScheme("IdentityServer", "IdentityServer", options); + services.AddScheme("IdentityServerIdentityServerAuthenticationJwt", "IdentityServerIdentityServerAuthenticationJwt", options); return services; }