Browse Source

revized config

pull/51/head
Halil İbrahim Kalkan 5 years ago
parent
commit
5cd1c99d44
  1. 5
      etc/k8s/README.md
  2. 8
      etc/k8s/helm-chart/eventhub/templates/_helpers.tpl
  3. 6
      etc/k8s/helm-chart/eventhub/values.yaml
  4. 2
      src/EventHub.Admin.HttpApi.Host/appsettings.Development.json
  5. 32
      src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs
  6. 7
      src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs
  7. 14
      src/EventHub.HttpApi.Host/appsettings.Development.json
  8. 13
      src/EventHub.HttpApi.Host/appsettings.json
  9. 34
      src/EventHub.IdentityServer/EventHubIdentityServerModule.cs
  10. 8
      src/EventHub.IdentityServer/appsettings.Development.json
  11. 22
      src/EventHub.IdentityServer/appsettings.json
  12. 8
      src/EventHub.Web/EventHubWebModule.cs
  13. 3
      src/EventHub.Web/appsettings.Development.json
  14. 17
      src/EventHub.Web/appsettings.json

5
etc/k8s/README.md

@ -0,0 +1,5 @@
### How to run?
* Run `build-images.ps1` in the `scripts` directory.
* Run `helm install eh-st eventhub` in the `helm-chart` directory.

8
etc/k8s/helm-chart/eventhub/templates/_helpers.tpl

@ -9,4 +9,12 @@
value: "{{ .Values.global.adminUrlFull }}"
- name: "AppUrls__AdminApi"
value: "{{ .Values.global.adminApiUrlFull }}"
- name: "Redis__Configuration"
value: "{{ .Values.global.redisConfiguration }}"
- name: "AuthServer__Authority"
value: "{{ .Values.global.internalAuthServerAuthority }}"
- name: "AuthServer__RequireHttpsMetadata"
value: "{{ .Values.global.internalAuthServerRequireHttpsMetadata }}"
- name: "StringEncryption__DefaultPassPhrase"
value: "{{ .Values.global.stringEncryptionDefaultPassPhrase }}"
{{- end }}

6
etc/k8s/helm-chart/eventhub/values.yaml

@ -11,4 +11,8 @@ global:
adminApiUrlFull: https://eh-st-admin-api
nginxProxyBufferSize: "32k"
nginxProxyBuffersNumber: "8"
defaultConnString: "Host=eh-st-postgresql;Port=5435;Database=EventHub;Username=root;Password=root"
defaultConnString: "Host=eh-st-postgresql;Port=5435;Database=EventHub;Username=root;Password=root"
redisConfiguration: "eh-st-redis"
internalAuthServerAuthority: "http://eh-st-account"
internalAuthServerRequireHttpsMetadata: "false"
stringEncryptionDefaultPassPhrase: "TxVIZFPxK33czbbv"

2
src/EventHub.Admin.HttpApi.Host/appsettings.Development.json

@ -1,2 +0,0 @@
{
}

32
src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs

@ -2,10 +2,42 @@
{
public class EventHubUrlOptions
{
private const string ConfigurationName = "AppUrls";
public string Account { get; set; } = "https://localhost:44313";
public string Www { get; set; } = "https://localhost:44308";
public string Api { get; set; } = "https://localhost:44362";
public string Admin { get; set; } = "https://localhost:44307";
public string AdminApi { get; set; } = "https://localhost:44305";
public static string GetAccountConfigKey()
{
return GetConfigKey(nameof(Account));
}
public static string GetWwwConfigKey()
{
return GetConfigKey(nameof(Www));
}
public static string GetApiConfigKey()
{
return GetConfigKey(nameof(Api));
}
public static string GetAdminConfigKey()
{
return GetConfigKey(nameof(Admin));
}
public static string GetAdminApiConfigKey()
{
return GetConfigKey(nameof(AdminApi));
}
private static string GetConfigKey(string appName)
{
return $"{ConfigurationName}:{appName}";
}
}
}

7
src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs

@ -11,6 +11,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using EventHub.EntityFrameworkCore;
using EventHub.Web;
using Microsoft.AspNetCore.Localization;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
@ -26,6 +27,7 @@ using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Swashbuckle;
using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem;
namespace EventHub
@ -158,10 +160,7 @@ namespace EventHub
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
configuration[EventHubUrlOptions.GetWwwConfigKey()]
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()

14
src/EventHub.HttpApi.Host/appsettings.Development.json

@ -1,14 +0,0 @@
{
"ConnectionStrings": {
"Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432"
},
"Redis": {
"Configuration": "127.0.0.1"
},
"AuthServer": {
"Authority": "https://localhost:44313",
"RequireHttpsMetadata": "true",
"SwaggerClientId": "EventHub_Swagger",
"SwaggerClientSecret": "1q2w3e*"
}
}

13
src/EventHub.HttpApi.Host/appsettings.json

@ -1,21 +1,14 @@
{
"App": {
"CorsOrigins": "https://eh-st-www,eh-st-admin",
"WebAppUrl": "https://eh-st-www"
},
"ConnectionStrings": {
"Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432"
},
"Redis": {
"Configuration": "eh-st-redis"
"Configuration": "localhost"
},
"AuthServer": {
"Authority": "http://eh-st-account",
"RequireHttpsMetadata": "false",
"Authority": "https://localhost:44313",
"RequireHttpsMetadata": "true",
"SwaggerClientId": "EventHub_Swagger",
"SwaggerClientSecret": "1q2w3e*"
},
"StringEncryption": {
"DefaultPassPhrase": "TxVIZFPxK33czbbv"
}
}

34
src/EventHub.IdentityServer/EventHubIdentityServerModule.cs

@ -1,6 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Builder;
@ -17,13 +15,11 @@ using IdentityServer4.Configuration;
using IdentityServer4.Extensions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using StackExchange.Redis;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Auditing;
@ -119,14 +115,9 @@ namespace EventHub
options.ApplicationName = "AuthServer";
});
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
});
Configure<IdentityServerOptions>(options =>
{
options.IssuerUri = configuration["App:SelfUrl"];
options.IssuerUri = configuration["AppUrls:Account"];
});
if (hostingEnvironment.IsDevelopment())
@ -141,8 +132,13 @@ namespace EventHub
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(','));
options.Applications["MVC"].RootUrl = configuration[EventHubUrlOptions.GetAccountConfigKey()];
options.RedirectAllowedUrls.AddRange(
new[]
{
configuration[EventHubUrlOptions.GetWwwConfigKey()],
configuration[EventHubUrlOptions.GetAdminConfigKey()]
});
});
Configure<AbpBackgroundJobOptions>(options =>
@ -166,10 +162,10 @@ namespace EventHub
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
configuration[EventHubUrlOptions.GetWwwConfigKey()],
configuration[EventHubUrlOptions.GetApiConfigKey()],
configuration[EventHubUrlOptions.GetAdminConfigKey()],
configuration[EventHubUrlOptions.GetAdminApiConfigKey()]
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
@ -186,7 +182,7 @@ namespace EventHub
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
var conf = context.ServiceProvider.GetRequiredService<IConfiguration>();
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
/*
app.Use((context, next) =>
@ -200,7 +196,7 @@ namespace EventHub
{
if (ctx.Request.Headers.ContainsKey("fromingress"))
{
ctx.SetIdentityServerOrigin(conf["App:SelfUrl"]);
ctx.SetIdentityServerOrigin(configuration[EventHubUrlOptions.GetAccountConfigKey()]);
}
await next();
@ -221,7 +217,7 @@ namespace EventHub
app.UseCookiePolicy();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();

8
src/EventHub.IdentityServer/appsettings.Development.json

@ -1,8 +0,0 @@
{
"ConnectionStrings": {
"Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432"
},
"Redis": {
"Configuration": "localhost"
}
}

22
src/EventHub.IdentityServer/appsettings.json

@ -1,28 +1,8 @@
{
"App": {
"SelfUrl": "https://eh-st-account",
"CorsOrigins": "https://eh-st-www,https://eh-st-api,https://localhost:44307,https://localhost:44362",
"RedirectAllowedUrls": "https://eh-st-api,https://eh-st-www,http://eh-st-api,http://eh-st-www",
"WebAppUrl": "https://eh-st-www"
},
"ConnectionStrings": {
"Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432"
},
"Redis": {
"Configuration": "eh-st-redis"
},
"StringEncryption": {
"DefaultPassPhrase": "TxVIZFPxK33czbbv"
},
"Settings": {
"Abp.Mailing.Smtp.Host": "127.0.0.1",
"Abp.Mailing.Smtp.Port": "25",
"Abp.Mailing.Smtp.UserName": "",
"Abp.Mailing.Smtp.Password": "",
"Abp.Mailing.Smtp.Domain": "",
"Abp.Mailing.Smtp.EnableSsl": "false",
"Abp.Mailing.Smtp.UseDefaultCredentials": "true",
"Abp.Mailing.DefaultFromAddress": "noreply@abp.io",
"Abp.Mailing.DefaultFromDisplayName": "ABP application"
"Configuration": "localhost"
}
}

8
src/EventHub.Web/EventHubWebModule.cs

@ -28,6 +28,7 @@ using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper;
using Volo.Abp.Caching;
using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.IdentityModel.Web;
using Volo.Abp.Modularity;
using Volo.Abp.Swashbuckle;
@ -109,7 +110,12 @@ namespace EventHub.Web
{
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.Applications["MVC"].RootUrl = configuration[EventHubUrlOptions.GetWwwConfigKey()];
});
Configure<AbpRemoteServiceOptions>(options =>
{
options.RemoteServices.Default.BaseUrl = configuration[EventHubUrlOptions.GetApiConfigKey()].EnsureEndsWith('/');
});
}

3
src/EventHub.Web/appsettings.Development.json

@ -1,3 +0,0 @@
{
}

17
src/EventHub.Web/appsettings.json

@ -1,22 +1,11 @@
{
"App": {
"SelfUrl": "https://eh-st-www"
},
"RemoteServices": {
"Default": {
"BaseUrl": "http://eh-st-api/"
}
},
"Redis": {
"Configuration": "eh-st-redis"
"Configuration": "localhost"
},
"AuthServer": {
"Authority": "http://eh-st-account",
"RequireHttpsMetadata": "false",
"Authority": "https://localhost:44313",
"RequireHttpsMetadata": "true",
"ClientId": "EventHub_Web",
"ClientSecret": "1q2w3e*"
},
"StringEncryption": {
"DefaultPassPhrase": "7loHY5ax625vIGkV"
}
}

Loading…
Cancel
Save