Browse Source

Added account & api services

pull/51/head
Halil İbrahim Kalkan 5 years ago
parent
commit
72d7a4888a
  1. 3
      etc/k8s/helm-chart/eventhub/charts/account/templates/account-ingress.yaml
  2. 4
      etc/k8s/helm-chart/eventhub/charts/account/templates/account-service.yaml
  3. 2
      etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml
  4. 6
      etc/k8s/helm-chart/eventhub/charts/api/Chart.yaml
  5. 18
      etc/k8s/helm-chart/eventhub/charts/api/templates/api-ingress.yaml
  6. 14
      etc/k8s/helm-chart/eventhub/charts/api/templates/api-service.yaml
  7. 22
      etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml
  8. 1
      src/EventHub.Admin.HttpApi.Host/EventHubAdminHttpApiHostModule.cs
  9. 2
      src/EventHub.Admin.HttpApi.Host/Program.cs
  10. 4
      src/EventHub.DbMigrator/EventHub.DbMigrator.csproj
  11. 5
      src/EventHub.DbMigrator/appsettings.Development.json
  12. 8
      src/EventHub.Domain.Shared/Web/EventHubExternalUrls.cs
  13. 4
      src/EventHub.HttpApi.Host/Dockerfile
  14. 10
      src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs
  15. 2
      src/EventHub.HttpApi.Host/Program.cs
  16. 70
      src/EventHub.HttpApi.Host/SameSiteCookiesServiceCollectionExtensions.cs
  17. 12
      src/EventHub.HttpApi.Host/appsettings.Development.json
  18. 6
      src/EventHub.HttpApi.Host/appsettings.json
  19. 4
      src/EventHub.IdentityServer/EventHub.IdentityServer.csproj
  20. 16
      src/EventHub.IdentityServer/EventHubIdentityServerModule.cs
  21. 8
      src/EventHub.IdentityServer/appsettings.Development.json
  22. 6
      src/EventHub.Web.Theme/wwwroot/themes/eventhub/owl-edit.css
  23. 6
      src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css
  24. 2
      src/EventHub.Web/Program.cs

3
etc/k8s/helm-chart/eventhub/charts/account/templates/account-ingress.yaml

@ -4,6 +4,7 @@ metadata:
name: account-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
spec:
rules:
- host: "account.openeventhub.com"
@ -15,4 +16,4 @@ spec:
service:
name: account
port:
number: 443
number: 80

4
etc/k8s/helm-chart/eventhub/charts/account/templates/account-service.yaml

@ -8,7 +8,7 @@ spec:
ports:
- name: "80"
port: 80
- name: "433"
port: 433
- name: "443"
port: 443
selector:
app: account

2
etc/k8s/helm-chart/eventhub/charts/account/templates/account.yaml

@ -19,4 +19,4 @@ spec:
- name: accounthttp
containerPort: 80
- name: accounthttps
containerPort: 433
containerPort: 443

6
etc/k8s/helm-chart/eventhub/charts/api/Chart.yaml

@ -0,0 +1,6 @@
apiVersion: v2
name: api
appVersion: "1.0"
description: EventHub API Application
version: 1.0.0
type: application

18
etc/k8s/helm-chart/eventhub/charts/api/templates/api-ingress.yaml

@ -0,0 +1,18 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: "api.openeventhub.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api
port:
number: 80

14
etc/k8s/helm-chart/eventhub/charts/api/templates/api-service.yaml

@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
name: api
name: api
spec:
ports:
- name: "80"
port: 80
- name: "443"
port: 443
selector:
app: api

22
etc/k8s/helm-chart/eventhub/charts/api/templates/api.yaml

@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- image: eventhub.api
imagePullPolicy: Never
name: api
ports:
- name: apihttp
containerPort: 80
- name: apihttps
containerPort: 443

1
src/EventHub.Admin.HttpApi.Host/EventHubAdminHttpApiHostModule.cs

@ -15,6 +15,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Serilog;

2
src/EventHub.Admin.HttpApi.Host/Program.cs

@ -20,9 +20,7 @@ namespace EventHub.Admin
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try

4
src/EventHub.DbMigrator/EventHub.DbMigrator.csproj

@ -12,6 +12,10 @@
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

5
src/EventHub.DbMigrator/appsettings.Development.json

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

8
src/EventHub.Domain.Shared/Web/EventHubExternalUrls.cs

@ -9,10 +9,10 @@ namespace EventHub.Web
public const string EhWww = "https://localhost:44308";
#else
// TODO: Change these production links
public const string EhAccount = "https://localhost:44313";
public const string EhApi = "https://localhost:44362";
public const string EhAdmin = "https://localhost:44307";
public const string EhWww = "https://localhost:44308";
public const string EhAccount = "https://account.openeventhub.com";
public const string EhApi = "https://api.openeventhub.com";
public const string EhAdmin = "https://admin.openeventhub.com";
public const string EhWww = "https://openeventhub.com";
#endif
}
}

4
src/EventHub.HttpApi.Host/Dockerfile

@ -0,0 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0
COPY bin/Release/net5.0/publish/ app/
WORKDIR /app
ENTRYPOINT ["dotnet", "EventHub.HttpApi.Host.dll"]

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

@ -170,6 +170,8 @@ namespace EventHub
.AllowCredentials();
});
});
context.Services.AddSameSiteCookiePolicy();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -181,6 +183,12 @@ namespace EventHub
{
app.UseDeveloperExceptionPage();
}
app.Use((context, next) =>
{
context.Request.Scheme = "https";
return next();
});
var supportedCultures = new[]
{
@ -204,6 +212,8 @@ namespace EventHub
app.UseErrorPage();
}
app.UseCookiePolicy();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();

2
src/EventHub.HttpApi.Host/Program.cs

@ -20,9 +20,7 @@ namespace EventHub
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try

70
src/EventHub.HttpApi.Host/SameSiteCookiesServiceCollectionExtensions.cs

@ -0,0 +1,70 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
namespace Microsoft.Extensions.DependencyInjection
{
public static class SameSiteCookiesServiceCollectionExtensions
{
public static IServiceCollection AddSameSiteCookiePolicy(this IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
options.OnAppendCookie = cookieContext =>
CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
options.OnDeleteCookie = cookieContext =>
CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
});
return services;
}
private static void CheckSameSite(HttpContext httpContext, CookieOptions options)
{
if (options.SameSite == SameSiteMode.None)
{
var userAgent = httpContext.Request.Headers["User-Agent"].ToString();
if (!httpContext.Request.IsHttps || DisallowsSameSiteNone(userAgent))
{
// For .NET Core < 3.1 set SameSite = (SameSiteMode)(-1)
options.SameSite = SameSiteMode.Unspecified;
}
}
}
private static bool DisallowsSameSiteNone(string userAgent)
{
// Cover all iOS based browsers here. This includes:
// - Safari on iOS 12 for iPhone, iPod Touch, iPad
// - WkWebview on iOS 12 for iPhone, iPod Touch, iPad
// - Chrome on iOS 12 for iPhone, iPod Touch, iPad
// All of which are broken by SameSite=None, because they use the iOS networking stack
if (userAgent.Contains("CPU iPhone OS 12") || userAgent.Contains("iPad; CPU OS 12"))
{
return true;
}
// Cover Mac OS X based browsers that use the Mac OS networking stack. This includes:
// - Safari on Mac OS X.
// This does not include:
// - Chrome on Mac OS X
// Because they do not use the Mac OS networking stack.
if (userAgent.Contains("Macintosh; Intel Mac OS X 10_14") &&
userAgent.Contains("Version/") && userAgent.Contains("Safari"))
{
return true;
}
// Cover Chrome 50-69, because some versions are broken by SameSite=None,
// and none in this range require it.
// Note: this covers some pre-Chromium Edge versions,
// but pre-Chromium Edge does not require SameSite=None.
if (userAgent.Contains("Chrome/5") || userAgent.Contains("Chrome/6"))
{
return true;
}
return false;
}
}
}

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

@ -1,2 +1,14 @@
{
"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*"
}
}

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

@ -3,13 +3,13 @@
"CorsOrigins": "https://*.openeventhub.com,https://localhost:44307,https://localhost:44308"
},
"ConnectionStrings": {
"Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432"
"Default": "Host=postgresql;Port=5435;Database=EventHub;Username=root;Password=root"
},
"Redis": {
"Configuration": "127.0.0.1"
"Configuration": "redis"
},
"AuthServer": {
"Authority": "https://localhost:44313",
"Authority": "https://account.openeventhub.com",
"RequireHttpsMetadata": "true",
"SwaggerClientId": "EventHub_Swagger",
"SwaggerClientSecret": "1q2w3e*"

4
src/EventHub.IdentityServer/EventHub.IdentityServer.csproj

@ -20,6 +20,10 @@
<Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" />
<None Remove="localhost.pfx" />
<Content Include="localhost.pfx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>

16
src/EventHub.IdentityServer/EventHubIdentityServerModule.cs

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
@ -13,6 +14,7 @@ using EventHub.Web;
using EventHub.Web.Theme;
using EventHub.Web.Theme.Bundling;
using IdentityServer4.Configuration;
using Microsoft.IdentityModel.Tokens;
using StackExchange.Redis;
using Volo.Abp;
using Volo.Abp.Account;
@ -46,6 +48,14 @@ namespace EventHub
{
private const string DefaultCorsPolicyName = "Default";
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<IIdentityServerBuilder>(builder =>
{
builder.AddSigningCredential(new X509Certificate2("localhost.pfx", "e8202f07-66e5-4619-be07-72ba76fde97f"));
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
@ -148,6 +158,12 @@ namespace EventHub
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
app.Use((context, next) =>
{
context.Request.Scheme = "https";
return next();
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();

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

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

6
src/EventHub.Web.Theme/wwwroot/themes/eventhub/owl-edit.css

@ -10,7 +10,7 @@
.main-slider .owl-carousel .owl-nav button.owl-next {
width: 40px;
height: 40px;
background: rgb(0 4 74 / 20%);
background: rgba(0, 4, 74, 0.2);
transition: background-color .3s ease;
position: absolute;
display: inline-block;
@ -24,7 +24,7 @@
}
.main-slider .owl-carousel .owl-nav button.owl-prev:hover,
.main-slider .owl-carousel .owl-nav button.owl-next:hover {
background: rgb(255 255 255 / 35%);
background: rgba(255, 255, 255, 0.35);
}
.main-slider .owl-carousel .owl-nav button span {
font-size: 40px;
@ -65,7 +65,7 @@
.card-slider .owl-carousel .owl-nav button.owl-next {
width: 9px;
height: 15px;
background: rgb(255 255 255 / 22%);
background: rgba(255, 255, 255, 0.22);
transition: background-color .3s ease;
display: inline-block;
overflow: hidden;

6
src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css

@ -754,7 +754,7 @@ div.checkbox.switcher label, div.radio.switcher label {
margin-right: 10px;
width: 56px;
height: 30px;
background: rgb(107 126 146 / 20%);
background: rgba(107, 126, 146, 0.20);
border: 3px solid #e1e5e9;
border-radius: 50px;
transition: all 0.3s ease-in-out;
@ -791,7 +791,7 @@ div.checkbox.switcher label, div.radio.switcher label {
.image-area {
border: 2px dashed rgb(218 224 229);
border: 2px dashed rgb(218, 224, 229);
padding: 1em;
position: relative;
border-radius: 10px;
@ -802,7 +802,7 @@ div.checkbox.switcher label, div.radio.switcher label {
.image-area::before {
content: 'Uploaded image result';
color: rgb(218 224 229);
color: rgb(218, 224, 229);
font-weight: bold;
text-transform: uppercase;
position: absolute;

2
src/EventHub.Web/Program.cs

@ -20,9 +20,7 @@ namespace EventHub.Web
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try

Loading…
Cancel
Save