mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 19:30:49 +08:00 
			
		
		
		
	Merge branch 'develop' of https://github.com/geffzhang/Ocelot into develop
This commit is contained in:
		@@ -138,8 +138,28 @@ Then map the authentication provider key to a ReRoute in your configuration e.g.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Okta
 | 
					Okta
 | 
				
			||||||
^^^^
 | 
					^^^^
 | 
				
			||||||
 | 
					Add nuget package : `"Okta.AspNetCore" https://www.nuget.org/packages/Okta.AspNetCore/`_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
I have not had time to write this up but we have `Issue 446 <https://github.com/ThreeMammals/Ocelot/issues/446>`_ that contains some code and examples that might help with Okta integration.
 | 
					In a StartUp.cs file add to a method Configure next lines:
 | 
				
			||||||
 | 
					app.UseAuthentication();
 | 
				
			||||||
 | 
					app.UseOcelot().Wait();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					In a StartUp.cs file add to a method ConfigureServices lines:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					services.AddAuthentication(options =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                options.DefaultAuthenticateScheme = OktaDefaults.ApiAuthenticationScheme;
 | 
				
			||||||
 | 
					                options.DefaultChallengeScheme = OktaDefaults.ApiAuthenticationScheme;
 | 
				
			||||||
 | 
					                options.DefaultSignInScheme = OktaDefaults.ApiAuthenticationScheme;
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					            .AddOktaWebApi(new OktaWebApiOptions
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                OktaDomain = _cfg["Okta:OktaDomain"]
 | 
				
			||||||
 | 
					               
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					services.AddOcelot(_cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`Issue 446 <https://github.com/ThreeMammals/Ocelot/issues/446>`_ that contains some code and examples that might help with Okta integration.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Allowed Scopes
 | 
					Allowed Scopes
 | 
				
			||||||
^^^^^^^^^^^^^
 | 
					^^^^^^^^^^^^^
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,8 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        IConfiguration Configuration { get; }
 | 
					        IConfiguration Configuration { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IMvcCoreBuilder MvcCoreBuilder { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        IOcelotBuilder AddDelegatingHandler<T>(bool global = false)
 | 
					        IOcelotBuilder AddDelegatingHandler<T>(bool global = false)
 | 
				
			||||||
            where T : DelegatingHandler;
 | 
					            where T : DelegatingHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,7 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        public IServiceCollection Services { get; }
 | 
					        public IServiceCollection Services { get; }
 | 
				
			||||||
        public IConfiguration Configuration { get; }
 | 
					        public IConfiguration Configuration { get; }
 | 
				
			||||||
 | 
					        public IMvcCoreBuilder MvcCoreBuilder { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public OcelotBuilder(IServiceCollection services, IConfiguration configurationRoot)
 | 
					        public OcelotBuilder(IServiceCollection services, IConfiguration configurationRoot)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -133,7 +134,7 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
            //add asp.net services..
 | 
					            //add asp.net services..
 | 
				
			||||||
            var assembly = typeof(FileConfigurationController).GetTypeInfo().Assembly;
 | 
					            var assembly = typeof(FileConfigurationController).GetTypeInfo().Assembly;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Services.AddMvcCore()
 | 
					            this.MvcCoreBuilder = Services.AddMvcCore()
 | 
				
			||||||
                  .AddApplicationPart(assembly)
 | 
					                  .AddApplicationPart(assembly)
 | 
				
			||||||
                  .AddControllersAsServices()
 | 
					                  .AddControllersAsServices()
 | 
				
			||||||
                  .AddAuthorization()
 | 
					                  .AddAuthorization()
 | 
				
			||||||
@@ -144,6 +145,7 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
            Services.AddWebEncoders();
 | 
					            Services.AddWebEncoders();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IOcelotBuilder AddSingletonDefinedAggregator<T>()
 | 
					        public IOcelotBuilder AddSingletonDefinedAggregator<T>()
 | 
				
			||||||
            where T : class, IDefinedAggregator
 | 
					            where T : class, IDefinedAggregator
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
namespace Ocelot.Infrastructure.Claims.Parser
 | 
					namespace Ocelot.Infrastructure.Claims.Parser
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    using Errors;
 | 
					    using Microsoft.Extensions.Primitives;
 | 
				
			||||||
    using Responses;
 | 
					    using Responses;
 | 
				
			||||||
    using System.Collections.Generic;
 | 
					    using System.Collections.Generic;
 | 
				
			||||||
    using System.Linq;
 | 
					    using System.Linq;
 | 
				
			||||||
@@ -45,11 +45,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private Response<string> GetValue(IEnumerable<Claim> claims, string key)
 | 
					        private Response<string> GetValue(IEnumerable<Claim> claims, string key)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var claim = claims.FirstOrDefault(c => c.Type == key);
 | 
					            var claimValues = claims.Where(c => c.Type == key).Select(c => c.Value).ToArray();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (claim != null)
 | 
					            if (claimValues.Length > 0)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return new OkResponse<string>(claim.Value);
 | 
					                return new OkResponse<string>(new StringValues(claimValues).ToString());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return new ErrorResponse<string>(new CannotFindClaimError($"Cannot find claim for key: {key}"));
 | 
					            return new ErrorResponse<string>(new CannotFindClaimError($"Cannot find claim for key: {key}"));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user