Browse Source

FIS1.5第一次提交

master
liuyunfeng 1 year ago
commit
8621f20ace
  1. 86
      .drone.yml
  2. 3
      .gitattributes
  3. 32
      .gitignore
  4. 38
      README.md
  5. 1
      build/.gitignore
  6. 8
      build/be-build.sh
  7. 1
      build/fe-build.sh
  8. 361
      src/AuthServer/.gitignore
  9. 32
      src/AuthServer/AuthServer.Host/AuthServer.Host.csproj
  10. 25
      src/AuthServer/AuthServer.Host/AuthServer.Host.sln
  11. 255
      src/AuthServer/AuthServer.Host/AuthServerDataSeeder.cs
  12. 125
      src/AuthServer/AuthServer.Host/AuthServerHostModule.cs
  13. 12
      src/AuthServer/AuthServer.Host/Dockerfile
  14. 22
      src/AuthServer/AuthServer.Host/EntityFrameworkCore/AuthServerDbContext.cs
  15. 29
      src/AuthServer/AuthServer.Host/EntityFrameworkCore/AuthServerDbContextFactory.cs
  16. 846
      src/AuthServer/AuthServer.Host/Migrations/20200829070857_init.Designer.cs
  17. 520
      src/AuthServer/AuthServer.Host/Migrations/20200829070857_init.cs
  18. 846
      src/AuthServer/AuthServer.Host/Migrations/20201118072557_data1118.Designer.cs
  19. 17
      src/AuthServer/AuthServer.Host/Migrations/20201118072557_data1118.cs
  20. 846
      src/AuthServer/AuthServer.Host/Migrations/20201118083155_data.Designer.cs
  21. 17
      src/AuthServer/AuthServer.Host/Migrations/20201118083155_data.cs
  22. 1055
      src/AuthServer/AuthServer.Host/Migrations/20201210034748_update.Designer.cs
  23. 613
      src/AuthServer/AuthServer.Host/Migrations/20201210034748_update.cs
  24. 1053
      src/AuthServer/AuthServer.Host/Migrations/AuthServerDbContextModelSnapshot.cs
  25. 33
      src/AuthServer/AuthServer.Host/Pages/Index.cshtml
  26. 11
      src/AuthServer/AuthServer.Host/Pages/Index.cshtml.cs
  27. 4
      src/AuthServer/AuthServer.Host/Pages/_ViewImports.cshtml
  28. 63
      src/AuthServer/AuthServer.Host/Program.cs
  29. 26
      src/AuthServer/AuthServer.Host/Properties/launchSettings.json
  30. 20
      src/AuthServer/AuthServer.Host/Startup.cs
  31. 9
      src/AuthServer/AuthServer.Host/appsettings.Development.json
  32. 20
      src/AuthServer/AuthServer.Host/appsettings.json
  33. 9
      src/AuthServer/AuthServer.Host/gulpfile.js
  34. 5
      src/AuthServer/AuthServer.Host/libman.json
  35. 3453
      src/AuthServer/AuthServer.Host/package-lock.json
  36. 8
      src/AuthServer/AuthServer.Host/package.json
  37. 1
      src/AuthServer/AuthServer.Host/tempkey.jwk
  38. 1
      src/AuthServer/AuthServer.Host/tempkey.rsa
  39. BIN
      src/AuthServer/AuthServer.Host/wwwroot/images/anonymous-user.png
  40. 2596
      src/AuthServer/AuthServer.Host/yarn.lock
  41. 25
      src/AuthServer/AuthServer.sln
  42. 2
      src/AuthServer/README.md
  43. 360
      src/Gateways/.gitignore
  44. 26
      src/Gateways/InternalGateway/InternalGateway.Host/InternalGateway.Host.csproj
  45. 143
      src/Gateways/InternalGateway/InternalGateway.Host/InternalGatewayHostModule.cs
  46. 66
      src/Gateways/InternalGateway/InternalGateway.Host/Program.cs
  47. 27
      src/Gateways/InternalGateway/InternalGateway.Host/Properties/launchSettings.json
  48. 19
      src/Gateways/InternalGateway/InternalGateway.Host/Startup.cs
  49. 9
      src/Gateways/InternalGateway/InternalGateway.Host/appsettings.Development.json
  50. 39
      src/Gateways/InternalGateway/InternalGateway.Host/appsettings.json
  51. 25
      src/Gateways/InternalGateway/InternalGateway.sln
  52. 3
      src/Gateways/README.md
  53. 12
      src/Gateways/WebAppGateway/WebAppGateway.Host/Dockerfile
  54. 66
      src/Gateways/WebAppGateway/WebAppGateway.Host/Program.cs
  55. 27
      src/Gateways/WebAppGateway/WebAppGateway.Host/Properties/launchSettings.json
  56. 20
      src/Gateways/WebAppGateway/WebAppGateway.Host/Startup.cs
  57. 35
      src/Gateways/WebAppGateway/WebAppGateway.Host/WebAppGateway.Host.csproj
  58. 155
      src/Gateways/WebAppGateway/WebAppGateway.Host/WebAppGatewayHostModule.cs
  59. 9
      src/Gateways/WebAppGateway/WebAppGateway.Host/appsettings.Development.json
  60. 122
      src/Gateways/WebAppGateway/WebAppGateway.Host/appsettings.json
  61. 25
      src/Gateways/WebAppGateway/WebAppGateway.sln
  62. 360
      src/Modules/BaseService/.gitignore
  63. 53
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/Dto/BranchDto.cs
  64. 35
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/Dto/CreateOrUpdateBranchDto.cs
  65. 16
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/Dto/GetBranchInputDto.cs
  66. 32
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/IBranchAppService.cs
  67. 17
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/Permissions/Dto/ApplicationAuthes.cs
  68. 30
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/Dto/CreateOrUpdateUserBranchDto.cs
  69. 12
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/Dto/GetUserBranchInput.cs
  70. 38
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/Dto/UserBranchDto.cs
  71. 48
      src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/IUserBranchAppService.cs
  72. 20
      src/Modules/BaseService/BaseService.Application.Contracts/BaseService.Application.Contracts.csproj
  73. 329
      src/Modules/BaseService/BaseService.Application.Contracts/BaseService.Application.Contracts.xml
  74. 15
      src/Modules/BaseService/BaseService.Application.Contracts/BaseServiceApplicationContractsModule.cs
  75. 35
      src/Modules/BaseService/BaseService.Application.Contracts/Permissions/BaseServicePermissionDefinitionProvider .cs
  76. 34
      src/Modules/BaseService/BaseService.Application.Contracts/Permissions/BaseServicePermissions.cs
  77. 28
      src/Modules/BaseService/BaseService.Application.Contracts/RelationData/Dto/BranchPermissionDto.cs
  78. 30
      src/Modules/BaseService/BaseService.Application.Contracts/RelationData/Dto/BranchRoleDto.cs
  79. 67
      src/Modules/BaseService/BaseService.Application.Contracts/RelationData/IBranchRelationAppService.cs
  80. 25
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/AuditLogActionDto.cs
  81. 53
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/AuditLogDto.cs
  82. 29
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/EntityChangeDto.cs
  83. 20
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/EntityPropertyChangeDto.cs
  84. 28
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/GetAuditLogsInput.cs
  85. 11
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/GetAverageExecutionDurationPerDayInput.cs
  86. 10
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/GetAverageExecutionDurationPerDayOutput.cs
  87. 19
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/IAuditLoggingAppService.cs
  88. 75
      src/Modules/BaseService/BaseService.Application.Contracts/Systems/UserManagement/IUserAppService.cs
  89. 23
      src/Modules/BaseService/BaseService.Application/BaseService.Application.csproj
  90. 29
      src/Modules/BaseService/BaseService.Application/BaseServiceApplicationAutoMapperProfile.cs
  91. 33
      src/Modules/BaseService/BaseService.Application/BaseServiceApplicationModule.cs
  92. 314
      src/Modules/BaseService/BaseService.Application/BranchManagement/BranchAppService.cs
  93. 413
      src/Modules/BaseService/BaseService.Application/UserManagement/UserAppService.cs
  94. 503
      src/Modules/BaseService/BaseService.Application/UserManagement/UserBranchAppService.cs
  95. 14
      src/Modules/BaseService/BaseService.Domain/BaseData/AppIdentityRole.cs
  96. 152
      src/Modules/BaseService/BaseService.Domain/BaseData/Branch.cs
  97. 90
      src/Modules/BaseService/BaseService.Domain/BaseData/UserBranch.cs
  98. 41
      src/Modules/BaseService/BaseService.Domain/BaseData/UserBranchRole.cs
  99. 35
      src/Modules/BaseService/BaseService.Domain/BaseService.Domain.csproj
  100. 15
      src/Modules/BaseService/BaseService.Domain/BaseServiceConsts.cs

86
.drone.yml

@ -0,0 +1,86 @@
---
kind: pipeline
type: docker
name: 长春派格FIS项目
platform:
arch: amd64
os: linux
steps:
- name: 分析
image: aosapps/drone-sonar-plugin
settings:
sonar_host: http://dev.ccwin-in.com:3005
sonar_token: sqa_a1da3cf5984f39d9a256493acbae857c6624e954
- name: 后端构建
image: mcr.microsoft.com/dotnet/sdk:6.0
privileged: true
commands:
- cd ./build
- chmod 755 ./be-build.sh
- ./be-build.sh
- 'git --no-pager log --date=format:"%Y-%m-%d %H:%M:%S" --pretty=format:"%h - %ad %cn: %s %b" --invert-grep --grep="CI SKIP" --grep="drone" >./publish/log.txt'
- echo "${DRONE_BUILD_NUMBER}-${DRONE_COMMIT_AUTHOR}-${DRONE_REPO_BRANCH}-${DRONE_COMMIT_SHA:0:8}\n">./publish/version.txt
- echo ${DRONE_COMMIT_MESSAGE}>>./publish/version.txt
# - name: 前端构建
# image: node:14.21.3
# privileged: true
# commands:
# - cd ./build
# - chmod 755 ./fe-build.sh
# - ./fe-build.sh
- name: 发布到MinIO
image: plugins/s3
settings:
endpoint: http://dev.ccwin-in.com:3008
path_style: true
bucket: default
access_key: O222sbIaMKeGfeX18t8K
secret_key: 0LEOWfXSDnaLbIYGZfdKUxyi2kYIayx4YvdLTgcR
source: build/publish/**/*
strip_prefix: build/publish/
target: /fis/cc-pai-ge/${DRONE_BUILD_NUMBER}-${DRONE_COMMIT_AUTHOR}-${DRONE_REPO_BRANCH}-${DRONE_COMMIT_SHA:0:8}
- name: 停止测试服务器服务
image: appleboy/drone-ssh
settings:
host: dev.ccwin-in.com
port: 16085
username: Administrator
password: Microsoft@2022
command_timeout: 10m
script:
- mkdir -p /d/publish/fis/cc-pai-ge/web
- cd /d/publish/fis/cc-pai-ge/web
- ./stop.cmd
- sleep 3
- cd ../..
- rm -rf /d/publish/fis/cc-pai-ge
- mkdir -p /d/publish/fis/cc-pai-ge
- name: 部署到测试服务器
image: cschlosser/drone-ftps
environment:
PLUGIN_HOSTNAME: dev.ccwin-in.com:16022
FTP_USERNAME: Administrator
FTP_PASSWORD: Microsoft@2022
PLUGIN_SRC_DIR: /build/publish
PLUGIN_DEST_DIR: /fis/cc-pai-ge
PLUGIN_SECURE: false
PLUGIN_CHMOD: false
- name: 启动测试服务器服务
image: appleboy/drone-ssh
settings:
host: dev.ccwin-in.com
port: 16085
username: Administrator
password: Microsoft@2022
command_timeout: 10m
script:
- cd /d/publish/fis/cc-pai-ge/web
- ./start.cmd

3
.gitattributes

@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf

32
.gitignore

@ -0,0 +1,32 @@
################################################################################
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
################################################################################
/src/Shared/Win.Abp.Snowflakes/bin/Debug/netcoreapp5/Win.Abp.Snowflakes.deps.json
/src/Shared
/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Logs/log-20210906.txt
/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Logs
/.vs
/src/.vs
/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Logs
/src/Modules/派格FIS/src/WY.NewJit.Application/obj
/src/Modules/派格FIS/src/WY.NewJit.Application.Contracts/obj
/src/Modules/派格FIS/src/WY.NewJit.DbMigrator/obj
/src/Modules/派格FIS
/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Web/JIS_BAK
/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Web/JIS_WORK
/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Web/JIS_RECEIVE
/src/Modules/新版JIT或JIS系统服务端/OutPut
/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.xml
/src/Modules/新版JIT或JIS系统服务端/OutPut
OutPut
/src/Modules/新版JIT或JIS系统服务端/OutPut/net5.0/WY.NewJit.Application.Contracts.dll
/src/Modules/新版JIT或JIS系统服务端/OutPut/net5.0/WY.NewJit.Application.dll
/src/Modules/新版JIT或JIS系统服务端/OutPut/net5.0/WY.NewJit.Domain.Shared.dll
/src/Modules/新版JIT或JIS系统服务端/OutPut/net5.0/WY.NewJit.Domain.dll
/src/Modules/新版JIT或JIS系统服务端/OutPut/net5.0/WY.NewJit.EntityFrameworkCore.dll
/src/Modules/新版JIT或JIS系统服务端/OutPut/netstandard2.0/WY.NewJit.Application.Contracts.dll
/src/Modules/新版JIT或JIS系统服务端/OutPut/netstandard2.0/WY.NewJit.Domain.Shared.dll
debug.log

38
README.md

@ -0,0 +1,38 @@
# 长春派格FIS项目
## 提交规范
默认进行自动构建、发布到MinIO并自动部署到测试服务器
1. 提交前确保先拉取更新
1. 提交时确保编译通过,提交后检查CI服务器编译是否成功
1. 不需要自动构建和部署的,在提交信息中添加 `[CI SKIP]`
1. 针对特定问题的解决,提交信息中添加问题编号
## 开发环境配置
### 配置文件
在项目 SettleAccount.HttpApi.Host 下添加开发配置文件 appsettings.development.json
```json
```
### 数据库
本地安装 SQL Server 2016 + ,在程序包管理器控制台中切换项目并设置为启动项目后执行 EF Core 数据迁移命令
```sh
#WY.NewJit.EntityFrameworkCore.DbMigrations
update-database -context NewJitMigrationsDbContext -connection "Server=.;Database=NewJit;uid=sa;pwd=aA123456!"
```
### 启动调试
入口项目:WY.NewJit.Web
## 部署
1. 部署到测试服务器时正常提交,appsettings.json 中默认为测试服务器配置,本地使用 appsettings.development.json 进行配置
1. 部署到生产正常提交,生产环境使用 appsettings.production.json 进行配置

1
build/.gitignore

@ -0,0 +1 @@
publish

8
build/be-build.sh

@ -0,0 +1,8 @@
rm -rf ./publish
dotnet publish -v normal -c Release -r win-x64 ../src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Web -o ./publish/web
dotnet publish -v normal -c Release -r win-x64 ../src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp -o ./publish/console/ConsoleApp
dotnet publish -v normal -c Release -r win-x64 ../src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleBatchImportBrokenNum -o ./publish/console/ConsoleBatchImportBrokenNum
dotnet publish -v normal -c Release -r win-x64 ../src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.BomInterface/WY.NewJit.Job.ConsoleBomInterface.csproj -o ./publish/console/ConsoleBomInterface
dotnet publish -v normal -c Release -r win-x64 ../src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleGetEDIFile -o ./publish/console/ConsoleGetEDIFile
dotnet publish -v normal -c Release -r win-x64 ../src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleSyncToWms -o ./publish/console/ConsoleMesSync
dotnet publish -v normal -c Release -r win-x64 ../src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleMoveFile -o ./publish/console/ConsoleMoveFile

1
build/fe-build.sh

@ -0,0 +1 @@
cd ../vue&&npm config set registry https://registry.npm.taobao.org&&npm install --registry=https://registry.npm.taobao.org&&npm run build:prod&&mv ./dist/** ../build/publish/web/wwwroot/

361
src/AuthServer/.gitignore

@ -0,0 +1,361 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
/AuthServer.Host/wwwroot/libs

32
src/AuthServer/AuthServer.Host/AuthServer.Host.csproj

@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Volo.Abp.Account.Application" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="4.0.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="4.0.0" />
<PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.0.0" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="4.0.0" />
<PackageReference Include="Volo.Abp.IdentityServer.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="4.0.0" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

25
src/AuthServer/AuthServer.Host/AuthServer.Host.sln

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29326.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthServer.Host", "AuthServer.Host.csproj", "{21789B5F-E84A-407E-8DAA-5F268E5F8647}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7585D0E2-0A6D-4F73-8EFF-433646754357}
EndGlobalSection
EndGlobal

255
src/AuthServer/AuthServer.Host/AuthServerDataSeeder.cs

@ -0,0 +1,255 @@
using IdentityServer4.Models;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow;
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope;
using Client = Volo.Abp.IdentityServer.Clients.Client;
namespace AuthServer.Host
{
public class AuthServerDataSeeder : IDataSeedContributor, ITransientDependency
{
private readonly IApiResourceRepository _apiResourceRepository;
private readonly IApiScopeRepository _apiScopeRepository;
private readonly IClientRepository _clientRepository;
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder;
private readonly IGuidGenerator _guidGenerator;
private readonly IPermissionDataSeeder _permissionDataSeeder;
public AuthServerDataSeeder(
IClientRepository clientRepository,
IApiResourceRepository apiResourceRepository,
IApiScopeRepository apiScopeRepository,
IIdentityResourceDataSeeder identityResourceDataSeeder,
IGuidGenerator guidGenerator,
IPermissionDataSeeder permissionDataSeeder)
{
_clientRepository = clientRepository;
_apiResourceRepository = apiResourceRepository;
_apiScopeRepository = apiScopeRepository;
_identityResourceDataSeeder = identityResourceDataSeeder;
_guidGenerator = guidGenerator;
_permissionDataSeeder = permissionDataSeeder;
}
[UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context)
{
await _identityResourceDataSeeder.CreateStandardResourcesAsync();
await CreateApiResourcesAsync();
await CreateApiScopesAsync();
await CreateClientsAsync();
}
private async Task CreateApiScopesAsync()
{
await CreateApiScopeAsync("BaseService");
await CreateApiScopeAsync("InternalGateway");
await CreateApiScopeAsync("WebAppGateway");
await CreateApiScopeAsync("TenantService");
await CreateApiScopeAsync("BusinessService");
await CreateApiScopeAsync("FileStorageService");
await CreateApiScopeAsync("IdentityService");
await CreateApiScopeAsync("SettleAccount");
}
private async Task CreateApiResourcesAsync()
{
var commonApiUserClaims = new[]
{
"email",
"email_verified",
"name",
"user_name",
"phone_number",
"phone_number_verified",
"role"
};
await CreateApiResourceAsync("IdentityService", commonApiUserClaims);
await CreateApiResourceAsync("BaseService", commonApiUserClaims);
await CreateApiResourceAsync("InternalGateway", commonApiUserClaims);
await CreateApiResourceAsync("WebAppGateway", commonApiUserClaims);
await CreateApiResourceAsync("TenantService", commonApiUserClaims);
await CreateApiResourceAsync("BusinessService", commonApiUserClaims);
await CreateApiResourceAsync("FileStorageService", commonApiUserClaims);
await CreateApiResourceAsync("SettleAccount", commonApiUserClaims);
}
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims)
{
var apiResource = await _apiResourceRepository.FindByNameAsync(name);
if (apiResource == null)
{
apiResource = await _apiResourceRepository.InsertAsync(
new ApiResource(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
}
foreach (var claim in claims)
{
if (apiResource.FindClaim(claim) == null)
{
apiResource.AddUserClaim(claim);
}
}
return await _apiResourceRepository.UpdateAsync(apiResource);
}
private async Task<ApiScope> CreateApiScopeAsync(string name)
{
var apiScope = await _apiScopeRepository.GetByNameAsync(name);
if (apiScope == null)
{
apiScope = await _apiScopeRepository.InsertAsync(
new ApiScope(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
}
return apiScope;
}
private async Task CreateClientsAsync()
{
var commonScopes = new[]
{
"email",
"username",
"name",
"openid",
"profile",
"role",
"phone",
"address"
};
await CreateClientAsync(
"basic-web",
new[] { "IdentityService", "BaseService", "WebAppGateway", "FileStorageService", "TenantService", "BusinessService", "SettleAccount" },
new[] { "password" },
"1q2w3e*".Sha256()
);
//BaseDataService
await CreateClientAsync(
"business-app",
new[] { "InternalGateway", "IdentityService", "BaseService", "FileStorageService", "SettleAccount" },
new[] { "client_credentials" },
"1q2w3e*".Sha256(),
permissions: new[] { IdentityPermissions.Users.Default }
);
//FileStorge
await CreateClientAsync(
"file-app",
new[] { "InternalGateway", "IdentityService", "BaseService", "BaseDataService", "BusinessService" },
new[] { "client_credentials" },
"1q2w3e*".Sha256(),
permissions: new[] { IdentityPermissions.Users.Default }
);
}
private async Task<Client> CreateClientAsync(
string name,
IEnumerable<string> scopes,
IEnumerable<string> grantTypes,
string secret,
string redirectUri = null,
string postLogoutRedirectUri = null,
IEnumerable<string> permissions = null)
{
var client = await _clientRepository.FindByClientIdAsync(name);
if (client == null)
{
client = await _clientRepository.InsertAsync(
new Client(
_guidGenerator.Create(),
name
)
{
ClientName = name,
ProtocolType = "oidc",
Description = name,
AlwaysIncludeUserClaimsInIdToken = true,
AllowOfflineAccess = true,
AbsoluteRefreshTokenLifetime = 31536000, //365 days
AccessTokenLifetime = 31536000, //365 days
AuthorizationCodeLifetime = 300,
IdentityTokenLifetime = 300,
RequireConsent = false
},
autoSave: true
);
}
foreach (var scope in scopes)
{
if (client.FindScope(scope) == null)
{
client.AddScope(scope);
}
}
foreach (var grantType in grantTypes)
{
if (client.FindGrantType(grantType) == null)
{
client.AddGrantType(grantType);
}
}
if (client.FindSecret(secret) == null)
{
client.AddSecret(secret);
}
if (redirectUri != null)
{
if (client.FindRedirectUri(redirectUri) == null)
{
client.AddRedirectUri(redirectUri);
}
}
if (postLogoutRedirectUri != null)
{
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null)
{
client.AddPostLogoutRedirectUri(postLogoutRedirectUri);
}
}
if (permissions != null)
{
await _permissionDataSeeder.SeedAsync(
ClientPermissionValueProvider.ProviderName,
name,
permissions
);
}
return await _clientRepository.UpdateAsync(client);
}
}
}

125
src/AuthServer/AuthServer.Host/AuthServerHostModule.cs

@ -0,0 +1,125 @@
using AuthServer.Host.EntityFrameworkCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
using System;
using System.Linq;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.Auditing;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
namespace AuthServer.Host
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule)
)]
public class AuthServerHostModule : AbpModule
{
private const string DefaultCorsPolicyName = "Default";
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
context.Services.AddAbpDbContext<AuthServerDbContext>(options =>
{
options.AddDefaultRepositories();
});
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("en", "en", "English"));
});
context.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = configuration["Redis:Configuration"];
});
context.Services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName,
builder =>
{
builder.WithOrigins(configuration["CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray())
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
Configure<AbpAuditingOptions>(options =>
{
options.IsEnabledForGetRequests = true;
options.ApplicationName = "AuthServer";
});
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseMultiTenancy();
app.UseIdentityServer();
app.UseAuthorization();
app.UseAbpRequestLocalization();
app.UseAuditing();
AsyncHelper.RunSync(async () =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
}
});
}
}
}

12
src/AuthServer/AuthServer.Host/Dockerfile

@ -0,0 +1,12 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o publish
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build /src/publish ./
ENTRYPOINT ["dotnet", "AuthServer.Host.dll"]

22
src/AuthServer/AuthServer.Host/EntityFrameworkCore/AuthServerDbContext.cs

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
namespace AuthServer.Host.EntityFrameworkCore
{
public class AuthServerDbContext : AbpDbContext<AuthServerDbContext>
{
public AuthServerDbContext(DbContextOptions<AuthServerDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureIdentityServer();
}
}
}

29
src/AuthServer/AuthServer.Host/EntityFrameworkCore/AuthServerDbContextFactory.cs

@ -0,0 +1,29 @@
using System.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace AuthServer.Host.EntityFrameworkCore
{
public class AuthServerDbContextFactory : IDesignTimeDbContextFactory<AuthServerDbContext>
{
public AuthServerDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<AuthServerDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
return new AuthServerDbContext(builder.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
return builder.Build();
}
}
}

846
src/AuthServer/AuthServer.Host/Migrations/20200829070857_init.Designer.cs

@ -0,0 +1,846 @@
// <auto-generated />
using System;
using AuthServer.Host.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace AuthServer.Host.Migrations
{
[DbContext(typeof(AuthServerDbContext))]
[Migration("20200829070857_init")]
partial class init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "3.1.6")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Properties")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("IdentityServerApiResources");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ApiResourceId", "Type");
b.ToTable("IdentityServerApiClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("bit");
b.Property<bool>("Required")
.HasColumnType("bit");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("bit");
b.HasKey("ApiResourceId", "Name");
b.ToTable("IdentityServerApiScopes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ApiResourceId", "Name", "Type");
b.ToTable("IdentityServerApiScopeClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(4000)")
.HasMaxLength(4000);
b.Property<string>("Description")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.HasKey("ApiResourceId", "Type", "Value");
b.ToTable("IdentityServerApiSecrets");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("AbsoluteRefreshTokenLifetime")
.HasColumnType("int");
b.Property<int>("AccessTokenLifetime")
.HasColumnType("int");
b.Property<int>("AccessTokenType")
.HasColumnType("int");
b.Property<bool>("AllowAccessTokensViaBrowser")
.HasColumnType("bit");
b.Property<bool>("AllowOfflineAccess")
.HasColumnType("bit");
b.Property<bool>("AllowPlainTextPkce")
.HasColumnType("bit");
b.Property<bool>("AllowRememberConsent")
.HasColumnType("bit");
b.Property<bool>("AlwaysIncludeUserClaimsInIdToken")
.HasColumnType("bit");
b.Property<bool>("AlwaysSendClientClaims")
.HasColumnType("bit");
b.Property<int>("AuthorizationCodeLifetime")
.HasColumnType("int");
b.Property<bool>("BackChannelLogoutSessionRequired")
.HasColumnType("bit");
b.Property<string>("BackChannelLogoutUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("ClientClaimsPrefix")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<int?>("ConsentLifetime")
.HasColumnType("int");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<int>("DeviceCodeLifetime")
.HasColumnType("int");
b.Property<bool>("EnableLocalLogin")
.HasColumnType("bit");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("FrontChannelLogoutSessionRequired")
.HasColumnType("bit");
b.Property<string>("FrontChannelLogoutUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<int>("IdentityTokenLifetime")
.HasColumnType("int");
b.Property<bool>("IncludeJwtId")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("LogoUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("PairWiseSubjectSalt")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ProtocolType")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<int>("RefreshTokenExpiration")
.HasColumnType("int");
b.Property<int>("RefreshTokenUsage")
.HasColumnType("int");
b.Property<bool>("RequireClientSecret")
.HasColumnType("bit");
b.Property<bool>("RequireConsent")
.HasColumnType("bit");
b.Property<bool>("RequirePkce")
.HasColumnType("bit");
b.Property<int>("SlidingRefreshTokenLifetime")
.HasColumnType("int");
b.Property<bool>("UpdateAccessTokenClaimsOnRefresh")
.HasColumnType("bit");
b.Property<string>("UserCodeType")
.HasColumnType("nvarchar(100)")
.HasMaxLength(100);
b.Property<int?>("UserSsoLifetime")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("IdentityServerClients");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.HasKey("ClientId", "Type", "Value");
b.ToTable("IdentityServerClientClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Origin")
.HasColumnType("nvarchar(150)")
.HasMaxLength(150);
b.HasKey("ClientId", "Origin");
b.ToTable("IdentityServerClientCorsOrigins");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("GrantType")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.HasKey("ClientId", "GrantType");
b.ToTable("IdentityServerClientGrantTypes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Provider")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ClientId", "Provider");
b.ToTable("IdentityServerClientIdPRestrictions");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PostLogoutRedirectUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "PostLogoutRedirectUri");
b.ToTable("IdentityServerClientPostLogoutRedirectUris");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Key")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "Key");
b.ToTable("IdentityServerClientProperties");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("RedirectUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "RedirectUri");
b.ToTable("IdentityServerClientRedirectUris");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Scope")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ClientId", "Scope");
b.ToTable("IdentityServerClientScopes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(4000)")
.HasMaxLength(4000);
b.Property<string>("Description")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.HasKey("ClientId", "Type", "Value");
b.ToTable("IdentityServerClientSecrets");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Devices.DeviceFlowCodes", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasMaxLength(50000);
b.Property<string>("DeviceCode")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<DateTime?>("Expiration")
.IsRequired()
.HasColumnType("datetime2");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<string>("SubjectId")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("UserCode")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("DeviceCode")
.IsUnique();
b.HasIndex("Expiration");
b.HasIndex("UserCode")
.IsUnique();
b.ToTable("IdentityServerDeviceFlowCodes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b =>
{
b.Property<string>("Key")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasMaxLength(50000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("SubjectId")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(50)")
.HasMaxLength(50);
b.HasKey("Key");
b.HasIndex("Expiration");
b.HasIndex("SubjectId", "ClientId", "Type");
b.ToTable("IdentityServerPersistedGrants");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b =>
{
b.Property<Guid>("IdentityResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("IdentityResourceId", "Type");
b.ToTable("IdentityServerIdentityClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("bit");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Properties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Required")
.HasColumnType("bit");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("bit");
b.HasKey("Id");
b.ToTable("IdentityServerIdentityResources");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("Scopes")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiScope", null)
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId", "Name")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("Secrets")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("Claims")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedCorsOrigins")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedGrantTypes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("IdentityProviderRestrictions")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("PostLogoutRedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("Properties")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("RedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedScopes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("ClientSecrets")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", null)
.WithMany("UserClaims")
.HasForeignKey("IdentityResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

520
src/AuthServer/AuthServer.Host/Migrations/20200829070857_init.cs

@ -0,0 +1,520 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace AuthServer.Host.Migrations
{
public partial class init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "IdentityServerApiResources",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(nullable: true),
DeletionTime = table.Column<DateTime>(nullable: true),
Name = table.Column<string>(maxLength: 200, nullable: false),
DisplayName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
Enabled = table.Column<bool>(nullable: false),
Properties = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IdentityServerClients",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(nullable: true),
DeletionTime = table.Column<DateTime>(nullable: true),
ClientId = table.Column<string>(maxLength: 200, nullable: false),
ClientName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
ClientUri = table.Column<string>(maxLength: 2000, nullable: true),
LogoUri = table.Column<string>(maxLength: 2000, nullable: true),
Enabled = table.Column<bool>(nullable: false),
ProtocolType = table.Column<string>(maxLength: 200, nullable: false),
RequireClientSecret = table.Column<bool>(nullable: false),
RequireConsent = table.Column<bool>(nullable: false),
AllowRememberConsent = table.Column<bool>(nullable: false),
AlwaysIncludeUserClaimsInIdToken = table.Column<bool>(nullable: false),
RequirePkce = table.Column<bool>(nullable: false),
AllowPlainTextPkce = table.Column<bool>(nullable: false),
AllowAccessTokensViaBrowser = table.Column<bool>(nullable: false),
FrontChannelLogoutUri = table.Column<string>(maxLength: 2000, nullable: true),
FrontChannelLogoutSessionRequired = table.Column<bool>(nullable: false),
BackChannelLogoutUri = table.Column<string>(maxLength: 2000, nullable: true),
BackChannelLogoutSessionRequired = table.Column<bool>(nullable: false),
AllowOfflineAccess = table.Column<bool>(nullable: false),
IdentityTokenLifetime = table.Column<int>(nullable: false),
AccessTokenLifetime = table.Column<int>(nullable: false),
AuthorizationCodeLifetime = table.Column<int>(nullable: false),
ConsentLifetime = table.Column<int>(nullable: true),
AbsoluteRefreshTokenLifetime = table.Column<int>(nullable: false),
SlidingRefreshTokenLifetime = table.Column<int>(nullable: false),
RefreshTokenUsage = table.Column<int>(nullable: false),
UpdateAccessTokenClaimsOnRefresh = table.Column<bool>(nullable: false),
RefreshTokenExpiration = table.Column<int>(nullable: false),
AccessTokenType = table.Column<int>(nullable: false),
EnableLocalLogin = table.Column<bool>(nullable: false),
IncludeJwtId = table.Column<bool>(nullable: false),
AlwaysSendClientClaims = table.Column<bool>(nullable: false),
ClientClaimsPrefix = table.Column<string>(maxLength: 200, nullable: true),
PairWiseSubjectSalt = table.Column<string>(maxLength: 200, nullable: true),
UserSsoLifetime = table.Column<int>(nullable: true),
UserCodeType = table.Column<string>(maxLength: 100, nullable: true),
DeviceCodeLifetime = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IdentityServerDeviceFlowCodes",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
DeviceCode = table.Column<string>(maxLength: 200, nullable: false),
UserCode = table.Column<string>(maxLength: 200, nullable: false),
SubjectId = table.Column<string>(maxLength: 200, nullable: true),
ClientId = table.Column<string>(maxLength: 200, nullable: false),
Expiration = table.Column<DateTime>(nullable: false),
Data = table.Column<string>(maxLength: 50000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IdentityServerIdentityResources",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(nullable: true),
DeletionTime = table.Column<DateTime>(nullable: true),
Name = table.Column<string>(maxLength: 200, nullable: false),
DisplayName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
Enabled = table.Column<bool>(nullable: false),
Required = table.Column<bool>(nullable: false),
Emphasize = table.Column<bool>(nullable: false),
ShowInDiscoveryDocument = table.Column<bool>(nullable: false),
Properties = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IdentityServerPersistedGrants",
columns: table => new
{
Key = table.Column<string>(maxLength: 200, nullable: false),
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
Type = table.Column<string>(maxLength: 50, nullable: false),
SubjectId = table.Column<string>(maxLength: 200, nullable: true),
ClientId = table.Column<string>(maxLength: 200, nullable: false),
CreationTime = table.Column<DateTime>(nullable: false),
Expiration = table.Column<DateTime>(nullable: true),
Data = table.Column<string>(maxLength: 50000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key);
});
migrationBuilder.CreateTable(
name: "IdentityServerApiClaims",
columns: table => new
{
Type = table.Column<string>(maxLength: 200, nullable: false),
ApiResourceId = table.Column<Guid>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiClaims", x => new { x.ApiResourceId, x.Type });
table.ForeignKey(
name: "FK_IdentityServerApiClaims_IdentityServerApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerApiScopes",
columns: table => new
{
ApiResourceId = table.Column<Guid>(nullable: false),
Name = table.Column<string>(maxLength: 200, nullable: false),
DisplayName = table.Column<string>(maxLength: 200, nullable: true),
Description = table.Column<string>(maxLength: 1000, nullable: true),
Required = table.Column<bool>(nullable: false),
Emphasize = table.Column<bool>(nullable: false),
ShowInDiscoveryDocument = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiScopes", x => new { x.ApiResourceId, x.Name });
table.ForeignKey(
name: "FK_IdentityServerApiScopes_IdentityServerApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerApiSecrets",
columns: table => new
{
Type = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 4000, nullable: false),
ApiResourceId = table.Column<Guid>(nullable: false),
Description = table.Column<string>(maxLength: 2000, nullable: true),
Expiration = table.Column<DateTime>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiSecrets", x => new { x.ApiResourceId, x.Type, x.Value });
table.ForeignKey(
name: "FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientClaims",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
Type = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 250, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value });
table.ForeignKey(
name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientCorsOrigins",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
Origin = table.Column<string>(maxLength: 150, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin });
table.ForeignKey(
name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientGrantTypes",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
GrantType = table.Column<string>(maxLength: 250, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType });
table.ForeignKey(
name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientIdPRestrictions",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
Provider = table.Column<string>(maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider });
table.ForeignKey(
name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientPostLogoutRedirectUris",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
PostLogoutRedirectUri = table.Column<string>(maxLength: 2000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri });
table.ForeignKey(
name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientProperties",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
Key = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 2000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key });
table.ForeignKey(
name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientRedirectUris",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
RedirectUri = table.Column<string>(maxLength: 2000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri });
table.ForeignKey(
name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientScopes",
columns: table => new
{
ClientId = table.Column<Guid>(nullable: false),
Scope = table.Column<string>(maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope });
table.ForeignKey(
name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerClientSecrets",
columns: table => new
{
Type = table.Column<string>(maxLength: 250, nullable: false),
Value = table.Column<string>(maxLength: 4000, nullable: false),
ClientId = table.Column<Guid>(nullable: false),
Description = table.Column<string>(maxLength: 2000, nullable: true),
Expiration = table.Column<DateTime>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value });
table.ForeignKey(
name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId",
column: x => x.ClientId,
principalTable: "IdentityServerClients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerIdentityClaims",
columns: table => new
{
Type = table.Column<string>(maxLength: 200, nullable: false),
IdentityResourceId = table.Column<Guid>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerIdentityClaims", x => new { x.IdentityResourceId, x.Type });
table.ForeignKey(
name: "FK_IdentityServerIdentityClaims_IdentityServerIdentityResources_IdentityResourceId",
column: x => x.IdentityResourceId,
principalTable: "IdentityServerIdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerApiScopeClaims",
columns: table => new
{
Type = table.Column<string>(maxLength: 200, nullable: false),
ApiResourceId = table.Column<Guid>(nullable: false),
Name = table.Column<string>(maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiResourceId, x.Name, x.Type });
table.ForeignKey(
name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiResourceId_Name",
columns: x => new { x.ApiResourceId, x.Name },
principalTable: "IdentityServerApiScopes",
principalColumns: new[] { "ApiResourceId", "Name" },
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_IdentityServerClients_ClientId",
table: "IdentityServerClients",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_IdentityServerDeviceFlowCodes_DeviceCode",
table: "IdentityServerDeviceFlowCodes",
column: "DeviceCode",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityServerDeviceFlowCodes_Expiration",
table: "IdentityServerDeviceFlowCodes",
column: "Expiration");
migrationBuilder.CreateIndex(
name: "IX_IdentityServerDeviceFlowCodes_UserCode",
table: "IdentityServerDeviceFlowCodes",
column: "UserCode",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityServerPersistedGrants_Expiration",
table: "IdentityServerPersistedGrants",
column: "Expiration");
migrationBuilder.CreateIndex(
name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type",
table: "IdentityServerPersistedGrants",
columns: new[] { "SubjectId", "ClientId", "Type" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "IdentityServerApiClaims");
migrationBuilder.DropTable(
name: "IdentityServerApiScopeClaims");
migrationBuilder.DropTable(
name: "IdentityServerApiSecrets");
migrationBuilder.DropTable(
name: "IdentityServerClientClaims");
migrationBuilder.DropTable(
name: "IdentityServerClientCorsOrigins");
migrationBuilder.DropTable(
name: "IdentityServerClientGrantTypes");
migrationBuilder.DropTable(
name: "IdentityServerClientIdPRestrictions");
migrationBuilder.DropTable(
name: "IdentityServerClientPostLogoutRedirectUris");
migrationBuilder.DropTable(
name: "IdentityServerClientProperties");
migrationBuilder.DropTable(
name: "IdentityServerClientRedirectUris");
migrationBuilder.DropTable(
name: "IdentityServerClientScopes");
migrationBuilder.DropTable(
name: "IdentityServerClientSecrets");
migrationBuilder.DropTable(
name: "IdentityServerDeviceFlowCodes");
migrationBuilder.DropTable(
name: "IdentityServerIdentityClaims");
migrationBuilder.DropTable(
name: "IdentityServerPersistedGrants");
migrationBuilder.DropTable(
name: "IdentityServerApiScopes");
migrationBuilder.DropTable(
name: "IdentityServerClients");
migrationBuilder.DropTable(
name: "IdentityServerIdentityResources");
migrationBuilder.DropTable(
name: "IdentityServerApiResources");
}
}
}

846
src/AuthServer/AuthServer.Host/Migrations/20201118072557_data1118.Designer.cs

@ -0,0 +1,846 @@
// <auto-generated />
using System;
using AuthServer.Host.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace AuthServer.Host.Migrations
{
[DbContext(typeof(AuthServerDbContext))]
[Migration("20201118072557_data1118")]
partial class data1118
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "3.1.6")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Properties")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("IdentityServerApiResources");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ApiResourceId", "Type");
b.ToTable("IdentityServerApiClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("bit");
b.Property<bool>("Required")
.HasColumnType("bit");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("bit");
b.HasKey("ApiResourceId", "Name");
b.ToTable("IdentityServerApiScopes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ApiResourceId", "Name", "Type");
b.ToTable("IdentityServerApiScopeClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(4000)")
.HasMaxLength(4000);
b.Property<string>("Description")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.HasKey("ApiResourceId", "Type", "Value");
b.ToTable("IdentityServerApiSecrets");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("AbsoluteRefreshTokenLifetime")
.HasColumnType("int");
b.Property<int>("AccessTokenLifetime")
.HasColumnType("int");
b.Property<int>("AccessTokenType")
.HasColumnType("int");
b.Property<bool>("AllowAccessTokensViaBrowser")
.HasColumnType("bit");
b.Property<bool>("AllowOfflineAccess")
.HasColumnType("bit");
b.Property<bool>("AllowPlainTextPkce")
.HasColumnType("bit");
b.Property<bool>("AllowRememberConsent")
.HasColumnType("bit");
b.Property<bool>("AlwaysIncludeUserClaimsInIdToken")
.HasColumnType("bit");
b.Property<bool>("AlwaysSendClientClaims")
.HasColumnType("bit");
b.Property<int>("AuthorizationCodeLifetime")
.HasColumnType("int");
b.Property<bool>("BackChannelLogoutSessionRequired")
.HasColumnType("bit");
b.Property<string>("BackChannelLogoutUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("ClientClaimsPrefix")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<int?>("ConsentLifetime")
.HasColumnType("int");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<int>("DeviceCodeLifetime")
.HasColumnType("int");
b.Property<bool>("EnableLocalLogin")
.HasColumnType("bit");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("FrontChannelLogoutSessionRequired")
.HasColumnType("bit");
b.Property<string>("FrontChannelLogoutUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<int>("IdentityTokenLifetime")
.HasColumnType("int");
b.Property<bool>("IncludeJwtId")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("LogoUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("PairWiseSubjectSalt")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ProtocolType")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<int>("RefreshTokenExpiration")
.HasColumnType("int");
b.Property<int>("RefreshTokenUsage")
.HasColumnType("int");
b.Property<bool>("RequireClientSecret")
.HasColumnType("bit");
b.Property<bool>("RequireConsent")
.HasColumnType("bit");
b.Property<bool>("RequirePkce")
.HasColumnType("bit");
b.Property<int>("SlidingRefreshTokenLifetime")
.HasColumnType("int");
b.Property<bool>("UpdateAccessTokenClaimsOnRefresh")
.HasColumnType("bit");
b.Property<string>("UserCodeType")
.HasColumnType("nvarchar(100)")
.HasMaxLength(100);
b.Property<int?>("UserSsoLifetime")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("IdentityServerClients");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.HasKey("ClientId", "Type", "Value");
b.ToTable("IdentityServerClientClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Origin")
.HasColumnType("nvarchar(150)")
.HasMaxLength(150);
b.HasKey("ClientId", "Origin");
b.ToTable("IdentityServerClientCorsOrigins");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("GrantType")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.HasKey("ClientId", "GrantType");
b.ToTable("IdentityServerClientGrantTypes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Provider")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ClientId", "Provider");
b.ToTable("IdentityServerClientIdPRestrictions");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PostLogoutRedirectUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "PostLogoutRedirectUri");
b.ToTable("IdentityServerClientPostLogoutRedirectUris");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Key")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "Key");
b.ToTable("IdentityServerClientProperties");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("RedirectUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "RedirectUri");
b.ToTable("IdentityServerClientRedirectUris");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Scope")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ClientId", "Scope");
b.ToTable("IdentityServerClientScopes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(4000)")
.HasMaxLength(4000);
b.Property<string>("Description")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.HasKey("ClientId", "Type", "Value");
b.ToTable("IdentityServerClientSecrets");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Devices.DeviceFlowCodes", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasMaxLength(50000);
b.Property<string>("DeviceCode")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<DateTime?>("Expiration")
.IsRequired()
.HasColumnType("datetime2");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<string>("SubjectId")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("UserCode")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("DeviceCode")
.IsUnique();
b.HasIndex("Expiration");
b.HasIndex("UserCode")
.IsUnique();
b.ToTable("IdentityServerDeviceFlowCodes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b =>
{
b.Property<string>("Key")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasMaxLength(50000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("SubjectId")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(50)")
.HasMaxLength(50);
b.HasKey("Key");
b.HasIndex("Expiration");
b.HasIndex("SubjectId", "ClientId", "Type");
b.ToTable("IdentityServerPersistedGrants");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b =>
{
b.Property<Guid>("IdentityResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("IdentityResourceId", "Type");
b.ToTable("IdentityServerIdentityClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("bit");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Properties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Required")
.HasColumnType("bit");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("bit");
b.HasKey("Id");
b.ToTable("IdentityServerIdentityResources");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("Scopes")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiScope", null)
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId", "Name")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("Secrets")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("Claims")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedCorsOrigins")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedGrantTypes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("IdentityProviderRestrictions")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("PostLogoutRedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("Properties")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("RedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedScopes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("ClientSecrets")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", null)
.WithMany("UserClaims")
.HasForeignKey("IdentityResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

17
src/AuthServer/AuthServer.Host/Migrations/20201118072557_data1118.cs

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace AuthServer.Host.Migrations
{
public partial class data1118 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

846
src/AuthServer/AuthServer.Host/Migrations/20201118083155_data.Designer.cs

@ -0,0 +1,846 @@
// <auto-generated />
using System;
using AuthServer.Host.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace AuthServer.Host.Migrations
{
[DbContext(typeof(AuthServerDbContext))]
[Migration("20201118083155_data")]
partial class data
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "3.1.6")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Properties")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("IdentityServerApiResources");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ApiResourceId", "Type");
b.ToTable("IdentityServerApiClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("bit");
b.Property<bool>("Required")
.HasColumnType("bit");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("bit");
b.HasKey("ApiResourceId", "Name");
b.ToTable("IdentityServerApiScopes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ApiResourceId", "Name", "Type");
b.ToTable("IdentityServerApiScopeClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b =>
{
b.Property<Guid>("ApiResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(4000)")
.HasMaxLength(4000);
b.Property<string>("Description")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.HasKey("ApiResourceId", "Type", "Value");
b.ToTable("IdentityServerApiSecrets");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("AbsoluteRefreshTokenLifetime")
.HasColumnType("int");
b.Property<int>("AccessTokenLifetime")
.HasColumnType("int");
b.Property<int>("AccessTokenType")
.HasColumnType("int");
b.Property<bool>("AllowAccessTokensViaBrowser")
.HasColumnType("bit");
b.Property<bool>("AllowOfflineAccess")
.HasColumnType("bit");
b.Property<bool>("AllowPlainTextPkce")
.HasColumnType("bit");
b.Property<bool>("AllowRememberConsent")
.HasColumnType("bit");
b.Property<bool>("AlwaysIncludeUserClaimsInIdToken")
.HasColumnType("bit");
b.Property<bool>("AlwaysSendClientClaims")
.HasColumnType("bit");
b.Property<int>("AuthorizationCodeLifetime")
.HasColumnType("int");
b.Property<bool>("BackChannelLogoutSessionRequired")
.HasColumnType("bit");
b.Property<string>("BackChannelLogoutUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("ClientClaimsPrefix")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<int?>("ConsentLifetime")
.HasColumnType("int");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<int>("DeviceCodeLifetime")
.HasColumnType("int");
b.Property<bool>("EnableLocalLogin")
.HasColumnType("bit");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("FrontChannelLogoutSessionRequired")
.HasColumnType("bit");
b.Property<string>("FrontChannelLogoutUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<int>("IdentityTokenLifetime")
.HasColumnType("int");
b.Property<bool>("IncludeJwtId")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("LogoUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<string>("PairWiseSubjectSalt")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ProtocolType")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<int>("RefreshTokenExpiration")
.HasColumnType("int");
b.Property<int>("RefreshTokenUsage")
.HasColumnType("int");
b.Property<bool>("RequireClientSecret")
.HasColumnType("bit");
b.Property<bool>("RequireConsent")
.HasColumnType("bit");
b.Property<bool>("RequirePkce")
.HasColumnType("bit");
b.Property<int>("SlidingRefreshTokenLifetime")
.HasColumnType("int");
b.Property<bool>("UpdateAccessTokenClaimsOnRefresh")
.HasColumnType("bit");
b.Property<string>("UserCodeType")
.HasColumnType("nvarchar(100)")
.HasMaxLength(100);
b.Property<int?>("UserSsoLifetime")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("IdentityServerClients");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.HasKey("ClientId", "Type", "Value");
b.ToTable("IdentityServerClientClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Origin")
.HasColumnType("nvarchar(150)")
.HasMaxLength(150);
b.HasKey("ClientId", "Origin");
b.ToTable("IdentityServerClientCorsOrigins");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("GrantType")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.HasKey("ClientId", "GrantType");
b.ToTable("IdentityServerClientGrantTypes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Provider")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ClientId", "Provider");
b.ToTable("IdentityServerClientIdPRestrictions");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PostLogoutRedirectUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "PostLogoutRedirectUri");
b.ToTable("IdentityServerClientPostLogoutRedirectUris");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Key")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.IsRequired()
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "Key");
b.ToTable("IdentityServerClientProperties");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("RedirectUri")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.HasKey("ClientId", "RedirectUri");
b.ToTable("IdentityServerClientRedirectUris");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Scope")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("ClientId", "Scope");
b.ToTable("IdentityServerClientScopes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b =>
{
b.Property<Guid>("ClientId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(250)")
.HasMaxLength(250);
b.Property<string>("Value")
.HasColumnType("nvarchar(4000)")
.HasMaxLength(4000);
b.Property<string>("Description")
.HasColumnType("nvarchar(2000)")
.HasMaxLength(2000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.HasKey("ClientId", "Type", "Value");
b.ToTable("IdentityServerClientSecrets");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Devices.DeviceFlowCodes", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasMaxLength(50000);
b.Property<string>("DeviceCode")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<DateTime?>("Expiration")
.IsRequired()
.HasColumnType("datetime2");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<string>("SubjectId")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("UserCode")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("Id");
b.HasIndex("DeviceCode")
.IsUnique();
b.HasIndex("Expiration");
b.HasIndex("UserCode")
.IsUnique();
b.ToTable("IdentityServerDeviceFlowCodes");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b =>
{
b.Property<string>("Key")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasMaxLength(50000);
b.Property<DateTime?>("Expiration")
.HasColumnType("datetime2");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("SubjectId")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(50)")
.HasMaxLength(50);
b.HasKey("Key");
b.HasIndex("Expiration");
b.HasIndex("SubjectId", "ClientId", "Type");
b.ToTable("IdentityServerPersistedGrants");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b =>
{
b.Property<Guid>("IdentityResourceId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Type")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.HasKey("IdentityResourceId", "Type");
b.ToTable("IdentityServerIdentityClaims");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(1000)")
.HasMaxLength(1000);
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<bool>("Emphasize")
.HasColumnType("bit");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(200)")
.HasMaxLength(200);
b.Property<string>("Properties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Required")
.HasColumnType("bit");
b.Property<bool>("ShowInDiscoveryDocument")
.HasColumnType("bit");
b.HasKey("Id");
b.ToTable("IdentityServerIdentityResources");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("Scopes")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiScope", null)
.WithMany("UserClaims")
.HasForeignKey("ApiResourceId", "Name")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)
.WithMany("Secrets")
.HasForeignKey("ApiResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("Claims")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedCorsOrigins")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedGrantTypes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("IdentityProviderRestrictions")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("PostLogoutRedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("Properties")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("RedirectUris")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("AllowedScopes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b =>
{
b.HasOne("Volo.Abp.IdentityServer.Clients.Client", null)
.WithMany("ClientSecrets")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", null)
.WithMany("UserClaims")
.HasForeignKey("IdentityResourceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

17
src/AuthServer/AuthServer.Host/Migrations/20201118083155_data.cs

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace AuthServer.Host.Migrations
{
public partial class data : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

1055
src/AuthServer/AuthServer.Host/Migrations/20201210034748_update.Designer.cs

File diff suppressed because it is too large

613
src/AuthServer/AuthServer.Host/Migrations/20201210034748_update.cs

@ -0,0 +1,613 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace AuthServer.Host.Migrations
{
public partial class update : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityServerApiClaims_IdentityServerApiResources_ApiResourceId",
table: "IdentityServerApiClaims");
migrationBuilder.DropForeignKey(
name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiResourceId_Name",
table: "IdentityServerApiScopeClaims");
migrationBuilder.DropForeignKey(
name: "FK_IdentityServerApiScopes_IdentityServerApiResources_ApiResourceId",
table: "IdentityServerApiScopes");
migrationBuilder.DropTable(
name: "IdentityServerApiSecrets");
migrationBuilder.DropTable(
name: "IdentityServerIdentityClaims");
migrationBuilder.DropIndex(
name: "IX_IdentityServerDeviceFlowCodes_UserCode",
table: "IdentityServerDeviceFlowCodes");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerClientProperties",
table: "IdentityServerClientProperties");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerApiScopes",
table: "IdentityServerApiScopes");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerApiScopeClaims",
table: "IdentityServerApiScopeClaims");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerApiClaims",
table: "IdentityServerApiClaims");
migrationBuilder.DropColumn(
name: "Properties",
table: "IdentityServerIdentityResources");
migrationBuilder.DropColumn(
name: "Name",
table: "IdentityServerApiScopeClaims");
migrationBuilder.DropColumn(
name: "Properties",
table: "IdentityServerApiResources");
migrationBuilder.RenameTable(
name: "IdentityServerApiClaims",
newName: "IdentityServerApiResourceClaims");
migrationBuilder.RenameColumn(
name: "ApiResourceId",
table: "IdentityServerApiScopes",
newName: "Id");
migrationBuilder.RenameColumn(
name: "ApiResourceId",
table: "IdentityServerApiScopeClaims",
newName: "ApiScopeId");
migrationBuilder.AddColumn<DateTime>(
name: "ConsumedTime",
table: "IdentityServerPersistedGrants",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Description",
table: "IdentityServerPersistedGrants",
type: "nvarchar(200)",
maxLength: 200,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SessionId",
table: "IdentityServerPersistedGrants",
type: "nvarchar(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Description",
table: "IdentityServerDeviceFlowCodes",
type: "nvarchar(200)",
maxLength: 200,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SessionId",
table: "IdentityServerDeviceFlowCodes",
type: "nvarchar(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "AllowedIdentityTokenSigningAlgorithms",
table: "IdentityServerClients",
type: "nvarchar(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "RequireRequestObject",
table: "IdentityServerClients",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "ConcurrencyStamp",
table: "IdentityServerApiScopes",
type: "nvarchar(40)",
maxLength: 40,
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "CreationTime",
table: "IdentityServerApiScopes",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<Guid>(
name: "CreatorId",
table: "IdentityServerApiScopes",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "DeleterId",
table: "IdentityServerApiScopes",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DeletionTime",
table: "IdentityServerApiScopes",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "Enabled",
table: "IdentityServerApiScopes",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "ExtraProperties",
table: "IdentityServerApiScopes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "IdentityServerApiScopes",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "LastModificationTime",
table: "IdentityServerApiScopes",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "LastModifierId",
table: "IdentityServerApiScopes",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "AllowedAccessTokenSigningAlgorithms",
table: "IdentityServerApiResources",
type: "nvarchar(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "ShowInDiscoveryDocument",
table: "IdentityServerApiResources",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerClientProperties",
table: "IdentityServerClientProperties",
columns: new[] { "ClientId", "Key", "Value" });
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerApiScopes",
table: "IdentityServerApiScopes",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerApiScopeClaims",
table: "IdentityServerApiScopeClaims",
columns: new[] { "ApiScopeId", "Type" });
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerApiResourceClaims",
table: "IdentityServerApiResourceClaims",
columns: new[] { "ApiResourceId", "Type" });
migrationBuilder.CreateTable(
name: "IdentityServerApiResourceProperties",
columns: table => new
{
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value });
table.ForeignKey(
name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerApiResourceScopes",
columns: table => new
{
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Scope = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope });
table.ForeignKey(
name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerApiResourceSecrets",
columns: table => new
{
Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
Value = table.Column<string>(type: "nvarchar(4000)", maxLength: 4000, nullable: false),
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
Expiration = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value });
table.ForeignKey(
name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerApiScopeProperties",
columns: table => new
{
ApiScopeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value });
table.ForeignKey(
name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_ApiScopeId",
column: x => x.ApiScopeId,
principalTable: "IdentityServerApiScopes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerIdentityResourceClaims",
columns: table => new
{
Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
IdentityResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type });
table.ForeignKey(
name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityResources_IdentityResourceId",
column: x => x.IdentityResourceId,
principalTable: "IdentityServerIdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerIdentityResourceProperties",
columns: table => new
{
IdentityResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value });
table.ForeignKey(
name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdentityResources_IdentityResourceId",
column: x => x.IdentityResourceId,
principalTable: "IdentityServerIdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type",
table: "IdentityServerPersistedGrants",
columns: new[] { "SubjectId", "SessionId", "Type" });
migrationBuilder.CreateIndex(
name: "IX_IdentityServerDeviceFlowCodes_UserCode",
table: "IdentityServerDeviceFlowCodes",
column: "UserCode");
migrationBuilder.AddForeignKey(
name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId",
table: "IdentityServerApiResourceClaims",
column: "ApiResourceId",
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId",
table: "IdentityServerApiScopeClaims",
column: "ApiScopeId",
principalTable: "IdentityServerApiScopes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId",
table: "IdentityServerApiResourceClaims");
migrationBuilder.DropForeignKey(
name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId",
table: "IdentityServerApiScopeClaims");
migrationBuilder.DropTable(
name: "IdentityServerApiResourceProperties");
migrationBuilder.DropTable(
name: "IdentityServerApiResourceScopes");
migrationBuilder.DropTable(
name: "IdentityServerApiResourceSecrets");
migrationBuilder.DropTable(
name: "IdentityServerApiScopeProperties");
migrationBuilder.DropTable(
name: "IdentityServerIdentityResourceClaims");
migrationBuilder.DropTable(
name: "IdentityServerIdentityResourceProperties");
migrationBuilder.DropIndex(
name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type",
table: "IdentityServerPersistedGrants");
migrationBuilder.DropIndex(
name: "IX_IdentityServerDeviceFlowCodes_UserCode",
table: "IdentityServerDeviceFlowCodes");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerClientProperties",
table: "IdentityServerClientProperties");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerApiScopes",
table: "IdentityServerApiScopes");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerApiScopeClaims",
table: "IdentityServerApiScopeClaims");
migrationBuilder.DropPrimaryKey(
name: "PK_IdentityServerApiResourceClaims",
table: "IdentityServerApiResourceClaims");
migrationBuilder.DropColumn(
name: "ConsumedTime",
table: "IdentityServerPersistedGrants");
migrationBuilder.DropColumn(
name: "Description",
table: "IdentityServerPersistedGrants");
migrationBuilder.DropColumn(
name: "SessionId",
table: "IdentityServerPersistedGrants");
migrationBuilder.DropColumn(
name: "Description",
table: "IdentityServerDeviceFlowCodes");
migrationBuilder.DropColumn(
name: "SessionId",
table: "IdentityServerDeviceFlowCodes");
migrationBuilder.DropColumn(
name: "AllowedIdentityTokenSigningAlgorithms",
table: "IdentityServerClients");
migrationBuilder.DropColumn(
name: "RequireRequestObject",
table: "IdentityServerClients");
migrationBuilder.DropColumn(
name: "ConcurrencyStamp",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "CreationTime",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "CreatorId",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "DeleterId",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "DeletionTime",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "Enabled",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "ExtraProperties",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "LastModificationTime",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "LastModifierId",
table: "IdentityServerApiScopes");
migrationBuilder.DropColumn(
name: "AllowedAccessTokenSigningAlgorithms",
table: "IdentityServerApiResources");
migrationBuilder.DropColumn(
name: "ShowInDiscoveryDocument",
table: "IdentityServerApiResources");
migrationBuilder.RenameTable(
name: "IdentityServerApiResourceClaims",
newName: "IdentityServerApiClaims");
migrationBuilder.RenameColumn(
name: "Id",
table: "IdentityServerApiScopes",
newName: "ApiResourceId");
migrationBuilder.RenameColumn(
name: "ApiScopeId",
table: "IdentityServerApiScopeClaims",
newName: "ApiResourceId");
migrationBuilder.AddColumn<string>(
name: "Properties",
table: "IdentityServerIdentityResources",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Name",
table: "IdentityServerApiScopeClaims",
type: "nvarchar(200)",
maxLength: 200,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Properties",
table: "IdentityServerApiResources",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerClientProperties",
table: "IdentityServerClientProperties",
columns: new[] { "ClientId", "Key" });
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerApiScopes",
table: "IdentityServerApiScopes",
columns: new[] { "ApiResourceId", "Name" });
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerApiScopeClaims",
table: "IdentityServerApiScopeClaims",
columns: new[] { "ApiResourceId", "Name", "Type" });
migrationBuilder.AddPrimaryKey(
name: "PK_IdentityServerApiClaims",
table: "IdentityServerApiClaims",
columns: new[] { "ApiResourceId", "Type" });
migrationBuilder.CreateTable(
name: "IdentityServerApiSecrets",
columns: table => new
{
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
Value = table.Column<string>(type: "nvarchar(4000)", maxLength: 4000, nullable: false),
Description = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
Expiration = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerApiSecrets", x => new { x.ApiResourceId, x.Type, x.Value });
table.ForeignKey(
name: "FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResourceId",
column: x => x.ApiResourceId,
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityServerIdentityClaims",
columns: table => new
{
IdentityResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityServerIdentityClaims", x => new { x.IdentityResourceId, x.Type });
table.ForeignKey(
name: "FK_IdentityServerIdentityClaims_IdentityServerIdentityResources_IdentityResourceId",
column: x => x.IdentityResourceId,
principalTable: "IdentityServerIdentityResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_IdentityServerDeviceFlowCodes_UserCode",
table: "IdentityServerDeviceFlowCodes",
column: "UserCode",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_IdentityServerApiClaims_IdentityServerApiResources_ApiResourceId",
table: "IdentityServerApiClaims",
column: "ApiResourceId",
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiResourceId_Name",
table: "IdentityServerApiScopeClaims",
columns: new[] { "ApiResourceId", "Name" },
principalTable: "IdentityServerApiScopes",
principalColumns: new[] { "ApiResourceId", "Name" },
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityServerApiScopes_IdentityServerApiResources_ApiResourceId",
table: "IdentityServerApiScopes",
column: "ApiResourceId",
principalTable: "IdentityServerApiResources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

1053
src/AuthServer/AuthServer.Host/Migrations/AuthServerDbContextModelSnapshot.cs

File diff suppressed because it is too large

33
src/AuthServer/AuthServer.Host/Pages/Index.cshtml

@ -0,0 +1,33 @@
@page
@using Volo.Abp.Users
@model AuthServer.Host.Pages.IndexModel
@inject ICurrentUser CurrentUser
@if (CurrentUser.IsAuthenticated)
{
<div>
<abp-row>
<abp-column size-md="_3" class="text-center">
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i>
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account">Logout</a>
</abp-column>
<abp-column size-md="_9">
<h2>@CurrentUser.UserName</h2>
<h5 class="text-muted">@CurrentUser.Email</h5>
<div>
<strong>Roles</strong>: @CurrentUser.Roles.JoinAsString(", ")
<br />
<strong>Claims</strong>: <br />
@Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString(" <br /> "))
</div>
</abp-column>
</abp-row>
</div>
}
@if (!CurrentUser.IsAuthenticated)
{
<div class="text-center">
<img src="~/images/anonymous-user.png" width="200" /><br/><br />
<a abp-button="Primary" asp-page="/Account/Login">Login</a>
</div>
}

11
src/AuthServer/AuthServer.Host/Pages/Index.cshtml.cs

@ -0,0 +1,11 @@
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace AuthServer.Host.Pages
{
public class IndexModel : AbpPageModel
{
public void OnGet()
{
}
}
}

4
src/AuthServer/AuthServer.Host/Pages/_ViewImports.cshtml

@ -0,0 +1,4 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling

63
src/AuthServer/AuthServer.Host/Program.cs

@ -0,0 +1,63 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace AuthServer.Host
{
public class Program
{
public static int Main(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables()
.Build();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.WithProperty("Application", "AuthServer")
.Enrich.FromLogContext()
.WriteTo.File("Logs/logs.txt")
//.WriteTo.Elasticsearch(
// new ElasticsearchSinkOptions(new Uri(configuration["ElasticSearch:Url"]))
// {
// AutoRegisterTemplate = true,
// AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
// IndexFormat = "xdlms-log-{0:yyyy.MM}"
// })
.WriteTo.Console()
.CreateLogger();
try
{
Log.Information("Starting AuthServer.Host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "AuthServer.Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
}

26
src/AuthServer/AuthServer.Host/Properties/launchSettings.json

@ -0,0 +1,26 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:10100",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"AuthServer.Host": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:10100"
}
}
}

20
src/AuthServer/AuthServer.Host/Startup.cs

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace AuthServer.Host
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<AuthServerHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}
}

9
src/AuthServer/AuthServer.Host/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

20
src/AuthServer/AuthServer.Host/appsettings.json

@ -0,0 +1,20 @@
{
"ConnectionStrings": {
"Default": "Server=124.220.28.250;Database=ABP;User ID=sa;Password=Microsoft2008;"
//"Default": "Server=LAPTOP-V3U07C2O;Database=ABP;user id=sa;Password=1q2w!@#"
},
"ElasticSearch": {
"Url": "http://localhost:9200"
},
"CorsOrigins": "http://localhost:9528",
"Redis": {
"Configuration": "127.0.0.1"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"Urls": "http://*:8066"
}

9
src/AuthServer/AuthServer.Host/gulpfile.js

@ -0,0 +1,9 @@
"use strict";
var gulp = require("gulp"),
path = require('path'),
copyResources = require('./node_modules/@abp/aspnetcore.mvc.ui/gulp/copy-resources.js');
exports.default = function(){
return copyResources(path.resolve('./'));
};

5
src/AuthServer/AuthServer.Host/libman.json

@ -0,0 +1,5 @@
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": []
}

3453
src/AuthServer/AuthServer.Host/package-lock.json

File diff suppressed because it is too large

8
src/AuthServer/AuthServer.Host/package.json

@ -0,0 +1,8 @@
{
"version": "0.1.0",
"name": "authserver-host",
"private": true,
"dependencies": {
"@abp/aspnetcore.mvc.ui.theme.basic": "^1.0.2"
}
}

1
src/AuthServer/AuthServer.Host/tempkey.jwk

@ -0,0 +1 @@
{"alg":"RS256","d":"bOW5RmPaeT5EMN3Na6cV_KC7Qt5AfYRYKJ-eBe7uANI9USh4plhe8wiOYxhLmZINA4VVDSQMtZmNdo7EP_N92ll4LyD1_DR5lkburjCKh-ARqEl5JZ2OvEQwnzbFEx3-yhm8w86EM1FZ0FwrNv7tsZeTfCiL0zVOA2jOyk85OP4OPHpPnchLJXVbXQGJ3CGgt5q3Csc0zr2m9KodV_2OiPgxrWWILJknnIbQYRD3x2ZMzLp_bAmhZONNhvIMLPB6U5HCxI6v6oufukxIX17Son-wIoGRPwtwwnuTHuRGtRWdaPrMMcSkXeVEIyw3iYqV0O12bL-q39rQm9bCZXdRAQ","dp":"QL1fUIho-Oe6HcF5w5h3-HDoZ5jribSB1BT4dqBwNC9KWnK-uZf8uHuxqMly944iVEnbFHT2VI47IlUOAxD2zP_2F-Qt05ljC0Xly0c-zPr5MfrFW2F7f-8ppCnuyesi_XUF9pDdaWz7N6MRJOo0A_oCIMVxJe1eKCZyQ_EV_D8","dq":"AkvKURAcK1RQ6VXFndcKtqJfizd98FRnfhhchpXRxGz2BuS9cNSVe6NgA4wCnizInSlZXr-jmfNQXE5fT34--rj6wVAnVoAN3rt4NhOkj3__51wBfMvmj4Hpg6eFn_FArGyi9uCN23Bc0jvrK_gykGYoBhAdmoCjPw8ANNUcz_0","e":"AQAB","kid":"5A17250A6F20C147698EDAAC53F4E422","kty":"RSA","n":"rw8cAcpam0hSrqGL6jnhrlv6_8Ihh9352ivY2ecB6EpWObToyKWcAKZjihbMeFl14y34FA0FyZWFH-0UL8W2isvfGXoA_KZQ2J5flH2-cgApC2xREwf26ziLrQ6yGLwxrvk2CbdPLsD8mEBGDFI29fxqOKQEy8MfTRqjfF7d5DjCPoL8kidjab4pkdenHb-2dvNLKuObECWxGzqDkPm79VaLoT8hv5OrVh6NJnQwCzIBHxG-3Cfik2P3WRXSWOAIgmC0foHIAI-iYqPVeOhPwVkoAZK978GeE2XPSTByPttbbwFn7Zj55wwL6WbzaX-u1NfEFyxAg5u0oEkryNuGiQ","p":"yx0uMFsZeGRVgsVUBdxhg5InfhxMjdF_cxlQVAh3X7HwzN9OG1zJ00X90w-yKrw9Qca2EWDjLpbPMbjNGvxbypnXYmBSpY8QPw11A-wS7MTMCYJ5OxfGExPJevnrul1fJRKCtaINCwv7NBm-4Bdxhcp4Z7kjnkht-QWbEgtGIO8","q":"3KPjytutNXv2HAidgh-9ECxcL69axZJThNMwZvrgj6nV54OA9wAeHNmU_cHAQdcBexs519bXTmt4ubTIZS65Cz7dk3wdhictVtZQKHwcNML3gFdnJs72BK6NudHvSGZUtitQJVsdRqbCqfGDVhj5d6MRWWO46ZGMRekzvO3ZYAc","qi":"DgWNZXuKHm6I6B83fg8oj3rFTI4ILGFrd0MBbKrOh-ycTla_Av0ZAsHJuR_yM3SE4nl5baRDrDjlBsW6nuzP5lID6JhR_kOPqziZ8E28UyflG8v2C5pEEKee6CwSqckXPCtq-jnY4ciAiSlHaE48G5We7N86tLzqRmeflDsH980"}

1
src/AuthServer/AuthServer.Host/tempkey.rsa

@ -0,0 +1 @@
{"KeyId":"J2XEHsFYdI-u2CG4-DQofQ","Parameters":{"D":"KqHtHWJT08GCMba6s7jrEVO21zbfwtO6aan71VvRC7OuNok65o9UUY9vu1X+NexGRDWIleNY+8qhhSfXGUYhaVTMrAcj7wgjowoaALvZ5rLPODbBJPZ6bcGb6XnnT92eQ3y4PpEtXx2cvUFh3qVD1vDkXnliD7/PudMSBvG5mIZ1DpeleWuIqor2DrwWwYtc4twfincfwioc5Rs/IcYSLP2yPIbZBQ+WOLgfmKHFNXWNKMuc3ibDoIvy0gRfsxGvb24lOPvEosmRmQ9ho9R89aG0lVecRNppDc5kcuOBEEvkAWM/RkCV0UBdEizpZ/A5fixpyCTQST3l55xYNR12XQ==","DP":"bLOeKCdm8ahclUGMIE6Hl6MZEp9SJ5z5+YcMJU+9vCEj+YAx+AjNvXA9Atnubp9kWHCkIS/07HFfWVn9vdfigWKMzwzFinQbh7h6Wq+fk+dth96NjRY4+d4Qqg9Jzbq6X+Ai8xgzveOkDNk8X8M4JXaqGWENqnvz+8v68ekf2Nc=","DQ":"Nof5wutoO2R5vLZi17Z75h4J/uB1pfFmDkYcmJIEyxBEUFtBlQCoq5OeQADU4Jy8uCmBMXOQCgqbzGeBUoZH/cCuGH+awhlfOJLW3CYo00bHnYXA3KmbUHiTVBlKBAFL1O6w2K4f48mhWwFstZ2qmSVfrkOXYRHu0Wz5BJbvdds=","Exponent":"AQAB","InverseQ":"S+P+p0YYFXQiadN8/X/s6yJNUOKWwAUy2Q90mnFfuDGdWvEGUifqgAYR6P/IDKrP/a/+8h5uSvdTHFICM/v+wlisoS+STKTdKhIWHHQ9h371mNAQLQmPWoNs4WiVzOKvUsjNnqOnJT5zBuSWOJe6mV9OW/mGnJ1RMlETgFCGZmw=","Modulus":"p8IFbj7yTlG1zwr/GZ4CGB0Fxz8sZsqyqQ2/xVb9RaAVzI+VwQt+1nrVDPQMyYSjHzcGL36fUe+DECzysNA5DEjToyhg3oIbvzk9ybVO0HgbGViSYwM732ohR2zSXFTBoIguSSfquzshC4uZYp7w7KjSYp1vgGPXI5CXKAGbWyvONBmIWbfD4i74UmwLOZEQHuwKnPZ3DmuQaFr9+dB8IijGSbiPL9AYvFdamfDYnU2i1Th+gKlHurmWBKF3NllXWQPmyENiigULGDZX1PZHmUyLt7Ba1HxF0YYYYvlY9kjTahjcwFQIURayG5pajDZNP0lIJ7HitaoCXkc1agjj8Q==","P":"0hdR1/vTZ6S6GF8Dy94GpRmqoHZqAPHXYwk7EDkolAZAeoQ4UmcBWmvux63uJEwXpOYOZ0OrBkal00VllDBKPMhK9vW+mW+PgmeU0b5KRQLXiUpaEHD88W321fDTASEACtR7kPvoKLPv6Gy5RnFCOQ0QqY7arcJWl5x00mxpIr8=","Q":"zGqLlpbHclOgfOAlOTMVQWiQ3CV+RU4XCv/LCEg8/QsEVCkWN4dtKl2nHNj15ykBMwEPOlVUrGnsc7n5YcOe47SO31PZMTdiPNs5QM8uOBN87A/ZYN5z+NpKt6iziiULO//KsOYxbsuFtnIuK1kiQurLcRNeAHVgAOAhDpkilU8="}}

BIN
src/AuthServer/AuthServer.Host/wwwroot/images/anonymous-user.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

2596
src/AuthServer/AuthServer.Host/yarn.lock

File diff suppressed because it is too large

25
src/AuthServer/AuthServer.sln

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29326.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthServer", "./AuthServer.Host/AuthServer.Host.csproj", "{21789B5F-E84A-407E-8DAA-5F268E5F8647}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21789B5F-E84A-407E-8DAA-5F268E5F8647}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7585D0E2-0A6D-4F73-8EFF-433646754357}
EndGlobalSection
EndGlobal

2
src/AuthServer/README.md

@ -0,0 +1,2 @@
#SmartFactorySuite
##Authorization Server

360
src/Gateways/.gitignore

@ -0,0 +1,360 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

26
src/Gateways/InternalGateway/InternalGateway.Host/InternalGateway.Host.csproj

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp5</TargetFramework>
<RootNamespace>InternalGateway</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.5" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="Ocelot" Version="17.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
<PackageReference Include="Serilog.Sinks.ElasticSearch" Version="8.4.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.2" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="4.2.2" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.2.2" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="4.2.2" />
<PackageReference Include="Volo.Abp.Identity.HttpApi" Version="4.2.2" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

143
src/Gateways/InternalGateway/InternalGateway.Host/InternalGatewayHostModule.cs

@ -0,0 +1,143 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Volo.Abp;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.Security.Claims;
namespace InternalGateway
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAspNetCoreSerilogModule)
)]
public class InternalGatewayHostModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
ConfigureAuthentication(context, configuration);
//ConfigureSql();
//ConfigureRedis(context, configuration, hostingEnvironment);
ConfigureSwaggerServices(context);
context.Services.AddOcelot(context.Services.GetConfiguration());
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseRouting();
app.UseAuthentication();
//app.UseMultiTenancy();
//app.UseAuthorization();
app.Use(async (ctx, next) =>
{
var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>();
var map = new Dictionary<string, string>()
{
{ "sub", AbpClaimTypes.UserId },
{ "role", AbpClaimTypes.Role },
{ "email", AbpClaimTypes.Email },
{ "name", AbpClaimTypes.UserName },
{ "tenantid", AbpClaimTypes.TenantId }
};
var mapClaims = currentPrincipalAccessor.Principal.Claims.Where(p => map.Keys.Contains(p.Type)).ToList();
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Business Service API");
});
app.MapWhen(
ctx => ctx.Request.Path.ToString().StartsWith("/api/abp/") ||
ctx.Request.Path.ToString().StartsWith("/Abp/"),
app2 =>
{
app2.UseRouting();
app2.UseConfiguredEndpoints();
}
);
app.UseOcelot().Wait();
app.UseAbpSerilogEnrichers();
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = "InternalGateway";
});
}
/*
private void ConfigureSql()
{
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
}
private void ConfigureRedis(
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{
context.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = configuration["Redis:Configuration"];
});
if (!hostingEnvironment.IsDevelopment())
{
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
}
}
*/
private static void ConfigureSwaggerServices(ServiceConfigurationContext context)
{
context.Services.AddSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "InternalGateway Service API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
});
}
}
}

66
src/Gateways/InternalGateway/InternalGateway.Host/Program.cs

@ -0,0 +1,66 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace InternalGateway
{
public class Program
{
public static int Main(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables()
.Build();
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
// .WriteTo.Elasticsearch(
// new ElasticsearchSinkOptions(new Uri(configuration["ElasticSearch:Url"]))
// {
// AutoRegisterTemplate = true,
// AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
// IndexFormat = "msdemo-log-{0:yyyy.MM}"
// })
.WriteTo.Console()
.CreateLogger();
try
{
Log.Information("Starting Business.Host");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
}

27
src/Gateways/InternalGateway/InternalGateway.Host/Properties/launchSettings.json

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:58315/",
"sslPort": 44383
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"InternalGateway.Host": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:10110"
}
}
}

19
src/Gateways/InternalGateway/InternalGateway.Host/Startup.cs

@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace InternalGateway
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<InternalGatewayHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.InitializeApplication();
}
}
}

9
src/Gateways/InternalGateway/InternalGateway.Host/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

39
src/Gateways/InternalGateway/InternalGateway.Host/appsettings.json

@ -0,0 +1,39 @@
{
"AuthServer": {
"Authority": "http://localhost:10100",
"ApiName": "InternalGateway"
},
"ConnectionStrings": {
"Default": "Server=124.220.28.250;Database=ABP;User ID=sa;Password=Microsoft2008;"
},
"ElasticSearch": {
"Url": "http://localhost:9200"
},
"Redis": {
"Configuration": "127.0.0.1"
},
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/identity/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10130
}
],
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "http://localhost:10110"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"Urls": "http://*:8091"
}

25
src/Gateways/InternalGateway/InternalGateway.sln

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30002.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InternalGateway.Host", "InternalGateway.Host\InternalGateway.Host.csproj", "{C48F9300-FF79-4E66-9783-7E622FD0945A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C48F9300-FF79-4E66-9783-7E622FD0945A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C48F9300-FF79-4E66-9783-7E622FD0945A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C48F9300-FF79-4E66-9783-7E622FD0945A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C48F9300-FF79-4E66-9783-7E622FD0945A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {343C6B22-83EC-4A39-A731-1DD795BE7EF8}
EndGlobalSection
EndGlobal

3
src/Gateways/README.md

@ -0,0 +1,3 @@
#SmartFactorySuite
##Internal Gateway
##WebApp Gateway

12
src/Gateways/WebAppGateway/WebAppGateway.Host/Dockerfile

@ -0,0 +1,12 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o publish
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build /src/publish ./
ENTRYPOINT ["dotnet", "WebAppGateway.Host.dll"]

66
src/Gateways/WebAppGateway/WebAppGateway.Host/Program.cs

@ -0,0 +1,66 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace WebAppGateway
{
public class Program
{
public static int Main(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables()
.Build();
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
// .WriteTo.Elasticsearch(
// new ElasticsearchSinkOptions(new Uri(configuration["ElasticSearch:Url"]))
// {
// AutoRegisterTemplate = true,
// AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
// IndexFormat = "msdemo-log-{0:yyyy.MM}"
// })
.WriteTo.Console()
.CreateLogger();
try
{
Log.Information("Starting Business.Host");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
}

27
src/Gateways/WebAppGateway/WebAppGateway.Host/Properties/launchSettings.json

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:63356/",
"sslPort": 44393
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebAppGateway.Host": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:10120"
}
}
}

20
src/Gateways/WebAppGateway/WebAppGateway.Host/Startup.cs

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace WebAppGateway
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<WebAppGatewayHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}
}

35
src/Gateways/WebAppGateway/WebAppGateway.Host/WebAppGateway.Host.csproj

@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp5</TargetFramework>
<RootNamespace>WebAppGateway</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.0" />
<PackageReference Include="Ocelot" Version="15.0.7" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
<!-- <PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.2.0" /> -->
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="4.0.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.0.0" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Identity.HttpApi" Version="4.0.0" />
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="4.0.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="4.0.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="4.0.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="4.0.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi" Version="4.0.0" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="4.0.0" />
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi" Version="4.0.0" />
</ItemGroup>
</Project>

155
src/Gateways/WebAppGateway/WebAppGateway.Host/WebAppGatewayHostModule.cs

@ -0,0 +1,155 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using StackExchange.Redis;
using System;
using System.Linq;
using Volo.Abp;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
namespace WebAppGateway
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpAspNetCoreSerilogModule)
)]
public class WebAppGatewayHostModule: AbpModule
{
private const string DefaultCorsPolicyName = "Default";
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
ConfigureAuthentication(context, configuration);
//ConfigureSql();
//ConfigureRedis(context, configuration, hostingEnvironment);
ConfigureCors(context, configuration);
//ConfigureSwaggerServices(context);
ConfigureLocalization();
context.Services.AddOcelot(context.Services.GetConfiguration());
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
//app.UseSwagger();
//app.UseSwaggerUI(options =>
//{
// options.SwaggerEndpoint("/swagger/v1/swagger.json", "Business Service API");
//});
app.UseOcelot().Wait();
app.UseAbpSerilogEnrichers();
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = "WebAppGateway";
});
}
/*
private static void ConfigureSwaggerServices(ServiceConfigurationContext context)
{
context.Services.AddSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "WebAppGateway Service API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
});
}
*/
private void ConfigureLocalization()
{
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
});
}
/*
private void ConfigureSql()
{
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
}
private void ConfigureRedis(
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{
context.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = configuration["Redis:Configuration"];
});
if (!hostingEnvironment.IsDevelopment())
{
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
}
}
*/
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}
}
}

9
src/Gateways/WebAppGateway/WebAppGateway.Host/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

122
src/Gateways/WebAppGateway/WebAppGateway.Host/appsettings.json

@ -0,0 +1,122 @@
{
"RemoteServices": {
"Default": {
"BaseUrl": "http://localhost:10120/"
}
},
"App": {
"CorsOrigins": "http://localhost:10000/"
},
"ConnectionStrings": {
"Default": "Server=124.220.28.250;Database=ABP;User ID=sa;Password=Microsoft2008;"
},
"Redis": {
"Configuration": "192.168.1.191"
},
"ElasticSearch": {
"Url": "http://localhost:9200"
},
"AuthServer": {
"Authority": "http://localhost:10100"
},
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10130
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/identity/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10130
}
],
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/base/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10130
}
],
"UpstreamPathTemplate": "/api/base/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/multi-tenancy/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10130
}
],
"UpstreamPathTemplate": "/api/multi-tenancy/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/permission-management/permissions",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10130
}
],
"UpstreamPathTemplate": "/api/permission-management/permissions",
"UpstreamHttpMethod": [ "Put", "Get" ]
},
{
"DownstreamPathTemplate": "/api/MasterDataService/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10200
}
],
"UpstreamPathTemplate": "/api/MasterDataService/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/getBlobFiles/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 10600
}
],
"UpstreamPathTemplate": "/api/getBlobFiles/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/getBlobFiles/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "http://114.116.225.148/",
"Port": 8088
}
],
"UpstreamPathTemplate": "/api/getBlobFiles/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
],
"Urls": "http://*:8092"
}

25
src/Gateways/WebAppGateway/WebAppGateway.sln

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30002.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAppGateway.Host", "WebAppGateway.Host\WebAppGateway.Host.csproj", "{C27EC872-685A-43E2-8E8E-1C4B05B0B004}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C27EC872-685A-43E2-8E8E-1C4B05B0B004}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C27EC872-685A-43E2-8E8E-1C4B05B0B004}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C27EC872-685A-43E2-8E8E-1C4B05B0B004}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C27EC872-685A-43E2-8E8E-1C4B05B0B004}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {993A20BD-5184-407D-8874-270FC037FC57}
EndGlobalSection
EndGlobal

360
src/Modules/BaseService/.gitignore

@ -0,0 +1,360 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

53
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/Dto/BranchDto.cs

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using BaseService.RelationBaseData;
using Volo.Abp.Application.Dtos;
namespace BaseService.BaseData.BranchManagement.Dto
{
public class BranchDto : EntityDto<Guid>
{
public short CategoryId { get; set; }
public Guid? Pid { get; set; }
public string Name { get; set; }
public string FullName { get; set; }
public int Sort { get; set; }
public bool Enabled { get; set; }
public bool HasChildren { get; set; }
public bool Leaf { get; set; }
#region >扩展字段<
public string Label { get; set; }
#endregion
public virtual ICollection<BranchRole> Roles { get; set; }
//public short CategoryId { get; set; }
//public Guid? Pid { get; set; }
//public string Name { get; set; }
//public string FullName { get; set; }
//public int Sort { get; set; }
//public bool Enabled { get; set; }
//public bool HasChildren { get; set; }
//public bool Leaf { get; set; }
//#region >扩展字段<
//public string Label { get; set; }
//#endregion
//public virtual ICollection<BranchRole> Roles { get; set; }
}
}

35
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/Dto/CreateOrUpdateBranchDto.cs

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using BaseService.RelationBaseData;
namespace BaseService.BaseData.BranchManagement.Dto
{/// <summary>
/// 分支DTO
/// </summary>
public class CreateOrUpdateBranchDto
{
public short CategoryId { get; set; }
/// <summary>
/// 子分支ID
/// </summary>
public Guid? Pid { get; set; }
/// <summary>
/// 分支名称
/// </summary>
[Required]
public string Name { get; set; }
/// <summary>
/// 分类
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 是否可用
/// </summary>
public bool Enabled { get; set; }
/// <summary>
/// 对应的角色列表
/// </summary>
public virtual ICollection<BranchRole> Roles { get; set; }
}
}

16
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/Dto/GetBranchInputDto.cs

@ -0,0 +1,16 @@
using System;
using Volo.Abp.Application.Dtos;
namespace BaseService.BaseData.BranchManagement.Dto
{
public class GetBranchInputDto : PagedAndSortedResultRequestDto
{
public Guid? Id { get; set; }
public string Filter { get; set; }
public short? CategoryId { get; set; }
public Guid? Pid { get; set; }
}
}

32
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/BranchManagement/IBranchAppService.cs

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BaseService.BaseData.BranchManagement.Dto;
using BaseService.RelationData.Dto;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
namespace BaseService.BaseData.BranchManagement
{
public interface IBranchAppService : IApplicationService
{
Task<PagedResultDto<BranchDto>> GetPagedListAsync(GetBranchInputDto input);
Task<ListResultDto<BranchDto>> GetAllAsync(Guid? id, string filter);
Task<ListResultDto<BranchDto>> GetChildrenAsync();
Task<BranchDto> GetAsync(Guid id);
Task<BranchDto> CreateAsync(CreateOrUpdateBranchDto input);
Task<BranchDto> UpdateAsync(Guid id, CreateOrUpdateBranchDto input);
Task DeleteAsync(List<Guid> ids);
Task<ListResultDto<BranchRoleDto>> GetRolesAsync(Guid branchId);
Task<PagedResultDto<IdentityRoleDto>> GetPagedRolesAsync(Guid branchId, PagedAndSortedResultRequestDto input);
}
}

17
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/Permissions/Dto/ApplicationAuthes.cs

@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace BaseService.BaseData.Permissions.Dto
{
public class ApplicationAuthes
{
public Dictionary<string, bool> Policies { get; set; }
public Dictionary<string, bool> GrantedPolicies { get; set; }
public ApplicationAuthes()
{
Policies = new Dictionary<string, bool>();
GrantedPolicies = new Dictionary<string, bool>();
}
}
}

30
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/Dto/CreateOrUpdateUserBranchDto.cs

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Volo.Abp.Identity;
namespace BaseService.BaseData.UserBranchRoleManagement.Dto
{
public class CreateOrUpdateUserBranchDto
{
/// <summary>
/// 主键
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// 分支ID
/// </summary>
public Guid BranchId { get; set; }
/// <summary>
/// 角色列表
/// </summary>
public virtual ICollection<UserBranchRole> Roles { get; set; } = new Collection<UserBranchRole>();
}
}

12
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/Dto/GetUserBranchInput.cs

@ -0,0 +1,12 @@
using System;
using Volo.Abp.Application.Dtos;
namespace BaseService.BaseData.UserBranchRoleManagement.Dto
{
public class GetUserBranchInput : PagedAndSortedResultRequestDto
{
public Guid? UserId { get; set; }
public Guid? BranchId { get; set; }
public string Filter { get; set; }
}
}

38
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/Dto/UserBranchDto.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace BaseService.BaseData.UserBranchRoleManagement.Dto
{
public class UserBranchDto : EntityDto<Guid>
{
/// <summary>
/// 用户ID
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// 用户名称
/// </summary>
[NotMapped]
public string UserName { get; set; }
/// <summary>
/// 分支ID
/// </summary>
public Guid BranchId { get; set; }
/// <summary>
/// 分支机构名称
/// </summary>
[NotMapped]
public string BranchName { get; set; }
public virtual ICollection<UserBranchRole> Roles { get; set; } = new Collection<UserBranchRole>();
}
}

48
src/Modules/BaseService/BaseService.Application.Contracts/BaseData/UserBranchRoleManagement/IUserBranchAppService.cs

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BaseService.BaseData.Permissions.Dto;
using BaseService.BaseData.UserBranchRoleManagement.Dto;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace BaseService.BaseData.UserBranchRoleManagement
{
/// <summary>
/// 用户--分支--角色
/// </summary>
public interface IUserBranchAppService : IApplicationService
{
Task<PagedResultDto<UserBranchDto>> GetPagedListAsync(GetUserBranchInput input);
Task<UserBranchDto> GetAsync(Guid id);
//Task<UserBranchDto> CreateAsync(CreateOrUpdateUserBranchDto input);
Task CreateUpdateAsync(CreateOrUpdateUserBranchDto input);
Task<UserBranchDto> UpdateAsync(Guid id, CreateOrUpdateUserBranchDto input);
Task DeleteAsync(List<Guid> ids);
Task<List<UserBranchDto>> GetUserBranchsAsync(Guid userId);
Task<List<UserBranchDto>> GetCurrentUserBranchesAsync();
Task<ApplicationAuthes> GetAuthConfigAsync(Guid branchId);
Task<List<UserBranchRole>> GetUserRolesAsync(Guid userId,Guid branchId);
Task DeleteUnitAsync(Guid userId, Guid branchId);
//Task<List<UserBranchRole>> GetBranchRolesAsync(Guid branchId);
List<UserBranchRole> GetBranchRolesAsync(Guid branchId);
//Task<List<UserBranchRole>> GetUserRolesAsync(Guid userId);
List<UserBranchRole> GetUserRolesAsync(Guid userId);
Task<UserBranchDto> GetCurrentUserBranchAsync(Guid userId);
Task DeleteUnitAsync(Guid userId);
}
}

20
src/Modules/BaseService/BaseService.Application.Contracts/BaseService.Application.Contracts.csproj

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>BaseService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Identity.Application.Contracts" Version="4.3.3" />
<PackageReference Include="Volo.Abp.PermissionManagement.Application.Contracts" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Settings" Version="4.3.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BaseService.Domain\BaseService.Domain.csproj" />
</ItemGroup>
</Project>

329
src/Modules/BaseService/BaseService.Application.Contracts/BaseService.Application.Contracts.xml

@ -0,0 +1,329 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>BaseService.Application.Contracts</name>
</assembly>
<members>
<member name="T:BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto">
<summary>
分支DTO
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto.Pid">
<summary>
子分支ID
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto.Name">
<summary>
分支名称
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto.Sort">
<summary>
分类
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto.Enabled">
<summary>
是否可用
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto.Roles">
<summary>
对应的角色列表
</summary>
</member>
<member name="T:BaseService.BaseData.BranchManagement.Dto.GetBranchInputDto">
<summary>
获取分支信息
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.GetBranchInputDto.Id">
<summary>
传入分支ID
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.GetBranchInputDto.Filter">
<summary>
过滤条件
</summary>
</member>
<member name="P:BaseService.BaseData.BranchManagement.Dto.GetBranchInputDto.Pid">
<summary>
子分支ID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.CreateOrUpdateUserBranchRoleDto.Id">
<summary>
自身的GUID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.CreateOrUpdateUserBranchRoleDto.TenantId">
<summary>
租户
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.CreateOrUpdateUserBranchRoleDto.UserId">
<summary>
用户ID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.CreateOrUpdateUserBranchRoleDto.BranchId">
<summary>
分支ID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.CreateOrUpdateUserBranchRoleDto.RoleId">
<summary>
角色ID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.UserBranchRoleDto.TenantId">
<summary>
租户
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.UserBranchRoleDto.UserId">
<summary>
用户ID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.UserBranchRoleDto.UserIdToName">
<summary>
用户名称
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.UserBranchRoleDto.BranchId">
<summary>
分支ID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.UserBranchRoleDto.BranchIdToName">
<summary>
分支机构名称
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.UserBranchRoleDto.RoleId">
<summary>
角色ID
</summary>
</member>
<member name="P:BaseService.BaseData.UserBranchRoleManagement.Dto.UserBranchRoleDto.RoleIdToName">
<summary>
角色名称
</summary>
</member>
<member name="T:BaseService.BaseData.UserBranchRoleManagement.IUserBranchRoleAppService">
<summary>
用户--分支--角色
</summary>
</member>
<member name="P:BaseService.RelationBaseData.BranchAndRole.Dto.MyBranchUnitRoleDto.TenantId">
<summary>
TenantId of this entity.
</summary>
</member>
<member name="P:BaseService.RelationBaseData.BranchAndRole.Dto.MyBranchUnitRoleDto.RoleId">
<summary>
Id of the Role.
</summary>
</member>
<member name="P:BaseService.RelationBaseData.BranchAndRole.Dto.MyBranchUnitRoleDto.BranchUnitId">
<summary>
Id of the <see cref="!:BranchUnit"/>.
</summary>
</member>
<member name="P:BaseService.RelationBaseData.BranchAndRole.Dto.BranchUnitPermissionDto.BranchId">
<summary>
分支ID
</summary>
</member>
<member name="P:BaseService.RelationBaseData.BranchAndRole.Dto.BranchUnitPermissionDto.BranchIdToName">
<summary>
分支机构名称
</summary>
</member>
<member name="P:BaseService.RelationBaseData.BranchAndRole.Dto.BranchUnitPermissionDto.PermissName">
<summary>
权限名称
</summary>
</member>
<member name="P:BaseService.RelationBaseData.BranchAndRole.Dto.BranchUnitPermissionDto.ProviderKey">
<summary>
角色名称
</summary>
</member>
<member name="T:BaseService.RelationData.IBranchRelationAppService">
<summary>
分支接口:无权限设置调用
</summary>
</member>
<member name="M:BaseService.RelationData.IBranchRelationAppService.GetAll(BaseService.BaseData.BranchManagement.Dto.GetBranchInputDto)">
<summary>
获取所有分支
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IBranchRelationAppService.LoadAll(System.Nullable{System.Guid},System.String)">
<summary>
加载所有分支
</summary>
<param name="id"></param>
<param name="filter"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IBranchRelationAppService.LoadAllNodes">
<summary>
加载所有分支子节点
</summary>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IBranchRelationAppService.Get(System.Guid)">
<summary>
获取单条分支信息
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IBranchRelationAppService.Create(BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto)">
<summary>
创建分支信息
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IBranchRelationAppService.Update(System.Guid,BaseService.BaseData.BranchManagement.Dto.CreateOrUpdateBranchDto)">
<summary>
更新分支信息
</summary>
<param name="id"></param>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IBranchRelationAppService.Delete(System.Collections.Generic.List{System.Guid})">
<summary>
删除分支信息
</summary>
<param name="ids"></param>
<returns></returns>
</member>
<member name="T:BaseService.RelationData.IUserRelationAppService">
<summary>
用户信息:无权限设置
</summary>
</member>
<member name="M:BaseService.RelationData.IUserRelationAppService.Get(System.Guid)">
<summary>
根据ID获取单条信息
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IUserRelationAppService.GetCurrentUserInfo">
<summary>
获取当前登录用户信息
</summary>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IUserRelationAppService.GetAll(Volo.Abp.Identity.GetIdentityUsersInput)">
<summary>
获取所有用户信息
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IUserRelationAppService.LoadAllBranchesByUserId(System.Guid)">
<summary>
根据分支ID获取用户信息
</summary>
<param name="rolesbyuserId"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IUserRelationAppService.GetAuthConfigAsync(System.Guid)">
<summary>
获取权限列表信息
</summary>
<param name="branchId"></param>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IUserRelationAppService.LoadAllCurrentUserBranches">
<summary>
获取当前登录用户的所有分支信息
</summary>
<returns></returns>
</member>
<member name="M:BaseService.RelationData.IUserRelationAppService.ResetPasswordCurrentUser(System.Guid)">
<summary>
重置当前登录用户的密码
</summary>
<param name="id"></param>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.Get(System.Guid)">
<summary>
根据ID获取单条信息
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.GetCurrentUserInfo">
<summary>
获取当前登录用户信息
</summary>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.Create(Volo.Abp.Identity.IdentityUserCreateDto)">
<summary>
创建用户
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.UpdateAsync(System.Guid,Volo.Abp.Identity.IdentityUserUpdateDto)">
<summary>
更新用户信息
</summary>
<param name="id"></param>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.GetAll(Volo.Abp.Identity.GetIdentityUsersInput)">
<summary>
获取所有用户信息
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.LoadAllBranchesByUserId(System.Guid)">
<summary>
根据分支ID获取用户信息
</summary>
<param name="rolesbyuserId"></param>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.GetAuthConfigAsync(System.Guid)">
<summary>
获取权限列表信息
</summary>
<param name="branchId"></param>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.LoadAllCurrentUserBranches">
<summary>
获取当前登录用户的所有分支信息
</summary>
<returns></returns>
</member>
<member name="M:BaseService.Systems.UserManagement.IUserAppService.ResetPasswordCurrentUser(System.Guid)">
<summary>
重置当前登录用户的密码
</summary>
<param name="id"></param>
<param name="input"></param>
<returns></returns>
</member>
</members>
</doc>

15
src/Modules/BaseService/BaseService.Application.Contracts/BaseServiceApplicationContractsModule.cs

@ -0,0 +1,15 @@
using Volo.Abp.Application;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
namespace BaseService
{
[DependsOn(
typeof(BaseServiceDomainModule),
typeof(AbpDddApplicationModule),
typeof(AbpPermissionManagementApplicationContractsModule)
)]
public class BaseServiceApplicationContractsModule : AbpModule
{
}
}

35
src/Modules/BaseService/BaseService.Application.Contracts/Permissions/BaseServicePermissionDefinitionProvider .cs

@ -0,0 +1,35 @@
using BaseService.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
namespace BaseService.Permissions
{
public class BaseServicePermissionDefinitionProvider : PermissionDefinitionProvider
{
public override void Define(IPermissionDefinitionContext context)
{
var baseService = context.AddGroup(BaseServicePermissions.BaseService, L("BaseService"), MultiTenancySides.Tenant);
var auditLogging = baseService.AddPermission(BaseServicePermissions.AuditLogging.Default, L("AuditLogging"));
var branch = baseService.AddPermission(BaseServicePermissions.Branch.Default,L("Branch"));
branch.AddChild(BaseServicePermissions.Branch.Update, L("Edit"));
branch.AddChild(BaseServicePermissions.Branch.Delete, L("Delete"));
branch.AddChild(BaseServicePermissions.Branch.Create, L("Create"));
var userBranch = baseService.AddPermission(BaseServicePermissions.UserBranch.Default, L("UserBranch"));
userBranch.AddChild(BaseServicePermissions.UserBranch.Update, L("Edit"));
userBranch.AddChild(BaseServicePermissions.UserBranch.Delete, L("Delete"));
userBranch.AddChild(BaseServicePermissions.UserBranch.Create, L("Create"));
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<BaseServiceResource>(name);
}
}
}

34
src/Modules/BaseService/BaseService.Application.Contracts/Permissions/BaseServicePermissions.cs

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BaseService.Permissions
{
public static class BaseServicePermissions
{
public const string BaseService = "BaseService";
public static class AuditLogging
{
public const string Default = BaseService + ".AuditLogging";
}
public static class Branch
{
public const string Default = BaseService + ".Branch";
public const string Delete = Default + ".Delete";
public const string Update = Default + ".Update";
public const string Create = Default + ".Create";
}
public static class UserBranch
{
public const string Default = BaseService + ".UserBranch";
public const string Delete = Default + ".Delete";
public const string Update = Default + ".Update";
public const string Create = Default + ".Create";
}
}
}

28
src/Modules/BaseService/BaseService.Application.Contracts/RelationData/Dto/BranchPermissionDto.cs

@ -0,0 +1,28 @@
using System;
namespace BaseService.RelationData.Dto
{
public class BranchPermissionDto
{
/// <summary>
/// 分支ID
/// </summary>
public Guid BranchId { get; set; }
/// <summary>
/// 分支机构名称
/// </summary>
public string BranchIdToName { get; set; }
/// <summary>
/// 权限名称
/// </summary>
public string PermissName { get; set; }
/// <summary>
/// 角色名称
/// </summary>
public string ProviderKey { get; set; }
}
}

30
src/Modules/BaseService/BaseService.Application.Contracts/RelationData/Dto/BranchRoleDto.cs

@ -0,0 +1,30 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace BaseService.RelationData.Dto
{
public class BranchRoleDto : CreationAuditedEntity
{
/// <summary>
/// Id of the Role.
/// </summary>
public Guid RoleId { get; set; }
public string RoleName { get; set; }
/// <summary>
/// Id of the <see cref="Branch"/>.
/// </summary>
public Guid BranchId { get; set; }
public string BranchName { get; set; }
public override object[] GetKeys()
{
return new object[] { BranchId, RoleId };
}
}
}

67
src/Modules/BaseService/BaseService.Application.Contracts/RelationData/IBranchRelationAppService.cs

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using BaseService.BaseData.BranchManagement.Dto;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
namespace BaseService.RelationData
{
/// <summary>
/// 分支接口:无权限设置调用
/// </summary>
public interface IBranchRelationAppService : IApplicationService
{
/// <summary>
/// 获取所有分支
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<PagedResultDto<BranchDto>> GetPagedAsync(GetBranchInputDto input);
/// <summary>
/// 加载所有分支
/// </summary>
/// <param name="id"></param>
/// <param name="filter"></param>
/// <returns></returns>
Task<ListResultDto<BranchDto>> GetChildrenAsync(Guid? id, string filter);
/// <summary>
/// 加载所有分支子节点
/// </summary>
/// <returns></returns>
Task<ListResultDto<BranchDto>> GetAllAsync();
/// <summary>
/// 获取单条分支信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<BranchDto> GetAsync(Guid id);
/// <summary>
/// 创建分支信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<BranchDto> CreateAsync(CreateOrUpdateBranchDto input);
/// <summary>
/// 更新分支信息
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
Task<BranchDto> UpdateAsync(Guid id, CreateOrUpdateBranchDto input);
/// <summary>
/// 删除分支信息
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task DeleteAsync(List<Guid> ids);
}
}

25
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/AuditLogActionDto.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace BaseService.Systems.AuditLoggingManagement.Dto
{
public class AuditLogActionDto : EntityDto<Guid>
{
public Guid? TenantId { get; set; }
public Guid AuditLogId { get; set; }
public string ServiceName { get; set; }
public string MethodName { get; set; }
public string Parameters { get; set; }
public DateTime ExecutionTime { get; set; }
public int ExecutionDuration { get; set; }
public Dictionary<string, object> ExtraProperties { get; set; }
}
}

53
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/AuditLogDto.cs

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Volo.Abp.Application.Dtos;
namespace BaseService.Systems.AuditLoggingManagement.Dto
{
public class AuditLogDto : EntityDto<Guid>
{
public virtual string ApplicationName { get; set; }
public virtual Guid? UserId { get; set; }
public virtual string UserName { get; set; }
public virtual Guid? TenantId { get; set; }
public virtual string TenantName { get; set; }
public virtual Guid? ImpersonatorUserId { get; set; }
public virtual Guid? ImpersonatorTenantId { get; set; }
public virtual DateTime ExecutionTime { get; set; }
public virtual int ExecutionDuration { get; set; }
public virtual string ClientIpAddress { get; set; }
public virtual string ClientName { get; set; }
public virtual string ClientId { get; set; }
public virtual string CorrelationId { get; set; }
public virtual string BrowserInfo { get; set; }
public virtual string HttpMethod { get; set; }
public virtual string Url { get; set; }
public virtual string Exceptions { get; set; }
public virtual string Comments { get; set; }
public virtual int? HttpStatusCode { get; set; }
public virtual Dictionary<string, object> ExtraProperties { get; set; }
public virtual Collection<EntityChangeDto> EntityChanges { get; protected set; }
public virtual Collection<AuditLogActionDto> Actions { get; protected set; }
}
}

29
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/EntityChangeDto.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Auditing;
namespace BaseService.Systems.AuditLoggingManagement.Dto
{
public class EntityChangeDto : EntityDto<Guid>
{
public Guid AuditLogId { get; set; }
public Guid? TenantId { get; set; }
public DateTime ChangeTime { get; set; }
public EntityChangeType ChangeType { get; set; }
public Guid? EntityTenantId { get; set; }
public string EntityId { get; set; }
public string EntityTypeFullName { get; set; }
public Collection<EntityPropertyChangeDto> PropertyChanges { get; set; }
public Dictionary<string, object> ExtraProperties { get; set; }
}
}

20
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/EntityPropertyChangeDto.cs

@ -0,0 +1,20 @@
using System;
using Volo.Abp.Application.Dtos;
namespace BaseService.Systems.AuditLoggingManagement.Dto
{
public class EntityPropertyChangeDto : EntityDto<Guid>
{
public Guid? TenantId { get; set; }
public Guid EntityChangeId { get; set; }
public string NewValue { get; set; }
public string OriginalValue { get; set; }
public string PropertyName { get; set; }
public string PropertyTypeFullName { get; set; }
}
}

28
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/GetAuditLogsInput.cs

@ -0,0 +1,28 @@
using System.Net;
using Volo.Abp.Application.Dtos;
namespace BaseService.Systems.AuditLoggingManagement.Dto
{
public class GetAuditLogsInput : PagedResultRequestDto, IPagedAndSortedResultRequest, IPagedResultRequest, ILimitedResultRequest
{
public string Sorting { get; set; }
public string Url { get; set; }
public string UserName { get; set; }
public string ApplicationName { get; set; }
public string CorrelationId { get; set; }
public string HttpMethod { get; set; }
public HttpStatusCode? HttpStatusCode { get; set; }
public int? MaxExecutionDuration { get; set; }
public int? MinExecutionDuration { get; set; }
public bool HasException { get; set; }
}
}

11
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/GetAverageExecutionDurationPerDayInput.cs

@ -0,0 +1,11 @@
using System;
namespace BaseService.Systems.AuditLoggingManagement.Dto
{
public class GetAverageExecutionDurationPerDayInput
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
}

10
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/Dto/GetAverageExecutionDurationPerDayOutput.cs

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
namespace BaseService.Systems.AuditLoggingManagement.Dto
{
public class GetAverageExecutionDurationPerDayOutput
{
public Dictionary<DateTime, double> Data { get; set; }
}
}

19
src/Modules/BaseService/BaseService.Application.Contracts/Systems/AuditLoggingManagement/IAuditLoggingAppService.cs

@ -0,0 +1,19 @@
using BaseService.Systems.AuditLoggingManagement.Dto;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace BaseService.Systems.AuditLoggingManagement
{
public interface IAuditLoggingAppService : IApplicationService
{
Task<AuditLogDto> Get(Guid id);
Task<PagedResultDto<AuditLogDto>> GetAll(GetAuditLogsInput input);
Task<GetAverageExecutionDurationPerDayOutput> GetAverageExecutionDurationPerDay(GetAverageExecutionDurationPerDayInput input);
}
}

75
src/Modules/BaseService/BaseService.Application.Contracts/Systems/UserManagement/IUserAppService.cs

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using BaseService.BaseData.Permissions.Dto;
using BaseService.RelationData.Dto;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
namespace BaseService.Systems.UserManagement
{
public interface IUserAppService : IApplicationService
{
/// <summary>
/// 根据ID获取单条信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<IdentityUserDto> GetAsync(Guid id);
/// <summary>
/// 获取当前登录用户信息
/// </summary>
/// <returns></returns>
Task<IdentityUserDto> GetCurrentUserAsync();
/// <summary>
/// 创建用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input);
/// <summary>
/// 更新用户信息
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input);
/// <summary>
/// 获取所有用户信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<PagedResultDto<IdentityUserDto>> GetAll(GetIdentityUsersInput input);
/// <summary>
/// 根据分支ID获取用户信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
Task<ListResultDto<BranchRoleDto>> GetUserBranchesAsync(Guid userId);
/// <summary>
/// 获取权限列表信息
/// </summary>
/// <param name="branchId"></param>
/// <returns></returns>
Task<ApplicationAuthes> GetAuthConfigAsync(Guid branchId);
/// <summary>
/// 重置当前登录用户的密码
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
//Task<IdentityUserDto> ResetPasswordCurrentUser(Guid id, IdentityUserCreateDto input);
Task<IdentityUserDto> ResetPasswordAsync(Guid id);
}
}

23
src/Modules/BaseService/BaseService.Application/BaseService.Application.csproj

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>BaseService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Identity.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Settings" Version="4.3.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Shared\Win.Sfs.Shared\Win.Sfs.Shared.csproj" />
<ProjectReference Include="..\..\..\Shared\Win.Utils\Win.Utils.csproj" />
<ProjectReference Include="..\BaseService.Application.Contracts\BaseService.Application.Contracts.csproj" />
</ItemGroup>
</Project>

29
src/Modules/BaseService/BaseService.Application/BaseServiceApplicationAutoMapperProfile.cs

@ -0,0 +1,29 @@
using AutoMapper;
using BaseService.BaseData;
using BaseService.RelationBaseData;
using BaseService.Systems.AuditLoggingManagement.Dto;
using System;
using System.Collections.Generic;
using System.Text;
using BaseService.BaseData.BranchManagement.Dto;
using BaseService.BaseData.UserBranchRoleManagement.Dto;
using BaseService.RelationData.Dto;
namespace BaseService
{
public class BaseServiceApplicationAutoMapperProfile : Profile
{
public BaseServiceApplicationAutoMapperProfile()
{
CreateMap<Branch, BranchDto>()
.ForMember(dto => dto.Label, opt => opt.MapFrom(src => src.Name));
//用户--分支
CreateMap<UserBranch, UserBranchDto>();
//分支--角色
CreateMap<BranchRole, BranchRoleDto>();
}
}
}

33
src/Modules/BaseService/BaseService.Application/BaseServiceApplicationModule.cs

@ -0,0 +1,33 @@
using Volo.Abp.AutoMapper;
using Volo.Abp.Identity;
using Volo.Abp.Json;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
namespace BaseService
{
[DependsOn(
typeof(BaseServiceApplicationContractsModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpAutoMapperModule)
)]
public class BaseServiceApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<BaseServiceApplicationAutoMapperProfile>();
});
}
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<AbpJsonOptions>(option =>
{
option.UseHybridSerializer = false;
});
}
}
}

314
src/Modules/BaseService/BaseService.Application/BranchManagement/BranchAppService.cs

@ -0,0 +1,314 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using BaseService.BaseData.BranchManagement.Dto;
using BaseService.BaseData.UserBranchRoleManagement.Dto;
using BaseService.Permissions;
using BaseService.RelationBaseData;
using BaseService.RelationData.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Win.Sfs.Shared.CacheBase;
namespace BaseService.BaseData.BranchManagement
{
[Route("api/base/branch")]
[Authorize(BaseServicePermissions.Branch.Default)]
public class BranchAppService : ApplicationService, IBranchAppService
{
private readonly IRepository<Branch, Guid> _repository;
private readonly IRepository<UserBranch> _repositoryBranchRole;
public IIdentityRoleRepository RoleRepository { get; }
private readonly IDistributedCache<Branch> _cache;
public BranchAppService(IRepository<Branch, Guid> repository,
IRepository<UserBranch> repositoryBranchRole,
IDistributedCache<Branch> cache,
IIdentityRoleRepository roleRepository)
{
_repository = repository;
_repositoryBranchRole = repositoryBranchRole;
RoleRepository = roleRepository;
_cache = cache;
}
[HttpPost]
[Authorize(BaseServicePermissions.Branch.Create)]
public virtual async Task<BranchDto> CreateAsync(CreateOrUpdateBranchDto input)
{
var exist = await _repository.FirstOrDefaultAsync(_ => _.Name == input.Name);
if (exist != null) throw new BusinessException("名称:" + input.Name + "机构已存在");
var branch = new Branch(GuidGenerator.Create(),
CurrentTenant.Id,
input.CategoryId,
input.Pid,
input.Name,
"",
input.Sort,
true,
input.Enabled
);
var parent = await _repository.FirstOrDefaultAsync(_ => _.Id == input.Pid);
ChangeOrganizationModel(branch, parent);
await _repository.InsertAsync(branch);
//create cache
await _cache.SetAsync(branch.Id.ToString(), branch, CacheStrategyConst.FIVE_MINUTES);
return ObjectMapper.Map<Branch, BranchDto>(branch);
}
[HttpPost]
[Route("delete")]
[Authorize(BaseServicePermissions.Branch.Delete)]
public virtual async Task DeleteAsync(List<Guid> ids)
{
foreach (var id in ids)
{
var branch = await _repository.GetAsync(id);
await _repository.DeleteAsync(_ => _.CascadeId.Contains(branch.CascadeId));
await _cache.DeleteAsync(id.ToString());
await _repository.DeleteAsync(_ => _.Id == id);
}
}
[HttpGet]
[Route("{id}")]
[AllowAnonymous]
public virtual async Task<BranchDto> GetAsync(Guid id)
{
var result = await GetFromCacheAsync(id);
return ObjectMapper.Map<Branch, BranchDto>(result);
}
protected virtual async Task<Branch> GetFromCacheAsync(Guid id)
{
var result = await _cache.GetOrAddAsync(
id.ToString(),
async () => await GetFromRepository(id),
CacheStrategyConst.FIVE_MINUTES);
return result;
}
private async Task<Branch> GetFromRepository(Guid id)
{
return await _repository.GetAsync(id);
}
[HttpGet]
[Route("paged")]
public virtual async Task<PagedResultDto<BranchDto>> GetPagedListAsync(GetBranchInputDto input)
{
var query = _repository
.WhereIf(!string.IsNullOrWhiteSpace(input.Filter), _ => _.Name.Contains(input.Filter))
.WhereIf(input.CategoryId.HasValue, _ => _.CategoryId == input.CategoryId);
if (input.Id.HasValue)
{
var org = await _repository.GetAsync(input.Id.Value);
query = query.Where(_ => _.CascadeId.Contains(org.CascadeId));
}
var items = await query.OrderBy(input.Sorting ?? "Sort")
.Skip(input.SkipCount)
.Take(input.MaxResultCount)
.ToListAsync();
var totalCount = await query.CountAsync();
var dtos = ObjectMapper.Map<List<Branch>, List<BranchDto>>(items);
return new PagedResultDto<BranchDto>(totalCount, dtos);
//var query = _repository
// .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), _ => _.Name.Contains(input.Filter))
// .WhereIf(input.CategoryId.HasValue, _ => _.CategoryId == input.CategoryId);
//var items = await query.OrderBy(input.Sorting ?? "Sort")
// .Skip(input.SkipCount)
// .Take(input.MaxResultCount)
// .ToListAsync();
//var totalCount = await query.CountAsync();
//var dtos = ObjectMapper.Map<List<Branch>, List<BranchDto>>(items);
//return new PagedResultDto<BranchDto>(totalCount, dtos);
}
[HttpGet]
[Route("all")]
public virtual async Task<ListResultDto<BranchDto>> GetAllAsync(Guid? id, string filter)
{
var items = new List<Branch>();
if (!string.IsNullOrWhiteSpace(filter))
{
items = await _repository.Where(_ => _.Name.Contains(filter)).ToListAsync();
}
else
{
var query = id.HasValue ? _repository.Where(_ => _.Pid == id) :
_repository.Where(_ => _.Pid == null);
items = await query.ToListAsync();
}
var dtos = ObjectMapper.Map<List<Branch>, List<BranchDto>>(items);
return new ListResultDto<BranchDto>(dtos);
}
[HttpGet]
[Route("children")]
public virtual async Task<ListResultDto<BranchDto>> GetChildrenAsync()
{
var items = await _repository.GetListAsync();
var dtos = ObjectMapper.Map<List<Branch>, List<BranchDto>>(items);
return new ListResultDto<BranchDto>(dtos);
}
[HttpPut]
[Route("{id}")]
[Authorize(BaseServicePermissions.Branch.Update)]
public virtual async Task<BranchDto> UpdateAsync(Guid id, CreateOrUpdateBranchDto input)
{
if (input.Pid == id) throw new BusinessException("机构上级不能为当前机构!");
var branch = await _repository.FirstOrDefaultAsync(_ => _.Id == id);
if (branch.Pid != input.Pid)
{
var parent = await _repository.FirstOrDefaultAsync(_ => _.Id == input.Pid);
var orgs = await _repository.Where(_ => _.CascadeId.Contains(branch.CascadeId) && _.Id != branch.Id)
.OrderBy(_ => _.CascadeId).ToListAsync();
branch.Pid = input.Pid;
ChangeOrganizationModel(branch, parent);
foreach (var org in orgs)
{
if (org.Pid == branch.Id)
{
ChangeOrganizationModel(org, branch, false);
}
else
{
var orgParent = orgs.FirstOrDefault(_ => _.Id == org.Pid);
ChangeOrganizationModel(org, orgParent, false);
}
}
}
branch.Name = input.Name;
branch.Sort = input.Sort;
branch.Enabled = input.Enabled;
await _cache.SetAsync(id.ToString(), branch, CacheStrategyConst.FIVE_MINUTES);
return ObjectMapper.Map<Branch, BranchDto>(branch);
}
private void ChangeOrganizationModel(Branch org, Branch parent, bool checkLevel = true)
{
var cascadeId = org.CascadeId == null ? 1 : int.Parse(org.CascadeId.TrimEnd('.').Split('.').Last());
if (checkLevel)
{
if (parent != null && parent.Leaf) parent.Leaf = false;
var lastLevel = _repository.Where(_ => _.Pid == org.Pid && _.Id != org.Id)
.OrderByDescending(_ => _.CascadeId)
.FirstOrDefault();
cascadeId = lastLevel == null ? 1 : int.Parse(lastLevel.CascadeId.TrimEnd('.').Split('.').Last()) + 1;
}
if (org.Pid.HasValue)
{
if (parent == null) throw new BusinessException("上级机构查询错误!");
org.CascadeId = parent.CascadeId + cascadeId + ".";
org.FullName = parent.FullName + "/" + org.Name;
}
else
{
org.CascadeId = ".0." + cascadeId + ".";
org.FullName = org.Name;
}
}
/// <summary>
/// 根据分支ID,查找中间表branch-role
/// </summary>
/// <param name="branchId"></param>
/// <returns></returns>
[HttpGet]
[Route("{branchId}/roles")]
public virtual async Task<ListResultDto<BranchRoleDto>> GetRolesAsync(Guid branchId)
{
var dtos = new List<BranchRoleDto>();
var getRoleIds = await GetRolesByBranchIdAsync(branchId);
var roles = await RoleRepository.GetListAsync();
if (getRoleIds != null)
{
foreach (var role in getRoleIds)
{
dtos.Add(new BranchRoleDto() { RoleId = role.RoleId, RoleName = roles.FirstOrDefault(p => p.Id == role.RoleId)?.Name });
}
}
return new ListResultDto<BranchRoleDto>(dtos);
}
protected virtual async Task<List<UserBranchRole>> GetRolesByBranchIdAsync(Guid branchId)
{
var userBranch = await _repositoryBranchRole.GetAsync(_ => _.BranchId == branchId);
var roles = userBranch.Roles.ToList();
return roles;
}
/// <summary>
/// 用于角色管理:分支和角色互动
/// </summary>
/// <param name="branchId"></param>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[Route("paged-roles/{branchId}")]
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetPagedRolesAsync(Guid branchId, PagedAndSortedResultRequestDto input)
{
var listRoles = new List<IdentityRole>();
var getRoleIds = GetUserRolesAsync(branchId);
if (getRoleIds == null)
{
throw new BusinessException("未找到分支和角色的关联信息!");
}
else
{
var list = await RoleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount);
foreach (var roleid in getRoleIds)
{
var filterRole = list.FirstOrDefault(_ => _.Id == roleid.RoleId);
listRoles.Add(filterRole);
}
}
var totalCount = listRoles.Count;
return new PagedResultDto<IdentityRoleDto>(
totalCount,
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(listRoles)
);
}
protected virtual List<UserBranchRole> GetUserRolesAsync(Guid branchId)
{
var dtos = new List<UserBranchRole>();
var isInRole = _repositoryBranchRole.Where(_ => _.BranchId == branchId);
if (isInRole != null)
{
foreach (var userRoles in isInRole)
{
foreach (var role in userRoles.Roles)
{
dtos.Add(new UserBranchRole() { RoleId = role.RoleId });
}
}
}
return dtos;
}
}
}

413
src/Modules/BaseService/BaseService.Application/UserManagement/UserAppService.cs

@ -0,0 +1,413 @@
using BaseService.BaseData;
using BaseService.Permissions;
using BaseService.RelationBaseData;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BaseService.BaseData.Permissions.Dto;
using BaseService.RelationData.Dto;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Authorization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Users;
using IdentityUser = Volo.Abp.Identity.IdentityUser;
namespace BaseService.Systems.UserManagement
{
[Route("api/base/user")]
[Authorize(IdentityPermissions.Users.Default)]
public class UserAppService : ApplicationService, IUserAppService
{
protected IdentityUserManager UserManager { get; }
protected IIdentityUserRepository UserRepository { get; }
public IIdentityRoleRepository RoleRepository { get; }
private readonly IRepository<Branch, Guid> _branchRepository;
private readonly IRepository<BranchRole> _branchRoleRepository;
//权限提供者类
private readonly IAbpAuthorizationPolicyProvider _abpAuthorizationPolicyProvider;
private readonly IAuthorizationService _authorizationService;
protected ICurrentUser CurrentUsers { get; }
/// <summary>
/// 权限列表
/// </summary>
protected IPermissionGrantRepository PermissionGrantRepository { get; }
public UserAppService(
IdentityUserManager userManager,
IIdentityUserRepository userRepository,
IIdentityRoleRepository roleRepository,
IRepository<Branch, Guid> branchRepository,
IRepository<BranchRole> branchRoleRepository,
IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider,
IAuthorizationService authorizationService,
ICurrentUser currentUser,
IPermissionGrantRepository permissionGrantRepository)
{
UserManager = userManager;
UserRepository = userRepository;
RoleRepository = roleRepository;
_branchRepository = branchRepository;
_abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider;
_authorizationService = authorizationService;
CurrentUsers = currentUser;
PermissionGrantRepository = permissionGrantRepository;
_branchRoleRepository = branchRoleRepository;
}
[HttpGet]
[Route("{id}")]
public async Task<IdentityUserDto> GetAsync(Guid id)
{
var dto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(await UserManager.GetByIdAsync(id));
return dto;
}
/// <summary>
/// 获取当前登录用户信息
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("current")]
[AllowAnonymous]
public async Task<IdentityUserDto> GetCurrentUserAsync()
{
var id = CurrentUser.GetId();
var currentUser = await UserManager.GetByIdAsync(id);
var dto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(currentUser);
return dto;
}
[HttpPost]
[Authorize(IdentityPermissions.Users.Create)]
public async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
{
var user = new IdentityUser(
GuidGenerator.Create(),
input.UserName,
input.Email,
CurrentTenant.Id
);
input.MapExtraPropertiesTo(user);
(await UserManager.CreateAsync(user, input.Password)).CheckErrors();
await UpdateAsync(user, input);
var dto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
await CurrentUnitOfWork.SaveChangesAsync();
return dto;
}
[HttpPut]
[Route("{id}")]
[Authorize(IdentityPermissions.Users.Update)]
public async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
{
var user = await UserManager.GetByIdAsync(id);
user.ConcurrencyStamp = input.ConcurrencyStamp;
(await UserManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
await UpdateAsync(user, input);
input.MapExtraPropertiesTo(user);
(await UserManager.UpdateAsync(user)).CheckErrors();
if (!input.Password.IsNullOrEmpty())
{
(await UserManager.RemovePasswordAsync(user)).CheckErrors();
(await UserManager.AddPasswordAsync(user, input.Password)).CheckErrors();
}
var dto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
await CurrentUnitOfWork.SaveChangesAsync();
return dto;
}
[HttpGet]
public async Task<PagedResultDto<IdentityUserDto>> GetAll(GetIdentityUsersInput input)
{
var totalCount = await UserRepository.GetCountAsync(input.Filter);
var items = await UserRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount,
input.Filter);
var dtos = ObjectMapper.Map<List<IdentityUser>, List<IdentityUserDto>>(items);
return new PagedResultDto<IdentityUserDto>(totalCount, dtos);
}
[HttpGet]
[Route("update")]
protected virtual async Task UpdateAsync(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input)
{
if (!string.Equals(user.Email, input.Email, StringComparison.InvariantCultureIgnoreCase))
{
(await UserManager.SetEmailAsync(user, input.Email)).CheckErrors();
}
if (!string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase))
{
(await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
}
//说明:从3.1升级到3.3后,去掉了TwoFactorEnabled属性
//(await UserManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled)).CheckErrors();
(await UserManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors();
user.Name = input.Name;
user.Surname = input.Surname;
if (input.RoleNames != null)
{
(await UserManager.SetRolesAsync(user, input.RoleNames)).CheckErrors();
}
}
/// <summary>
/// 获取当前登录用户的分支信息,绑定分支下拉列表项
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("current/branches")]
[AllowAnonymous]
public async Task<List<BranchRoleDto>> GetCurrentUserBranchesAsync()
{
var branchList = new List<BranchRoleDto>();
//获取用户的所有分支
var branchRoles = await GetUserBranchRolesAsync(CurrentUsers.GetId());
var groupBranchRoles = branchRoles.GroupBy(x => x.BranchId)
.Select(y => new {xx = new {BranchId = y.Key}, items = y});
foreach (var group in groupBranchRoles
)
{
var mybranchrole = new BranchRoleDto
{
BranchId = @group.xx.BranchId,
BranchName = (await _branchRepository.GetListAsync())
.FirstOrDefault(_ => _.Id == @group.xx.BranchId)?.Name
};
branchList.Add(mybranchrole);
}
return branchList;
}
/// <summary>
/// 根据用户ID,查所有该用户的分支(供用户管理用)
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
[Route("{userId}/branches")]
public async Task<ListResultDto<BranchRoleDto>> GetUserBranchesAsync(Guid userId)
{
var branchList = new List<BranchRoleDto>();
//获取用户的所有分支
var branchRoles = await GetUserBranchRolesAsync(userId);
var groupBranchRoles = branchRoles.GroupBy(x => x.BranchId)
.Select(y => new {xx = new {BranchId = y.Key}, items = y});
foreach (var group in groupBranchRoles)
{
var mybranchrole = new BranchRoleDto
{
BranchId = @group.xx.BranchId,
BranchName = (await _branchRepository.GetListAsync())
.FirstOrDefault(_ => _.Id == @group.xx.BranchId)
.Name
};
branchList.Add(mybranchrole);
}
return new ListResultDto<BranchRoleDto>(branchList);
}
/// <summary>
/// 根据用户ID,获取当前登录用户的所有权限信息,带角色名称
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("{userId}/granted-permissions")]
protected virtual async Task<List<PermissionGrant>> GetUserGrantedPermissionsAsync(Guid userId)
{
// var userRoleNames = (await AppService.GetRolesAsync(id)).Items.Select(r => r.Name).ToList();
var listPermiss = new List<PermissionGrant>();
var listRolesName = await UserRepository.GetRoleNamesAsync(userId);
if (listRolesName != null)
{
foreach (var rolename in listRolesName)
{
var permissionGrantsInRole = await PermissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, rolename);
if (permissionGrantsInRole != null)
{
foreach (var permiss in permissionGrantsInRole)
{
listPermiss.Add(permiss);
}
}
}
}
return listPermiss;
}
/// <summary>
/// 获取当前用户的组织信息
/// </summary>
/// <param name="uid"></param>
/// <returns></returns>
protected virtual async Task<List<BranchRoleDto>> GetUserBranchRolesAsync(Guid userId)
{
var branchList = new List<BranchRole>();
//获取当前用户的所有角色
var userRoles = await UserRepository.GetRolesAsync(userId);
if (userRoles == null)
{
throw new BusinessException("当前登录用户没有任何角色信息,请找管理员进行维护!");
}
else
{
//获取所有分支-角色的信息
var allBranchRoles = await _branchRoleRepository.GetListAsync();
if (allBranchRoles != null)
{
foreach (var role in userRoles)
{
var branchRoles = allBranchRoles.Where(_ => _.RoleId == role.Id).ToList();
foreach (var branch in branchRoles)
{
if (branch == null)
continue; //该用户没有角色-分支信息
var branchRole = new BranchRole(branch.BranchId, role.Id);
branchList.Add(branchRole);
}
}
}
else
{
// Logger.LogDebug("未找到分支和角色的关联信息!");
throw new BusinessException("未找到分支和角色的关联信息!");
}
}
var dtos = ObjectMapper.Map<List<BranchRole>, List<BranchRoleDto>>(branchList);
return new List<BranchRoleDto>(dtos);
}
/// <summary>
/// 重要:根据分支ID,过滤当前登录用户的权限信息
/// </summary>
/// <param name="branchId"></param>
/// <returns></returns>
[HttpGet]
[Route("{branchId}/auth-config")]
public async Task<ApplicationAuthes> GetAuthConfigAsync(Guid branchId)
{
var authConfig = new ApplicationAuthes();
var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync();
foreach (var policyName in policyNames)
{
authConfig.Policies[policyName] = true;
//if (await _authorizationService.IsGrantedAsync(policyName))
//{
// authConfig.GrantedPolicies[policyName] = true;
//}
}
var userPermissList = new List<BranchPermissionDto>();
var userId = CurrentUsers.GetId();
//获取当前用户的所有权限信息
var getUserPermissions = await GetUserGrantedPermissionsAsync(userId);
//获取当前用户的所有分支
var gerUserBranches = await GetUserBranchRolesAsync(userId);
if (gerUserBranches == null)
{
throw new BusinessException("当前登录用户没有任何分支信息,请找管理员进行维护!");
}
else
{
//根据分支ID过滤
var branchRoles = gerUserBranches.Where(_ => _.BranchId == branchId).ToList();
if (!branchRoles.Any())
{
throw new BusinessException("当前登录用户在分支【" + branchRoles.FirstOrDefault()?.BranchName + "】中不存在!");
}
else
{
if (getUserPermissions == null)
{
throw new BusinessException("当前登录用户没有任何权限信息,请找管理员进行维护!");
}
else
{
foreach (var role in branchRoles)
{
var userPermission = getUserPermissions.Where(_ => _.ProviderKey == role.RoleName);
foreach (var permission in userPermission)
{
authConfig.GrantedPolicies.Add(permission.Name, true);
}
}
}
}
}
return authConfig;
}
/// <summary>
/// 重置密码功能
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
//[HttpPut]
//[Route("{userId}/reset-password")]
//public async Task<IdentityUserDto> ResetPasswordAsync(Guid userId)
//{
// var user = await UserManager.FindByIdAsync(userId.ToString());
// string token = await UserManager.GeneratePasswordResetTokenAsync(user);
// await UserManager.ResetPasswordAsync(user, token, "1q2w3E*");
// //await UserManager.ResetPasswordAsync(user, token, "123456");
// var dto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
// return dto;
//}
[HttpPut]
[Route("{userId}/reset-password")]
[Authorize(IdentityPermissions.Users.Update)]
public async Task<IdentityUserDto> ResetPasswordAsync(Guid userId)
{
var user = await UserManager.FindByIdAsync(userId.ToString());
//string token = await UserManager.GeneratePasswordResetTokenAsync(user);//err:No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.
//await UserManager.ResetPasswordAsync(user, token, "1q2w3E*");
await UserManager.RemovePasswordAsync(user);
if (user.PasswordHash == null)
{
(await UserManager.AddPasswordAsync(user, "123456")).CheckErrors();
}
var dto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
return dto;
}
}
}

503
src/Modules/BaseService/BaseService.Application/UserManagement/UserBranchAppService.cs

@ -0,0 +1,503 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BaseService.BaseData;
using BaseService.BaseData.BranchManagement;
using BaseService.BaseData.Permissions.Dto;
using BaseService.BaseData.UserBranchRoleManagement;
using BaseService.BaseData.UserBranchRoleManagement.Dto;
using BaseService.Permissions;
using BaseService.RelationData.Dto;
using BaseService.Systems.UserManagement;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Authorization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Users;
namespace BaseService.UserManagement
{
[Route("api/base/userbranch")]
//[Authorize(BaseServicePermissions.UserBranch.Default)]
public class UserBranchAppService : ApplicationService, IUserBranchAppService
{
/// <summary>
/// 角色
/// </summary>
protected IIdentityRoleRepository IdentityRoleRepository { get; }
private readonly IBranchAppService _branchAppService;
private readonly IUserAppService _userAppService;
private readonly IRepository<UserBranch, Guid> _repository;
//权限提供者类
private readonly IAbpAuthorizationPolicyProvider _abpAuthorizationPolicyProvider;
/// <summary>
/// 当前用户
/// </summary>
protected ICurrentUser CurrentUsers { get; }
protected IIdentityUserRepository UserRepository { get; }
/// <summary>
/// 权限类
/// </summary>
protected IPermissionGrantRepository PermissionGrantRepository { get; }
public UserBranchAppService(
IRepository<UserBranch, Guid> repository,
IIdentityRoleRepository identityRoleRepository,
IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider,
ICurrentUser currentUser,
IIdentityUserRepository userRepository,
IPermissionGrantRepository permissionGrantRepository,
IUserAppService userAppService,
IBranchAppService branchAppService)
{
_repository = repository;
IdentityRoleRepository = identityRoleRepository;
_abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider;
CurrentUsers = currentUser;
UserRepository = userRepository;
_branchAppService = branchAppService;
_userAppService = userAppService;
PermissionGrantRepository = permissionGrantRepository;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("createUpdate")]
//[Authorize(BaseServicePermissions.UserBranch.Create)]
public virtual async Task CreateUpdateAsync(CreateOrUpdateUserBranchDto input)
{
var userBranch = await _repository.FirstOrDefaultAsync(_ => _.UserId == input.UserId && _.BranchId == input.BranchId);
if (userBranch == null)
{
//执行添加操作
var createUserBranch = new UserBranch(GuidGenerator.Create(),
input.UserId,
input.BranchId
);
var userBranchRoles = input.Roles;
//选择了角色信息
foreach (var role in userBranchRoles)
{
createUserBranch.AddRole(role.RoleId);
}
await _repository.InsertAsync(createUserBranch);
ObjectMapper.Map<UserBranch, UserBranchDto>(createUserBranch);
}
else
{
userBranch.UserId = input.UserId;
userBranch.BranchId = input.BranchId;
//修改角色信息
var getRoleIds = userBranch.Roles.ToList();
if (getRoleIds != null)
{
for (int i = getRoleIds.Count; i > 0; i--)
{
var role = getRoleIds[i - 1];
userBranch.RemoveRole(role.RoleId);
}
var getRoles = input.Roles;
if (getRoles != null)
{
foreach (var role in getRoles)
{
userBranch.AddRole(role.RoleId);
}
}
}
if (input.Roles == null || input.Roles.Count == 0)
{
await _repository.UpdateAsync(userBranch);
}
else
{
await _repository.UpdateAsync(userBranch, true);
}
ObjectMapper.Map<UserBranch, UserBranchDto>(userBranch);
}
}
//public virtual async Task<UserBranchDto> CreateAsync(CreateOrUpdateUserBranchDto input)
//{
// var exist = await _repository.FirstOrDefaultAsync(_ => _.UserId == input.UserId && _.BranchId == input.BranchId);
// if (exist != null) throw new BusinessException("该资源信息已存在,不要重复添加!");
// var userBranch = new UserBranch(GuidGenerator.Create(),
// input.UserId,
// input.BranchId
// );
// await _repository.InsertAsync(userBranch);
// var userBranchRoles = input.Roles;
// //选择了角色信息
// foreach (var role in userBranchRoles)
// {
// userBranch.AddRole(role.RoleId);
// }
// return ObjectMapper.Map<UserBranch, UserBranchDto>(userBranch);
//}
/// <summary>
/// 单条删除
/// </summary>
/// <param name="userId"></param>
/// <param name="branchId"></param>
/// <returns></returns>
[HttpPost]
[Route("{userId}/{branchId}/delete")]
[Authorize(BaseServicePermissions.UserBranch.Delete)]
public virtual async Task DeleteUnitAsync(Guid userId, Guid branchId)
{
await _repository.DeleteAsync(p => p.UserId == userId && p.BranchId == branchId);
}
/// <summary>
/// 根据用户ID进行删除
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpPost]
[Route("{userId}/delete")]
[Authorize(BaseServicePermissions.UserBranch.Delete)]
public virtual async Task DeleteUnitAsync(Guid userId)
{
await _repository.DeleteAsync(p => p.UserId == userId);
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpPost]
[Route("delete")]
[Authorize(BaseServicePermissions.UserBranch.Delete)]
public virtual async Task DeleteAsync(List<Guid> ids)
{
foreach (var id in ids)
{
await _repository.DeleteAsync(_ => _.Id == id);
}
}
/// <summary>
/// 修改操作
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
[HttpPut]
[Route("{id}")]
[Authorize(BaseServicePermissions.UserBranch.Update)]
public virtual async Task<UserBranchDto> UpdateAsync(Guid id, CreateOrUpdateUserBranchDto input)
{
var userBranch = await _repository.FirstOrDefaultAsync(_ => _.UserId == input.UserId && _.BranchId == input.BranchId);
userBranch.UserId = input.UserId;
userBranch.BranchId = input.BranchId;
//修改角色信息
var getRoleIds = userBranch.Roles;
if (getRoleIds != null)
{
foreach (var removerole in getRoleIds)
{
userBranch.RemoveRole(removerole.RoleId);
}
var getRoles = input.Roles;
if (getRoles != null)
{
foreach (var role in getRoles)
{
userBranch.AddRole(role.RoleId);
}
}
}
return ObjectMapper.Map<UserBranch, UserBranchDto>(userBranch);
}
/// <summary>
/// 查单条数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("{id}")]
public virtual async Task<UserBranchDto> GetAsync(Guid id)
{
var result = await _repository.GetAsync(id);
return ObjectMapper.Map<UserBranch, UserBranchDto>(result);
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[Route("paged")]
public virtual async Task<PagedResultDto<UserBranchDto>> GetPagedListAsync(GetUserBranchInput input)
{
var query = _repository
.WhereIf(input.UserId.HasValue, _ => _.UserId == input.UserId);
var items = await query
.Skip(input.SkipCount)
.Take(input.MaxResultCount)
.ToListAsync();
var totalCount = await query.CountAsync();
var dtos = ObjectMapper.Map<List<UserBranch>, List<UserBranchDto>>(items);
return new PagedResultDto<UserBranchDto>(totalCount, dtos);
}
/// <summary>
/// 分支列表(输入用户ID)
/// </summary>
/// <param name="userId">用户ID</param>
/// <returns></returns>
[HttpGet]
[Route("{userId}/branches")]
[AllowAnonymous]
public virtual async Task<List<UserBranchDto>> GetUserBranchsAsync(Guid userId)
{
var dtos = new List<UserBranchDto>();
await GetBranchList(userId, dtos);
return dtos;
}
private async Task GetBranchList(Guid userId, List<UserBranchDto> dtos)
{
var userBranches = _repository.Where(_ => _.UserId == userId);
foreach (var query in userBranches)
{
var branch = await _branchAppService.GetAsync(query.BranchId);
dtos.Add(new UserBranchDto()
{
BranchId = query.BranchId,
BranchName = branch.Name,
});
}
}
/// <summary>
/// 分支列表(当前登录用户)
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("current/branches")]
[AllowAnonymous]
public virtual async Task<List<UserBranchDto>> GetCurrentUserBranchesAsync()
{
var dtos = new List<UserBranchDto>();
await GetBranchList(CurrentUser.GetId(), dtos);
return dtos;
}
/// <summary>
/// 获取当前登录用户默认的组织
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("user-branch/{userId}")]
[AllowAnonymous]
public virtual async Task<UserBranchDto> GetCurrentUserBranchAsync(Guid userId)
{
var dto = new UserBranchDto();
var userBranche = _repository.FirstOrDefault(_ => _.UserId == userId);
if (userBranche == null)
{
throw new BusinessException("当前登录用户不存在!");
}
var branch = await _branchAppService.GetAsync(userBranche.BranchId);
dto.BranchId = branch.Id;
return dto;
}
/// <summary>
/// 获取当前登录用户所在组织的所有权限信息
/// </summary>
/// <param name="branchId"></param>
/// <returns></returns>
[HttpGet]
[Route("{branchId}/auth-config")]
[AllowAnonymous]
public virtual async Task<ApplicationAuthes> GetAuthConfigAsync(Guid branchId)
{
var authConfig = new ApplicationAuthes();
var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync();
foreach (var policyName in policyNames)
{
authConfig.Policies[policyName] = true;
}
var userId = CurrentUser.GetId();
//获取当前用户的所有权限信息
var grantedPermuissions = await GetUserGrantedPermissionsAsync(userId, branchId);
if (grantedPermuissions == null || grantedPermuissions.Count == 0)
{
throw new BusinessException("当前登录用户没有任何权限信息,请找管理员进行维护!");
}
//获取当前用户所在组织的所有角色名
var userRoleName = await GetUserRoleNamesAsync(userId, branchId);
if (userRoleName == null)
{
throw new BusinessException("当前登录用户没有任何组织信息,请找管理员进行维护!");
}
foreach (var roleName in userRoleName)
{
var userPermission = grantedPermuissions.Where(_ => _.ProviderKey == roleName);
foreach (var permission in userPermission)
{
//GrantedPolicies的key键不能相同
if (authConfig.GrantedPolicies.ContainsKey(permission.Name))
continue;
authConfig.GrantedPolicies.Add(permission.Name, true);
}
}
return authConfig;
}
/// <summary>
/// 权限信息(单个用户)(获取权限调用)
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
protected virtual async Task<List<PermissionGrant>> GetUserGrantedPermissionsAsync(Guid userId,Guid branchId)
{
var permissionGrants = new List<PermissionGrant>();
var listRolesName = await GetUserRoleNamesAsync(userId, branchId);
if (listRolesName != null)
{
foreach (var rolename in listRolesName)
{
var permissionGrantsInRole = await PermissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, rolename);
if (permissionGrantsInRole != null)
{
foreach (var permiss in permissionGrantsInRole)
{
permissionGrants.Add(permiss);
}
}
}
}
return permissionGrants;
}
/// <summary>
/// 获取出用户所在当前组织的所有角色名称(获取权限调用)
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
protected virtual async Task<List<string>> GetUserRoleNamesAsync(Guid userId, Guid branchId)
{
var userBranch = await _repository.GetAsync(_ => _.UserId == userId && _.BranchId == branchId);
var userRoles = userBranch.Roles.ToList();
//var userRoles = await GetUserRolesAsync(userId, branchId);
var roles = await IdentityRoleRepository.GetListAsync();
return userRoles.Select(role => roles.FirstOrDefault(p => p.Id == role.RoleId)?.Name)
.Where(roleName => !string.IsNullOrWhiteSpace(roleName)).ToList();
}
/// <summary>
/// 根据用户ID、组织ID获取该用户角色信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
[Route("userRoles/{userId}/{branchId}")]
public virtual async Task<List<UserBranchRole>> GetUserRolesAsync(Guid userId,Guid branchId)
{
var roleList = new List<UserBranchRole>();
var isInRole = _repository.FirstOrDefault(_ => _.UserId == userId && _.BranchId == branchId);
if (isInRole != null)
{
var userBranch = await _repository.GetAsync(_ => _.UserId == userId && _.BranchId == branchId);
var roles = userBranch.Roles.ToList();
foreach(var role in roles)
{
roleList.Add(new UserBranchRole() { RoleId = role.RoleId });
}
}
return roleList;
}
/// <summary>
/// 根据组织ID查角色信息
/// </summary>
/// <param name="branchId"></param>
/// <returns></returns>
[HttpGet]
[Route("userRoles/{branchId}")]
public virtual List<UserBranchRole> GetBranchRolesAsync(Guid branchId)
{
var dtos = new List<UserBranchRole>();
var isInRole = _repository.Where(_ => _.BranchId == branchId);
if (isInRole != null)
{
foreach (var userRoles in isInRole)
{
foreach (var role in userRoles.Roles)
{
dtos.Add(new UserBranchRole() { RoleId = role.RoleId });
}
}
}
return dtos;
//var roleList = new List<UserBranchRole>();
//var isInRole = _repository.Where(_ => _.BranchId == branchId);
//if(isInRole!=null)
//{
// var userBranch = await _repository.GetAsync(_ => _.BranchId == branchId);
// var roles = userBranch.Roles.ToList();
// foreach (var role in roles)
// {
// roleList.Add(new UserBranchRole() { RoleId = role.RoleId });
// }
//}
//return roleList;
}
/// <summary>
/// 根据用户ID查角色信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
[Route("{userId}/userRoles")]
public virtual List<UserBranchRole> GetUserRolesAsync(Guid userId)
{
var dtos = new List<UserBranchRole>();
var isInRole = _repository.Where(_ => _.UserId == userId);
if (isInRole != null)
{
foreach (var userRoles in isInRole)
{
foreach (var role in userRoles.Roles)
{
dtos.Add(new UserBranchRole() { RoleId = role.RoleId });
}
}
}
return dtos;
}
}
}

14
src/Modules/BaseService/BaseService.Domain/BaseData/AppIdentityRole.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp.Identity;
namespace BaseService.BaseData
{
public class AppIdentityRole: IdentityRole
{
public string RoleName { get; set; }
public Guid RoleId { get; set; }
}
}

152
src/Modules/BaseService/BaseService.Domain/BaseData/Branch.cs

@ -0,0 +1,152 @@
using BaseService.RelationBaseData;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace BaseService.BaseData
{
public class Branch : AuditedAggregateRoot<Guid>, ISoftDelete
{
public Guid? TenantId { get; set; }
/// <summary>
/// 机构分类:1.公司;2.组织;3.部门;4.供应商
/// </summary>
public short CategoryId { get; set; }
public Guid? Pid { get; set; }
public string Name { get; set; }
public string FullName { get; set; }
public int Sort { get; set; }
/// <summary>
/// 是否子集
/// </summary>
public bool Leaf { get; set; }
/// <summary>
/// 级联
/// </summary>
public string CascadeId { get; set; }
public bool Enabled { get; set; }
public bool IsDeleted { get; set; }
public virtual ICollection<BranchRole> Roles { get; set; }
public Branch(Guid id, Guid? tenantId, short categoryId, Guid? pid, [NotNull] string name, string fullName, int sort, bool leaf, bool enabled)
{
TenantId = tenantId;
Id = id;
CategoryId = categoryId;
Pid = pid;
Name = name;
FullName = fullName;
Sort = sort;
Enabled = enabled;
Leaf = leaf;
Roles = new Collection<BranchRole>();
}
public virtual void AddRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
if (IsInRole(roleId))
{
return;
}
Roles.Add(new BranchRole(roleId, Id));
}
public virtual void RemoveRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
if (!IsInRole(roleId))
{
return;
}
Roles.RemoveAll(r => r.RoleId == roleId);
}
public virtual bool IsInRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
return Roles.Any(r => r.RoleId == roleId);
}
///// <summary>
///// 机构分类:1.公司;2.分支;3.部门;4.供应商
///// </summary>
//public short CategoryId { get; set; }
//public Guid? Pid { get; set; }
//public string Name { get; set; }
//public string FullName { get; set; }
//public int Sort { get; set; }
//public bool Enabled { get; set; }
//public bool IsDeleted { get; set; }
//public virtual ICollection<BranchRole> Roles { get; set; }
//public Branch(Guid id, short categoryId, Guid? pid, [NotNull] string name, string fullName, int sort, bool enabled)
//{
// Id = id;
// CategoryId = categoryId;
// Pid = pid;
// Name = name;
// FullName = fullName;
// Sort = sort;
// Enabled = enabled;
// Roles = new Collection<BranchRole>();
//}
//public virtual void AddRole(Guid roleId)
//{
// Check.NotNull(roleId, nameof(roleId));
// if (IsInRole(roleId))
// {
// return;
// }
// Roles.Add(new BranchRole(roleId, Id));
//}
//public virtual void RemoveRole(Guid roleId)
//{
// Check.NotNull(roleId, nameof(roleId));
// if (!IsInRole(roleId))
// {
// return;
// }
// Roles.RemoveAll(r => r.RoleId == roleId);
//}
//public virtual bool IsInRole(Guid roleId)
//{
// Check.NotNull(roleId, nameof(roleId));
// return Roles.Any(r => r.RoleId == roleId);
//}
}
}

90
src/Modules/BaseService/BaseService.Domain/BaseData/UserBranch.cs

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace BaseService.BaseData
{
/// <summary>
/// 用户-分支
/// </summary>
public class UserBranch : AuditedAggregateRoot<Guid>
{
/// <summary>
/// 用户ID
/// </summary>
public Guid UserId { get; set; }
// /// <summary>
// /// 用户名称
// /// </summary>
// [NotMapped]
// public string UserName { get; set; }
/// <summary>
/// 分支ID
/// </summary>
public Guid BranchId { get; set; }
// /// <summary>
// /// 分支机构名称
// /// </summary>
// [NotMapped]
// public string BranchName { get; set; }
//
/// <summary>
/// 软删除
/// </summary>
//public bool IsDeleted { get; set; }
public virtual ICollection<UserBranchRole> Roles { get; set; }
public UserBranch(Guid id, Guid userId, Guid branchId) : base(id)
{
UserId = userId;
BranchId = branchId;
Roles = new Collection<UserBranchRole>();
}
public virtual void AddRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
if (IsInRole(roleId))
{
return;
}
Roles.Add(new UserBranchRole(roleId));
}
public virtual void RemoveRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
if (!IsInRole(roleId))
{
return;
}
Roles.RemoveAll(r => r.RoleId == roleId);
}
public virtual bool IsInRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
return Roles.Any(r => r.RoleId == roleId);
}
}
}

41
src/Modules/BaseService/BaseService.Domain/BaseData/UserBranchRole.cs

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Values;
using Volo.Abp.Identity;
using Volo.Abp.MultiTenancy;
namespace BaseService.BaseData
{
/// <summary>
/// 用户--分支--角色(多对多表)
/// </summary>
public class UserBranchRole : ValueObject
{
/// <summary>
/// 角色ID
/// </summary>
public Guid RoleId { get; set; }
public UserBranchRole()
{
}
public UserBranchRole(Guid roleId)
{
RoleId = roleId;
}
protected override IEnumerable<object> GetAtomicValues()
{
yield return RoleId;
}
}
}

35
src/Modules/BaseService/BaseService.Domain/BaseService.Domain.csproj

@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>BaseService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Remove="BaseData\AppIdentityRole.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="Localization\BaseService\cs.json" />
<None Remove="Localization\BaseService\en.json" />
<None Remove="Localization\BaseService\zh-Hans.json" />
<None Remove="Localization\BaseService\zh-Hant.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization\BaseService\cs.json" />
<EmbeddedResource Include="Localization\BaseService\en.json" />
<EmbeddedResource Include="Localization\BaseService\zh-Hans.json" />
<EmbeddedResource Include="Localization\BaseService\zh-Hant.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="4.3.3" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="4.3.3" />
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Settings" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Users.Domain" Version="4.3.3" />
</ItemGroup>
</Project>

15
src/Modules/BaseService/BaseService.Domain/BaseServiceConsts.cs

@ -0,0 +1,15 @@
namespace BaseService
{
public static class BaseServiceConsts
{
public const int MaxNumeralLength = 16;
public const int MaxCodeLength = 32;
public const int MaxNameLength = 50;
public const int MaxFullNameLength = 128;
public const int MaxNotesLength = 256;
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save