mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 20:10:50 +08:00 
			
		
		
		
	messing around on mac trying to get something working..
This commit is contained in:
		@@ -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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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.AddAuthentication(x =>
 | 
					            services.AddScheme<IdentityServerAuthenticationOptions, IdentityServerAuthenticationHandler>("IdentityServer", "IdentityServer", options);
 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    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;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user