messing around on mac trying to get something working..

This commit is contained in:
Tom Gardham-Pallister 2017-10-30 19:57:11 +00:00
parent fd9eae0152
commit c1cfaf0fbb
2 changed files with 12 additions and 18 deletions

View File

@ -102,7 +102,8 @@ namespace Ocelot.Authentication.Middleware
//auth.AddScheme(scheme); //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? //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; context.User = result.Principal;
if (context.User.Identity.IsAuthenticated) if (context.User.Identity.IsAuthenticated)

View File

@ -150,27 +150,20 @@ namespace Ocelot.DependencyInjection
{ {
services.AddIdentityServer(identityServerConfiguration, configurationRoot); services.AddIdentityServer(identityServerConfiguration, configurationRoot);
} }
services.AddSingleton(services);
// public static IServiceCollection AddScheme<TOptions, THandler>(this IServiceCollection services, string authenticationScheme, Action<TOptions> configureOptions)
Action<AuthenticationSchemeBuilder> builder = schemeBuilder => Action<IdentityServerAuthenticationOptions> options = o =>
{ {
o.Authority = "http://localhost:51888";
o.ApiName = "api";
o.RequireHttpsMetadata = false;
o.SupportedTokens = SupportedTokens.Both;
o.ApiSecret = "secret";
};
} services.AddScheme<IdentityServerAuthenticationOptions, IdentityServerAuthenticationHandler>("IdentityServer", "IdentityServer", options);
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<IdentityServerAuthenticationOptions, IdentityServerAuthenticationHandler>("IdentityServerIdentityServerAuthenticationJwt", "IdentityServerIdentityServerAuthenticationJwt", options);
return services; return services;
} }