From fcefae273f09f75e348c83e0fc1905a4ca9b4e0d Mon Sep 17 00:00:00 2001 From: geffzhang Date: Mon, 11 Mar 2019 10:08:17 +0800 Subject: [PATCH 1/4] K8s package (#804) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Kubernetes ServiceDiscoveryProvider * 编写k8s测试例子 * feat:fix kube config * feat: remove port * feat : complete the k8s test * feat : add kubeserviceDiscovery test * feat : add kube provider unittest * feat :add kubetnetes docs how to use ocelot with kubetnetes docs * keep the configuration as simple as possible, no qos, no cache * fix: use http * add PollingKubeServiceDiscovery * feat : refactor logger * feat : add pollkube docs * feat:Remove unnecessary code * feat : code-block json * feat: publish package Ocelot.Provider.Kubernetes --- .../Ocelot.Provider.Kubernetes.csproj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj index 7a82d52f..a9c43364 100644 --- a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj +++ b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj @@ -2,6 +2,16 @@ netstandard2.0 + true + 0.0.0-dev + geffzhang + + Ocelot + Provides Ocelot extensions to use kubernetes + https://github.com/ThreeMammals/Ocelot + http://threemammals.com/images/ocelot_logo.png + + API Gateway;.NET core From 6f95b20b488f11a3f45aeec735ef83a92918cd1d Mon Sep 17 00:00:00 2001 From: SychevIgor Date: Mon, 11 Mar 2019 16:53:51 +0300 Subject: [PATCH 2/4] Okta integration (#807) Okta integration --- docs/features/authentication.rst | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/features/authentication.rst b/docs/features/authentication.rst index a7599c32..cb2ec08d 100644 --- a/docs/features/authentication.rst +++ b/docs/features/authentication.rst @@ -138,8 +138,28 @@ Then map the authentication provider key to a ReRoute in your configuration e.g. 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 `_ 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 `_ that contains some code and examples that might help with Okta integration. Allowed Scopes ^^^^^^^^^^^^^ From 49b2a0f0ce417c559981aef8c2f1cd12cc5ac014 Mon Sep 17 00:00:00 2001 From: liweihan Date: Mon, 11 Mar 2019 21:55:13 +0800 Subject: [PATCH 3/4] update cliamsParser (#798) * update cliamsParser * update using --- .../Infrastructure/Claims/Parser/ClaimsParser.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs b/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs index 773b4375..e25a58c8 100644 --- a/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs +++ b/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs @@ -1,6 +1,6 @@ namespace Ocelot.Infrastructure.Claims.Parser { - using Errors; + using Microsoft.Extensions.Primitives; using Responses; using System.Collections.Generic; using System.Linq; @@ -45,14 +45,14 @@ private Response GetValue(IEnumerable 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(claim.Value); + return new OkResponse(new StringValues(claimValues).ToString()); } return new ErrorResponse(new CannotFindClaimError($"Cannot find claim for key: {key}")); } } -} +} From 4a1e8d571bd4771cdb13a79e7369e51d2e1150bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=87=8C?= <510415008@qq.com> Date: Mon, 11 Mar 2019 22:39:27 +0800 Subject: [PATCH 4/4] IOcelotBuilder opens the IMvcCoreBuilder property for easy customization (#790) * IOcelotBuilder opens the IMvcCoreBuilder property for easy customization * Adjustment code --- src/Ocelot/DependencyInjection/IOcelotBuilder.cs | 2 ++ src/Ocelot/DependencyInjection/OcelotBuilder.cs | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Ocelot/DependencyInjection/IOcelotBuilder.cs b/src/Ocelot/DependencyInjection/IOcelotBuilder.cs index 5e22f8f6..34841c80 100644 --- a/src/Ocelot/DependencyInjection/IOcelotBuilder.cs +++ b/src/Ocelot/DependencyInjection/IOcelotBuilder.cs @@ -12,6 +12,8 @@ namespace Ocelot.DependencyInjection IConfiguration Configuration { get; } + IMvcCoreBuilder MvcCoreBuilder { get; } + IOcelotBuilder AddDelegatingHandler(bool global = false) where T : DelegatingHandler; diff --git a/src/Ocelot/DependencyInjection/OcelotBuilder.cs b/src/Ocelot/DependencyInjection/OcelotBuilder.cs index 753bf0e0..29719ef1 100644 --- a/src/Ocelot/DependencyInjection/OcelotBuilder.cs +++ b/src/Ocelot/DependencyInjection/OcelotBuilder.cs @@ -42,6 +42,7 @@ namespace Ocelot.DependencyInjection { public IServiceCollection Services { get; } public IConfiguration Configuration { get; } + public IMvcCoreBuilder MvcCoreBuilder { get; } public OcelotBuilder(IServiceCollection services, IConfiguration configurationRoot) { @@ -133,17 +134,18 @@ namespace Ocelot.DependencyInjection //add asp.net services.. var assembly = typeof(FileConfigurationController).GetTypeInfo().Assembly; - Services.AddMvcCore() - .AddApplicationPart(assembly) - .AddControllersAsServices() - .AddAuthorization() - .AddJsonFormatters(); + this.MvcCoreBuilder = Services.AddMvcCore() + .AddApplicationPart(assembly) + .AddControllersAsServices() + .AddAuthorization() + .AddJsonFormatters(); Services.AddLogging(); Services.AddMiddlewareAnalysis(); Services.AddWebEncoders(); } + public IOcelotBuilder AddSingletonDefinedAggregator() where T : class, IDefinedAggregator { @@ -170,7 +172,7 @@ namespace Ocelot.DependencyInjection if(global) { Services.AddTransient(); - Services.AddTransient(s => { + Services.AddTransient(s =>{ var service = s.GetService(); return new GlobalDelegatingHandler(service); });