From f56fe32e75eebdcd4c1a9df12c3a566aac2d5382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 4 Aug 2021 14:43:13 +0300 Subject: [PATCH] install curl to web image --- .../charts/account/templates/account-ingress.yaml | 13 +++++++++++++ .../EventHubIdentityServerModule.cs | 12 ++++++++++++ src/EventHub.Web/Dockerfile | 1 + src/EventHub.Web/EventHubWebModule.cs | 3 ++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/etc/k8s/helm-chart/eventhub/charts/account/templates/account-ingress.yaml b/etc/k8s/helm-chart/eventhub/charts/account/templates/account-ingress.yaml index a678100..fbdfd6f 100644 --- a/etc/k8s/helm-chart/eventhub/charts/account/templates/account-ingress.yaml +++ b/etc/k8s/helm-chart/eventhub/charts/account/templates/account-ingress.yaml @@ -5,13 +5,26 @@ metadata: annotations: nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/configuration-snippet: | + more_set_input_headers "fromingress: true"; spec: tls: - hosts: - {{ .Values.accountUrl }} + - accounttemp secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls rules: - host: "{{ .Values.accountUrl }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 + - host: "accounttemp" http: paths: - path: / diff --git a/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs b/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs index 15b82d9..a626db5 100644 --- a/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs +++ b/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs @@ -14,6 +14,7 @@ using EventHub.Web; using EventHub.Web.Theme; using EventHub.Web.Theme.Bundling; using IdentityServer4.Configuration; +using IdentityServer4.Extensions; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; @@ -186,6 +187,7 @@ namespace EventHub { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); + var conf = context.ServiceProvider.GetRequiredService(); /* app.Use((context, next) => @@ -195,6 +197,16 @@ namespace EventHub }); */ + app.Use(async (ctx, next) => + { + if (ctx.Request.Headers.ContainsKey("fromingress")) + { + ctx.SetIdentityServerOrigin(conf["App:SelfUrl"]); + } + + await next(); + }); + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); diff --git a/src/EventHub.Web/Dockerfile b/src/EventHub.Web/Dockerfile index ab31322..e65d369 100644 --- a/src/EventHub.Web/Dockerfile +++ b/src/EventHub.Web/Dockerfile @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/dotnet/aspnet:5.0 COPY bin/Release/net5.0/publish/ app/ + RUN apt-get update && apt-get install -y curl WORKDIR /app ENTRYPOINT ["dotnet", "EventHub.Web.dll"] \ No newline at end of file diff --git a/src/EventHub.Web/EventHubWebModule.cs b/src/EventHub.Web/EventHubWebModule.cs index 3f5a04e..3e394ff 100644 --- a/src/EventHub.Web/EventHubWebModule.cs +++ b/src/EventHub.Web/EventHubWebModule.cs @@ -151,12 +151,13 @@ namespace EventHub.Web options.Scope.Add("email"); options.Scope.Add("phone"); options.Scope.Add("EventHub"); - + /* options.Events.OnRedirectToIdentityProvider = redirectContext => { redirectContext.ProtocolMessage.RedirectUri = $"{configuration["App:SelfUrl"]}/signin-oidc"; return Task.CompletedTask; }; + */ }); }