Browse Source

添加Github Actions

 修复前端首次启动报错问题
 阻止跨站点请求伪造
pull/27/head 5.0.0.4
王军 4 years ago
parent
commit
ed4c17a208
  1. 20
      .github/workflows/dotnet-unit-test.yml
  2. 58
      .github/workflows/dotnet.yml
  3. 26
      .github/workflows/vben2.7.yml
  4. 48
      aspnet-core/gateways/Lion.AbpPro.WebGateway/appsettings.Consul.json
  5. 24
      aspnet-core/gateways/Lion.AbpPro.WebGateway/appsettings.Production.json
  6. 2
      aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/Notifications/DistributedEventHandlers/NotificationCreatedDistributedEventHandler.cs
  7. 20
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json
  8. 2
      aspnet-core/services/host/Lion.AbpPro.IdentityServer/appsettings.Development.json
  9. 13
      aspnet-core/services/host/Lion.AbpPro.IdentityServer/appsettings.Production.json
  10. 6
      aspnet-core/services/host/Lion.AbpPro.IdentityServer/appsettings.json
  11. 7
      aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Permissions/AbpProPermissions.cs
  12. 2
      aspnet-core/services/src/Lion.AbpPro.Domain/Settings/AbpProSettingDefinitionProvider.cs
  13. 14
      aspnet-core/shared/Lion.AbpPro.Shared.Hosting.Microservices/SharedHostingMicroserviceModule.cs
  14. 63
      docker-compose.yaml
  15. 7
      vben271/.env.production
  16. 936
      vben271/package-lock.json
  17. 2
      vben271/package.json
  18. 3
      vben271/src/router/guard/permissionGuard.ts

20
.github/workflows/dotnet-unit-test.yml

@ -0,0 +1,20 @@
name: Unit Test
on:
push:
branches:
- main
jobs:
AbpVnextPrc-CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Dotnet 6.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0"
include-prerelease: True
- name: Build
run: dotnet build aspnet-core/Lion.AbpPro.sln
- name: Test
run: dotnet test aspnet-core/services/test/Lion.AbpPro.Domain.Tests/Lion.AbpPro.Domain.Tests.csproj

58
.github/workflows/dotnet.yml

@ -1,17 +1,11 @@
name: CI
# on:
# push:
# tags:
# - "*"
name: Build-Dokcer
on:
push:
branches:
- main
tags:
- "*"
jobs:
AbpVnextPrc-CI:
Push-DockerHub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -20,13 +14,39 @@ jobs:
with:
dotnet-version: "6.0"
include-prerelease: True
- name: Build
- name: 设置标签
id: vars
run: echo ::set-output name=tag::${GITHUB_REF:10}
- name: 编译
run: dotnet build aspnet-core/Lion.AbpPro.sln
- name: Test
run: dotnet test aspnet-core/services/test/Lion.AbpPro.Domain.Tests/Lion.AbpPro.Domain.Tests.csproj
#- name: Restore dependencies
# run: dotnet restore
#- name: Build
# run: dotnet build --no-restore
# https://blog-resouce.oss-cn-shenzhen.aliyuncs.com/images/lion.png
- name: 发布HostApi
run: cd aspnet-core/services/host/Lion.AbpPro.HttpApi.Host &&
dotnet publish -c release -o publish &&
docker build -t abp-vnext-pro-api:${{ steps.vars.outputs.tag }} .
- name: 发布IdentityServer4
run: cd aspnet-core/services/host/Lion.AbpPro.IdentityServer &&
dotnet publish -c release -o publish &&
docker build -t abp-vnext-pro-id4:${{ steps.vars.outputs.tag }} .
- name: 发布WebGateway
run: cd aspnet-core/gateways/Lion.AbpPro.WebGateway &&
dotnet publish -c release -o publish &&
docker build -t abp-vnext-pro-web-gateway:${{ steps.vars.outputs.tag }} .
- name: 登录Docker
run: docker login -u zzzwangjun -p ${{secrets.dockerHubPassword}}
- name: HostApi镜像推送到DockerHub
run: docker tag abp-vnext-pro-api:${{ steps.vars.outputs.tag }} zzzwangjun/abp-vnext-pro-api:${{ steps.vars.outputs.tag }} &&
docker push zzzwangjun/abp-vnext-pro-api:${{ steps.vars.outputs.tag }}
- name: IdentityServer4镜像推送到DockerHub
run: docker tag abp-vnext-pro-id4:${{ steps.vars.outputs.tag }} zzzwangjun/abp-vnext-pro-id4:${{ steps.vars.outputs.tag }} &&
docker push zzzwangjun/abp-vnext-pro-id4:${{ steps.vars.outputs.tag }}
- name: WebGateway镜像推送到DockerHub
run: docker tag abp-vnext-pro-web-gateway:${{ steps.vars.outputs.tag }} zzzwangjun/abp-vnext-pro-web-gateway:${{ steps.vars.outputs.tag }} &&
docker push zzzwangjun/abp-vnext-pro-web-gateway:${{ steps.vars.outputs.tag }}

26
.github/workflows/vben2.7.yml

@ -0,0 +1,26 @@
name: Vben2.7
on:
push:
tags:
- "*"
jobs:
Push-DockerHub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Set Tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF:10}
- name: Build And Push Docker Hub
run: cd vben271 &&
npm install &&
npm run build &&
docker login -u zzzwangjun -p ${{secrets.dockerHubPassword}} &&
docker build -t abp-vnext-pro-ui:${{ steps.vars.outputs.tag }} . &&
docker tag abp-vnext-pro-ui:${{ steps.vars.outputs.tag }} zzzwangjun/abp-vnext-pro-ui:${{ steps.vars.outputs.tag }} &&
docker push zzzwangjun/abp-vnext-pro-ui:${{ steps.vars.outputs.tag }}

48
aspnet-core/gateways/Lion.AbpPro.WebGateway/appsettings.Consul.json

@ -1,48 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"App": {
"SelfUrl": "http://localhost:44314",
"CorsOrigins": "http://localhost:4200"
},
"GlobalConfiguration": {
},
"Routes": [
{
"DownstreamPathTemplate": "/{url}",
"DownstreamScheme": "http",
"ServiceName": "Project-Service",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"UpstreamPathTemplate": "/gateway/{url}",
"UpstreamHttpMethod": [
"Get",
"Post",
"Put",
"Delete"
]
},
{
"DownstreamPathTemplate": "/{url}",
"DownstreamScheme": "ws",
"ServiceName": "Project-Service",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"UpstreamPathTemplate": "/ws/{url}",
"UpstreamHttpMethod": [
"Get",
"Post",
"Put",
"Delete"
]
}
]
}

24
aspnet-core/gateways/Lion.AbpPro.WebGateway/appsettings.Production.json

@ -8,8 +8,8 @@
},
"AllowedHosts": "*",
"App": {
"SelfUrl": "http://localhost:44314",
"CorsOrigins": "http://localhost:4200"
"SelfUrl": "http://120.24.194.14:8014",
"CorsOrigins": "http://localhost:4200,http://120.24.194.14:8012,http://120.24.194.14:8011,http://120.24.194.14:8013"
},
"GlobalConfiguration": {
},
@ -17,12 +17,10 @@
{
"DownstreamPathTemplate": "/{url}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44315
}
],
"ServiceName": "AbpPro-Service",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"UpstreamPathTemplate": "/gateway/{url}",
"UpstreamHttpMethod": [
"Get",
@ -34,12 +32,10 @@
{
"DownstreamPathTemplate": "/{url}",
"DownstreamScheme": "ws",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44315
}
],
"ServiceName": "AbpPro-Service",
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"UpstreamPathTemplate": "/ws/{url}",
"UpstreamHttpMethod": [
"Get",

2
aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/Notifications/DistributedEventHandlers/NotificationCreatedDistributedEventHandler.cs

@ -20,7 +20,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications.DistributedEventHandl
_hubAppService = hubAppService;
}
public Task HandleEventAsync(CreatedNotificationDistributedEvent eventData)
public virtual Task HandleEventAsync(CreatedNotificationDistributedEvent eventData)
{
return _hubAppService.SendMessageAsync(
eventData.NotificationEto.Title,

20
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Consul.json → aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json

@ -12,14 +12,14 @@
}
},
"App": {
"SelfUrl": "http://localhost:44315",
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,http://localhost:3100"
"SelfUrl": "http://120.24.194.14:8011",
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,http://localhost:3100,http://120.24.194.14:8012,http://120.24.194.14:8011,http://120.24.194.14:8013"
},
"ConnectionStrings": {
"Default": "Data Source=localhost;Database=LionAbpProDB20211106;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
"Default": "Data Source=mysql;Database=LionAbpProDB20211106;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
},
"Redis": {
"Configuration": "localhost,password=mypassword,defaultdatabase=1"
"Configuration": "redis,password=1q2w3E*,defaultdatabase=1"
},
"Jwt": {
"Audience": "LionAbpPro",
@ -31,11 +31,11 @@
// hour
},
"Cap": {
"Enabled": "false",
"Enabled": "true",
"RabbitMq": {
"HostName": "localhost",
"HostName": "rabbitMq",
"UserName": "admin",
"Password": "admin"
"Password": "1q2w3E*"
}
},
"LogToElasticSearch": {
@ -50,12 +50,12 @@
},
"HttpClient": {
"Sts": {
"Url": "http://localhost:44354"
"Url": "http://120.24.194.14:8013"
}
},
"Consul": {
"Enabled": true,
"Host": "http://localhost:8500",
"Service": "Project-Service"
"Host": "http://consul:8500",
"Service": "AbpPro-Service"
}
}

2
aspnet-core/services/host/Lion.AbpPro.IdentityServer/appsettings.Development.json

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

13
aspnet-core/services/host/Lion.AbpPro.IdentityServer/appsettings.Production.json

@ -0,0 +1,13 @@
{
"App": {
"SelfUrl": "http://120.24.194.14:8013",
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,https://localhost:44307,https://localhost:44315,http://120.24.194.14:8012,http://120.24.194.14:8011,http://120.24.194.14:8013"
},
"ConnectionStrings": {
"Default": "Data Source=mysql;Database=LionAbpProDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
},
"Redis": {
"Configuration": "redis,password=1q2w3E*,defaultdatabase=1"
}
}

6
aspnet-core/services/host/Lion.AbpPro.IdentityServer/appsettings.json

@ -1,9 +1,7 @@
{
"App": {
"SelfUrl": "https://localhost:44354",
"ClientUrl": "http://localhost:4200",
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,https://localhost:44307,https://localhost:44315",
"RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307"
"SelfUrl": "http://localhost:44354",
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,https://localhost:44307,https://localhost:44315"
},
"ConnectionStrings": {
"Default": "Data Source=localhost;Database=LionAbpProDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"

7
aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Permissions/AbpProPermissions.cs

@ -4,13 +4,6 @@ namespace Lion.AbpPro.Permissions
{
public static class AbpProPermissions
{
public const string GroupName = "AbpPro";
public const string AbpIdentityGroupName = "AbpIdentity";
//Add your own permission names. Example:
//public const string MyPermission1 = GroupName + ".MyPermission1";
/// <summary>
/// 系统管理扩展权限
/// </summary>

2
aspnet-core/services/src/Lion.AbpPro.Domain/Settings/AbpProSettingDefinitionProvider.cs

@ -28,7 +28,7 @@ namespace Lion.AbpPro.Settings
.WithProperty(AbpProSettings.Group.Defalut,
AbpProSettings.Group.SystemManagement)
.WithProperty(AbpProSettings.ControlType.Defalut,
AbpProSettings.ControlType.TypeCheckBox);
AbpProSettings.ControlType.TypeText);
context.GetOrNull("Abp.Identity.Password.RequiredUniqueChars")
.WithProperty(AbpProSettings.Group.Defalut,

14
aspnet-core/shared/Lion.AbpPro.Shared.Hosting.Microservices/SharedHostingMicroserviceModule.cs

@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.Autofac;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
@ -31,10 +32,21 @@ namespace Lion.AbpPro
ConfigureUrls(configuration);
ConfigureAbpExceptions(context);
ConfigureConsul(context, configuration);
ConfigAntiForgery();
}
/// <summary>
/// 阻止跨站点请求伪造
/// https://docs.microsoft.com/zh-cn/aspnet/core/security/anti-request-forgery?view=aspnetcore-6.0
/// </summary>
private void ConfigAntiForgery()
{
Configure<AbpAntiForgeryOptions>(options =>
{
options.AutoValidate = false;
});
}
private void ConfigureConsul(ServiceConfigurationContext context,
IConfiguration configuration)
{

63
docker-compose.yaml

@ -0,0 +1,63 @@
version: '3'
services:
mysql:
image: mysql:5.7.26
# network_mode: "host" # 如果需要容器使用宿主机IP(内网IP),则可以配置此项
container_name: abp-pro-mysql # 指定容器名称,如果不设置此参数,则由系统自动生成
restart: always # 设置容器自启模式
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci # 设置utf8字符集
environment:
- TZ=Asia/Shanghai # 设置容器时区与宿主机保持一致
- MYSQL_ROOT_PASSWORD=1q2w3E* # 设置root密码
volumes:
- /etc/localtime:/etc/localtime:ro # 设置容器时区与宿主机保持一致
ports:
- "3307:3306"
networks:
- lionAbpPro
redis:
image: redis:5.0.4
container_name: abp-pro-redis
restart: always
command: redis-server # 启动redis命令
environment:
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro # 设置容器时区与宿主机保持一致
ports:
- "6380:6379"
networks:
- lionAbpPro
rabbitMq:
image: rabbitmq:management
container_name: abp-pro-rabbitMq
restart: always
ports:
- "5673:5672"
- "15673:15672"
environment:
- RABBITMQ_DEFAULT_USER=admin
- RABBITMQ_DEFAULT_PASS=1q2w3E*
networks:
- lionAbpPro
consul:
image: consul
ports:
- 8300:8300
- 8301:8301
- 8301:8301/udp
- 8302:8302
- 8302:8302/udp
- 8400:8400
- 8500:8500
- 53:53/udp
command: agent -server -bind=0.0.0.0 -client=0.0.0.0 -node=consul_Server1 -bootstrap-expect=1 -ui
networks:
- lionAbpPro
networks:
lionAbpPro:
driver: bridge

7
vben271/.env.production

@ -36,11 +36,12 @@ VITE_LEGACY = false
# 认证授权服务器地址
VITE_AUTH_URL= http://localhost:44354
VITE_AUTH_URL= http://120.24.194.14:8013
# 接口地址
VITE_API_URL= http://localhost:44314/gateway
VITE_API_URL= http://120.24.194.14:8014/gateway
# WEBSOCKE 地址
VITE_WEBSOCKE_URL= http://localhost:44314/ws
VITE_WEBSOCKE_URL= http://120.24.194.14:8014/ws

936
vben271/package-lock.json

File diff suppressed because it is too large

2
vben271/package.json

@ -149,4 +149,4 @@
"engines": {
"node": "^12 || >=14"
}
}
}

3
vben271/src/router/guard/permissionGuard.ts

@ -50,7 +50,8 @@ export function createPermissionGuard(router: Router) {
return;
}
} else {
router.replace(PageEnum.BASE_LOGIN);
next({path:PageEnum.BASE_LOGIN})
//router.replace(PageEnum.BASE_LOGIN);
return;
}

Loading…
Cancel
Save