717 changed files with 88576 additions and 0 deletions
@ -0,0 +1 @@ |
|||||
|
**/wwwroot/libs/** linguist-vendored |
@ -0,0 +1,265 @@ |
|||||
|
## Ignore Visual Studio temporary files, build results, and |
||||
|
## files generated by popular Visual Studio add-ons. |
||||
|
|
||||
|
# User-specific files |
||||
|
*.suo |
||||
|
*.user |
||||
|
*.userosscache |
||||
|
*.sln.docstates |
||||
|
|
||||
|
# User-specific files (MonoDevelop/Xamarin Studio) |
||||
|
*.userprefs |
||||
|
|
||||
|
# Build results |
||||
|
[Dd]ebug/ |
||||
|
[Dd]ebugPublic/ |
||||
|
[Rr]elease/ |
||||
|
[Rr]eleases/ |
||||
|
x64/ |
||||
|
x86/ |
||||
|
bld/ |
||||
|
[Bb]in/ |
||||
|
[Oo]bj/ |
||||
|
[Ll]og/ |
||||
|
|
||||
|
# Visual Studio 2015 cache/options directory |
||||
|
.vs/ |
||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot |
||||
|
#wwwroot/ |
||||
|
|
||||
|
# MSTest test Results |
||||
|
[Tt]est[Rr]esult*/ |
||||
|
[Bb]uild[Ll]og.* |
||||
|
|
||||
|
# NUNIT |
||||
|
*.VisualState.xml |
||||
|
TestResult.xml |
||||
|
|
||||
|
# Build Results of an ATL Project |
||||
|
[Dd]ebugPS/ |
||||
|
[Rr]eleasePS/ |
||||
|
dlldata.c |
||||
|
|
||||
|
# DNX |
||||
|
project.lock.json |
||||
|
artifacts/ |
||||
|
|
||||
|
*_i.c |
||||
|
*_p.c |
||||
|
*_i.h |
||||
|
*.ilk |
||||
|
*.meta |
||||
|
*.obj |
||||
|
*.pch |
||||
|
*.pdb |
||||
|
*.pgc |
||||
|
*.pgd |
||||
|
*.rsp |
||||
|
*.sbr |
||||
|
*.tlb |
||||
|
*.tli |
||||
|
*.tlh |
||||
|
*.tmp |
||||
|
*.tmp_proj |
||||
|
*.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 |
||||
|
|
||||
|
# TFS 2012 Local Workspace |
||||
|
$tf/ |
||||
|
|
||||
|
# Guidance Automation Toolkit |
||||
|
*.gpState |
||||
|
|
||||
|
# ReSharper is a .NET coding add-in |
||||
|
_ReSharper*/ |
||||
|
*.[Rr]e[Ss]harper |
||||
|
*.DotSettings.user |
||||
|
|
||||
|
# JustCode is a .NET coding add-in |
||||
|
.JustCode |
||||
|
|
||||
|
# TeamCity is a build add-in |
||||
|
_TeamCity* |
||||
|
|
||||
|
# DotCover is a Code Coverage Tool |
||||
|
*.dotCover |
||||
|
|
||||
|
# 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 |
||||
|
# TODO: 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 |
||||
|
# The packages folder can be ignored because of Package Restore |
||||
|
**/packages/* |
||||
|
# except build/, which is used as an MSBuild target. |
||||
|
!**/packages/build/ |
||||
|
# Uncomment if necessary however generally it will be regenerated when needed |
||||
|
#!**/packages/repositories.config |
||||
|
# NuGet v3's project.json files produces more ignoreable 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 |
||||
|
|
||||
|
# 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 |
||||
|
*.pfx |
||||
|
*.publishsettings |
||||
|
node_modules/ |
||||
|
orleans.codegen.cs |
||||
|
|
||||
|
# 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 |
||||
|
|
||||
|
# SQL Server files |
||||
|
*.mdf |
||||
|
*.ldf |
||||
|
|
||||
|
# Business Intelligence projects |
||||
|
*.rdl.data |
||||
|
*.bim.layout |
||||
|
*.bim_*.settings |
||||
|
|
||||
|
# Microsoft Fakes |
||||
|
FakesAssemblies/ |
||||
|
|
||||
|
# GhostDoc plugin setting file |
||||
|
*.GhostDoc.xml |
||||
|
|
||||
|
# Node.js Tools for Visual Studio |
||||
|
.ntvs_analysis.dat |
||||
|
|
||||
|
# Visual Studio 6 build log |
||||
|
*.plg |
||||
|
|
||||
|
# Visual Studio 6 workspace options file |
||||
|
*.opt |
||||
|
|
||||
|
# 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/ |
||||
|
|
||||
|
# JetBrains Rider |
||||
|
.idea/ |
||||
|
*.sln.iml |
||||
|
|
||||
|
# AuthSiteCenter |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.Web/Logs/* |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.Web.Host/Logs/* |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.AuthServer/Logs/* |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.HttpApi.Host/Logs/* |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.HttpApi.HostWithIds/Logs/* |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.DbMigrator/Logs/* |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.Blazor.Server/Logs/* |
||||
|
src/WinIn.FasterZ.AuthSiteCenter.Blazor.Server.Tiered/Logs/* |
||||
|
|
||||
|
# Use abp install-libs to restore. |
||||
|
**/wwwroot/libs/* |
@ -0,0 +1,5 @@ |
|||||
|
{ |
||||
|
"singleQuote": true, |
||||
|
"useTabs": false, |
||||
|
"tabWidth": 4 |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<configuration> |
||||
|
<packageSources> |
||||
|
</packageSources> |
||||
|
</configuration> |
@ -0,0 +1,86 @@ |
|||||
|
|
||||
|
Microsoft Visual Studio Solution File, Format Version 12.00 |
||||
|
# Visual Studio Version 17 |
||||
|
VisualStudioVersion = 17.6.33815.320 |
||||
|
MinimumVisualStudioVersion = 10.0.40219.1 |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.Domain", "src\WinIn.FasterZ.AuthSiteCenter.Domain\WinIn.FasterZ.AuthSiteCenter.Domain.csproj", "{554AD327-6DBA-4F8F-96F8-81CE7A0C863F}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.Application", "src\WinIn.FasterZ.AuthSiteCenter.Application\WinIn.FasterZ.AuthSiteCenter.Application.csproj", "{1A94A50E-06DC-43C1-80B5-B662820EC3EB}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore", "src\WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore\WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore.csproj", "{C956DD76-69C8-4A9C-83EA-D17DF83340FD}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.Web", "src\WinIn.FasterZ.AuthSiteCenter.Web\WinIn.FasterZ.AuthSiteCenter.Web.csproj", "{068855E8-9240-4F1A-910B-CF825794513B}" |
||||
|
EndProject |
||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CA9AC87F-097E-4F15-8393-4BC07735A5B0}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.Domain.Shared", "src\WinIn.FasterZ.AuthSiteCenter.Domain.Shared\WinIn.FasterZ.AuthSiteCenter.Domain.Shared.csproj", "{42F719ED-8413-4895-B5B4-5AB56079BC66}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.Application.Contracts", "src\WinIn.FasterZ.AuthSiteCenter.Application.Contracts\WinIn.FasterZ.AuthSiteCenter.Application.Contracts.csproj", "{520659C8-C734-4298-A3DA-B539DB9DFC0B}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.HttpApi", "src\WinIn.FasterZ.AuthSiteCenter.HttpApi\WinIn.FasterZ.AuthSiteCenter.HttpApi.csproj", "{4164BDF7-F527-4E85-9CE6-E3C2D7426A27}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.HttpApi.Client", "src\WinIn.FasterZ.AuthSiteCenter.HttpApi.Client\WinIn.FasterZ.AuthSiteCenter.HttpApi.Client.csproj", "{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinIn.FasterZ.AuthSiteCenter.DbMigrator", "src\WinIn.FasterZ.AuthSiteCenter.DbMigrator\WinIn.FasterZ.AuthSiteCenter.DbMigrator.csproj", "{AA94D832-1CCC-4715-95A9-A483F23A1A5D}" |
||||
|
EndProject |
||||
|
Global |
||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
|
Debug|Any CPU = Debug|Any CPU |
||||
|
Release|Any CPU = Release|Any CPU |
||||
|
EndGlobalSection |
||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
|
{554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{068855E8-9240-4F1A-910B-CF825794513B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{068855E8-9240-4F1A-910B-CF825794513B}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{068855E8-9240-4F1A-910B-CF825794513B}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{068855E8-9240-4F1A-910B-CF825794513B}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{520659C8-C734-4298-A3DA-B539DB9DFC0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{520659C8-C734-4298-A3DA-B539DB9DFC0B}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{520659C8-C734-4298-A3DA-B539DB9DFC0B}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{520659C8-C734-4298-A3DA-B539DB9DFC0B}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
EndGlobalSection |
||||
|
GlobalSection(SolutionProperties) = preSolution |
||||
|
HideSolutionNode = FALSE |
||||
|
EndGlobalSection |
||||
|
GlobalSection(NestedProjects) = preSolution |
||||
|
{554AD327-6DBA-4F8F-96F8-81CE7A0C863F} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{1A94A50E-06DC-43C1-80B5-B662820EC3EB} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{C956DD76-69C8-4A9C-83EA-D17DF83340FD} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{068855E8-9240-4F1A-910B-CF825794513B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{42F719ED-8413-4895-B5B4-5AB56079BC66} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{520659C8-C734-4298-A3DA-B539DB9DFC0B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
{AA94D832-1CCC-4715-95A9-A483F23A1A5D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} |
||||
|
EndGlobalSection |
||||
|
GlobalSection(ExtensibilityGlobals) = postSolution |
||||
|
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} |
||||
|
EndGlobalSection |
||||
|
EndGlobal |
@ -0,0 +1,23 @@ |
|||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||
|
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/UpgradedFromVSSettings/@EntryValue">True</s:Boolean> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceDoWhileStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceFixedStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceForeachStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceForStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceIfStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceLockStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceUsingStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceWhileStatementBraces/@EntryIndexedValue">WARNING</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOR/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_REDUNDANT/@EntryValue">False</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Implementations/@KeyIndexDefined">True</s:Boolean> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Async/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Mutable/@EntryIndexedValue">False</s:String> |
||||
|
<s:Boolean x:Key="/Default/CodeStyle/Generate/=Overrides/@KeyIndexDefined">True</s:Boolean> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Async/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Mutable/@EntryIndexedValue">False</s:String> |
||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String> |
||||
|
</wpf:ResourceDictionary> |
@ -0,0 +1,19 @@ |
|||||
|
<Project> |
||||
|
<PropertyGroup> |
||||
|
<LangVersion>latest</LangVersion> |
||||
|
<Version>1.0.0</Version> |
||||
|
<NoWarn>$(NoWarn);CS1591</NoWarn> |
||||
|
<AbpProjectType>app</AbpProjectType> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Target Name="NoWarnOnRazorViewImportedTypeConflicts" BeforeTargets="RazorCoreCompile"> |
||||
|
<PropertyGroup> |
||||
|
<NoWarn>$(NoWarn);0436</NoWarn> |
||||
|
</PropertyGroup> |
||||
|
</Target> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,28 @@ |
|||||
|
using Volo.Abp.Account; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.ObjectExtending; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AuthSiteCenterDomainSharedModule), |
||||
|
typeof(AbpAccountApplicationContractsModule), |
||||
|
typeof(AbpFeatureManagementApplicationContractsModule), |
||||
|
typeof(AbpIdentityApplicationContractsModule), |
||||
|
typeof(AbpPermissionManagementApplicationContractsModule), |
||||
|
typeof(AbpSettingManagementApplicationContractsModule), |
||||
|
typeof(AbpTenantManagementApplicationContractsModule), |
||||
|
typeof(AbpObjectExtendingModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterApplicationContractsModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
AuthSiteCenterDtoExtensions.Configure(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.ObjectExtending; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
public static class AuthSiteCenterDtoExtensions |
||||
|
{ |
||||
|
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
||||
|
|
||||
|
public static void Configure() |
||||
|
{ |
||||
|
OneTimeRunner.Run(() => |
||||
|
{ |
||||
|
/* You can add extension properties to DTOs |
||||
|
* defined in the depended modules. |
||||
|
* |
||||
|
* Example: |
||||
|
* |
||||
|
* ObjectExtensionManager.Instance |
||||
|
* .AddOrUpdateProperty<IdentityRoleDto, string>("Title"); |
||||
|
* |
||||
|
* See the documentation for more: |
||||
|
* https://docs.abp.io/en/abp/latest/Object-Extensions
|
||||
|
*/ |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Localization; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
public class AuthSiteCenterPermissionDefinitionProvider : PermissionDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(IPermissionDefinitionContext context) |
||||
|
{ |
||||
|
var myGroup = context.AddGroup(AuthSiteCenterPermissions.GroupName); |
||||
|
//Define your own permissions here. Example:
|
||||
|
//myGroup.AddPermission(AuthSiteCenterPermissions.MyPermission1, L("Permission:MyPermission1"));
|
||||
|
} |
||||
|
|
||||
|
private static LocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<AuthSiteCenterResource>(name); |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
public static class AuthSiteCenterPermissions |
||||
|
{ |
||||
|
public const string GroupName = "AuthSiteCenter"; |
||||
|
|
||||
|
//Add your own permission names. Example:
|
||||
|
//public const string MyPermission1 = GroupName + ".MyPermission1";
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace>WinIn.FasterZ.AuthSiteCenter</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Domain.Shared\WinIn.FasterZ.AuthSiteCenter.Domain.Shared.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.ObjectExtending" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.Account.Application.Contracts" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.Identity.Application.Contracts" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Application.Contracts" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.Application.Contracts" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.Application.Contracts" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.Application.Contracts" Version="7.3.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
/* Inherit your application services from this class. |
||||
|
*/ |
||||
|
public abstract class AuthSiteCenterAppService : ApplicationService |
||||
|
{ |
||||
|
protected AuthSiteCenterAppService() |
||||
|
{ |
||||
|
LocalizationResource = typeof(AuthSiteCenterResource); |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
using AutoMapper; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
public class AuthSiteCenterApplicationAutoMapperProfile : Profile |
||||
|
{ |
||||
|
public AuthSiteCenterApplicationAutoMapperProfile() |
||||
|
{ |
||||
|
/* You can configure your AutoMapper mapping configuration here. |
||||
|
* Alternatively, you can split your mapping configurations |
||||
|
* into multiple profile classes for a better organization. */ |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
using Volo.Abp.Account; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AuthSiteCenterDomainModule), |
||||
|
typeof(AbpAccountApplicationModule), |
||||
|
typeof(AuthSiteCenterApplicationContractsModule), |
||||
|
typeof(AbpIdentityApplicationModule), |
||||
|
typeof(AbpPermissionManagementApplicationModule), |
||||
|
typeof(AbpTenantManagementApplicationModule), |
||||
|
typeof(AbpFeatureManagementApplicationModule), |
||||
|
typeof(AbpSettingManagementApplicationModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterApplicationModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpAutoMapperOptions>(options => |
||||
|
{ |
||||
|
options.AddMaps<AuthSiteCenterApplicationModule>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
using System.Security.Claims; |
||||
|
using Microsoft.AspNetCore.Authentication; |
||||
|
using Microsoft.AspNetCore.Http.Features.Authentication; |
||||
|
using IAuthenticationHandler = Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Keeps the User and AuthenticationResult consistent with each other
|
||||
|
/// </summary>
|
||||
|
internal sealed class AuthenticationFeatures : |
||||
|
IAuthenticateResultFeature, |
||||
|
IHttpAuthenticationFeature |
||||
|
{ |
||||
|
private ClaimsPrincipal _user; |
||||
|
private AuthenticateResult _result; |
||||
|
|
||||
|
public AuthenticationFeatures(AuthenticateResult result) => AuthenticateResult = result; |
||||
|
|
||||
|
public AuthenticateResult AuthenticateResult |
||||
|
{ |
||||
|
get => _result; |
||||
|
set |
||||
|
{ |
||||
|
_result = value; |
||||
|
_user = _result?.Principal; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public ClaimsPrincipal User |
||||
|
{ |
||||
|
get => _user; |
||||
|
set |
||||
|
{ |
||||
|
_user = value; |
||||
|
_result = null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public IAuthenticationHandler Handler { get; set; } |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
using Microsoft.AspNetCore.Authentication; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Used to capture the <see cref="P:Microsoft.AspNetCore.Authentication.IAuthenticateResultFeature.AuthenticateResult" /> from the authorization middleware.
|
||||
|
/// </summary>
|
||||
|
public interface IAuthenticateResultFeature |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The <see cref="P:Microsoft.AspNetCore.Authentication.IAuthenticateResultFeature.AuthenticateResult" /> from the authorization middleware.
|
||||
|
/// Set to null if the <see cref="P:Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature.User" /> property is set after the authorization middleware.
|
||||
|
/// </summary>
|
||||
|
AuthenticateResult? AuthenticateResult { get; set; } |
||||
|
} |
@ -0,0 +1,168 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Security.Claims; |
||||
|
using System.Security.Principal; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.Security.Claims; |
||||
|
using Volo.Abp.SimpleStateChecking; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
public class PermissionChecker : IPermissionChecker, ITransientDependency |
||||
|
{ |
||||
|
protected IPermissionDefinitionManager PermissionDefinitionManager { get; } |
||||
|
protected ICurrentPrincipalAccessor PrincipalAccessor { get; } |
||||
|
protected ICurrentTenant CurrentTenant { get; } |
||||
|
protected IPermissionValueProviderManager PermissionValueProviderManager { get; } |
||||
|
protected ISimpleStateCheckerManager<PermissionDefinition> StateCheckerManager { get; } |
||||
|
|
||||
|
public PermissionChecker( |
||||
|
ICurrentPrincipalAccessor principalAccessor, |
||||
|
IPermissionDefinitionManager permissionDefinitionManager, |
||||
|
ICurrentTenant currentTenant, |
||||
|
IPermissionValueProviderManager permissionValueProviderManager, |
||||
|
ISimpleStateCheckerManager<PermissionDefinition> stateCheckerManager) |
||||
|
{ |
||||
|
PrincipalAccessor = principalAccessor; |
||||
|
PermissionDefinitionManager = permissionDefinitionManager; |
||||
|
CurrentTenant = currentTenant; |
||||
|
PermissionValueProviderManager = permissionValueProviderManager; |
||||
|
StateCheckerManager = stateCheckerManager; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<bool> IsGrantedAsync(string name) |
||||
|
{ |
||||
|
return await IsGrantedAsync(PrincipalAccessor.Principal, name); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<bool> IsGrantedAsync( |
||||
|
ClaimsPrincipal? claimsPrincipal, |
||||
|
string name) |
||||
|
{ |
||||
|
Check.NotNull(name, nameof(name)); |
||||
|
|
||||
|
var permission = await PermissionDefinitionManager.GetOrNullAsync(name); |
||||
|
if (permission == null) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
if (!permission.IsEnabled) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
if (!await StateCheckerManager.IsEnabledAsync(permission)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
var multiTenancySide = claimsPrincipal?.GetMultiTenancySide() |
||||
|
?? CurrentTenant.GetMultiTenancySide(); |
||||
|
|
||||
|
if (!permission.MultiTenancySide.HasFlag(multiTenancySide)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
var isGranted = false; |
||||
|
var context = new PermissionValueCheckContext(permission, claimsPrincipal); |
||||
|
foreach (var provider in PermissionValueProviderManager.ValueProviders) |
||||
|
{ |
||||
|
if (context.Permission.Providers.Any() && |
||||
|
!context.Permission.Providers.Contains(provider.Name)) |
||||
|
{ |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
var result = await provider.CheckAsync(context); |
||||
|
|
||||
|
if (result == PermissionGrantResult.Granted) |
||||
|
{ |
||||
|
isGranted = true; |
||||
|
} |
||||
|
else if (result == PermissionGrantResult.Prohibited) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return isGranted; |
||||
|
} |
||||
|
|
||||
|
public async Task<MultiplePermissionGrantResult> IsGrantedAsync(string[] names) |
||||
|
{ |
||||
|
return await IsGrantedAsync(PrincipalAccessor.Principal, names); |
||||
|
} |
||||
|
|
||||
|
public async Task<MultiplePermissionGrantResult> IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, string[] names) |
||||
|
{ |
||||
|
Check.NotNull(names, nameof(names)); |
||||
|
|
||||
|
var result = new MultiplePermissionGrantResult(); |
||||
|
if (!names.Any()) |
||||
|
{ |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
var multiTenancySide = claimsPrincipal?.GetMultiTenancySide() ?? |
||||
|
CurrentTenant.GetMultiTenancySide(); |
||||
|
|
||||
|
var permissionDefinitions = new List<PermissionDefinition>(); |
||||
|
foreach (var name in names) |
||||
|
{ |
||||
|
var permission = await PermissionDefinitionManager.GetOrNullAsync(name); |
||||
|
if (permission == null) |
||||
|
{ |
||||
|
result.Result.Add(name, PermissionGrantResult.Prohibited); |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
result.Result.Add(name, PermissionGrantResult.Undefined); |
||||
|
|
||||
|
if (permission.IsEnabled && |
||||
|
await StateCheckerManager.IsEnabledAsync(permission) && |
||||
|
permission.MultiTenancySide.HasFlag(multiTenancySide)) |
||||
|
{ |
||||
|
permissionDefinitions.Add(permission); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
foreach (var provider in PermissionValueProviderManager.ValueProviders) |
||||
|
{ |
||||
|
var permissions = permissionDefinitions |
||||
|
.Where(x => !x.Providers.Any() || x.Providers.Contains(provider.Name)) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (permissions.IsNullOrEmpty()) |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
var context = new PermissionValuesCheckContext( |
||||
|
permissions, |
||||
|
claimsPrincipal); |
||||
|
|
||||
|
var multipleResult = await provider.CheckAsync(context); |
||||
|
foreach (var grantResult in multipleResult.Result.Where(grantResult => |
||||
|
result.Result.ContainsKey(grantResult.Key) && |
||||
|
result.Result[grantResult.Key] == PermissionGrantResult.Undefined && |
||||
|
grantResult.Value != PermissionGrantResult.Undefined)) |
||||
|
{ |
||||
|
result.Result[grantResult.Key] = grantResult.Value; |
||||
|
permissionDefinitions.RemoveAll(x => x.Name == grantResult.Key); |
||||
|
} |
||||
|
|
||||
|
if (result.AllGranted || result.AllProhibited) |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using Volo.Abp.Text.Formatting; |
||||
|
|
||||
|
namespace WinIn.FasterZ.InterfaceDash.Permissions; |
||||
|
|
||||
|
[Serializable] |
||||
|
public class PermissionGrantCacheItem |
||||
|
{ |
||||
|
private const string CacheKeyFormat = "pn:{0},pk:{1},n:{2}"; |
||||
|
|
||||
|
public bool IsGranted { get; set; } |
||||
|
|
||||
|
public PermissionGrantCacheItem() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public PermissionGrantCacheItem(bool isGranted) |
||||
|
{ |
||||
|
IsGranted = isGranted; |
||||
|
} |
||||
|
|
||||
|
public static string CalculateCacheKey(string name, string providerName, string providerKey) |
||||
|
{ |
||||
|
return string.Format(CacheKeyFormat, providerName, providerKey, name); |
||||
|
} |
||||
|
|
||||
|
public static string GetPermissionNameFormCacheKeyOrNull(string cacheKey) |
||||
|
{ |
||||
|
var result = FormattedStringValueExtracter.Extract(cacheKey, CacheKeyFormat, true); |
||||
|
return result.IsMatch ? result.Matches.Last().Value : null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,148 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions |
||||
|
{ |
||||
|
public class PermissionStore : IPermissionStore, ITransientDependency |
||||
|
{ |
||||
|
public ILogger<PermissionStore> Logger { get; set; } |
||||
|
|
||||
|
protected IPermissionGrantRepository PermissionGrantRepository { get; } |
||||
|
|
||||
|
protected IPermissionDefinitionManager PermissionDefinitionManager { get; } |
||||
|
|
||||
|
protected IDistributedCache<PermissionGrantCacheItem> Cache { get; } |
||||
|
|
||||
|
public PermissionStore(IPermissionGrantRepository permissionGrantRepository, IDistributedCache<PermissionGrantCacheItem> cache, IPermissionDefinitionManager permissionDefinitionManager) |
||||
|
{ |
||||
|
PermissionGrantRepository = permissionGrantRepository; |
||||
|
Cache = cache; |
||||
|
PermissionDefinitionManager = permissionDefinitionManager; |
||||
|
Logger = NullLogger<PermissionStore>.Instance; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<bool> IsGrantedAsync(string name, string providerName, string providerKey) |
||||
|
{ |
||||
|
return (await GetCacheItemAsync(name, providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)).IsGranted; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<PermissionGrantCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey) |
||||
|
{ |
||||
|
string cacheKey = CalculateCacheKey(name, providerName, providerKey); |
||||
|
Logger.LogDebug("PermissionStore.GetCacheItemAsync: " + cacheKey); |
||||
|
PermissionGrantCacheItem cacheItem2 = await Cache.GetAsync(cacheKey).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
if (cacheItem2 != null) |
||||
|
{ |
||||
|
Logger.LogDebug("Found in the cache: " + cacheKey); |
||||
|
return cacheItem2; |
||||
|
} |
||||
|
Logger.LogDebug("Not found in the cache: " + cacheKey); |
||||
|
cacheItem2 = new PermissionGrantCacheItem(isGranted: false); |
||||
|
await SetCacheItemsAsync(providerName, providerKey, name, cacheItem2).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
return cacheItem2; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task SetCacheItemsAsync(string providerName, string providerKey, string currentName, PermissionGrantCacheItem currentCacheItem) |
||||
|
{ |
||||
|
IReadOnlyList<PermissionDefinition> permissions = await PermissionDefinitionManager.GetPermissionsAsync().ConfigureAwait(continueOnCapturedContext: false); |
||||
|
Logger.LogDebug("Getting all granted permissions from the repository for this provider name,key: " + providerName + "," + providerKey); |
||||
|
HashSet<string> hashSet = new HashSet<string>((await PermissionGrantRepository.GetListAsync(providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)).Select((p) => p.Name)); |
||||
|
Logger.LogDebug($"Setting the cache items. Count: {permissions.Count}"); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> list = new List<KeyValuePair<string, PermissionGrantCacheItem>>(); |
||||
|
foreach (PermissionDefinition item in permissions) |
||||
|
{ |
||||
|
bool isGranted = hashSet.Contains(item.Name); |
||||
|
list.Add(new KeyValuePair<string, PermissionGrantCacheItem>(CalculateCacheKey(item.Name, providerName, providerKey), new PermissionGrantCacheItem(isGranted))); |
||||
|
if (item.Name == currentName) |
||||
|
{ |
||||
|
currentCacheItem.IsGranted = isGranted; |
||||
|
} |
||||
|
} |
||||
|
await Cache.SetManyAsync(list).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
Logger.LogDebug($"Finished setting the cache items. Count: {permissions.Count}"); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<MultiplePermissionGrantResult> IsGrantedAsync(string[] names, string providerName, string providerKey) |
||||
|
{ |
||||
|
Check.NotNullOrEmpty(names, "names"); |
||||
|
MultiplePermissionGrantResult result = new MultiplePermissionGrantResult(); |
||||
|
if (names.Length == 1) |
||||
|
{ |
||||
|
string text = names.First(); |
||||
|
Dictionary<string, PermissionGrantResult> result2 = result.Result; |
||||
|
string key = text; |
||||
|
result2.Add(key, await IsGrantedAsync(names.First(), providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false) ? PermissionGrantResult.Granted : PermissionGrantResult.Undefined); |
||||
|
return result; |
||||
|
} |
||||
|
foreach (KeyValuePair<string, PermissionGrantCacheItem> item in await GetCacheItemsAsync(names, providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)) |
||||
|
{ |
||||
|
result.Result.Add(GetPermissionNameFormCacheKeyOrNull(item.Key), item.Value != null && item.Value.IsGranted ? PermissionGrantResult.Granted : PermissionGrantResult.Undefined); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<List<KeyValuePair<string, PermissionGrantCacheItem>>> GetCacheItemsAsync(string[] names, string providerName, string providerKey) |
||||
|
{ |
||||
|
List<string> cacheKeys = names.Select((x) => CalculateCacheKey(x, providerName, providerKey)).ToList(); |
||||
|
Logger.LogDebug("PermissionStore.GetCacheItemAsync: " + string.Join(",", cacheKeys)); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> cacheItems = (await Cache.GetManyAsync(cacheKeys).ConfigureAwait(continueOnCapturedContext: false)).ToList(); |
||||
|
if (cacheItems.All((x) => x.Value != null)) |
||||
|
{ |
||||
|
Logger.LogDebug("Found in the cache: " + string.Join(",", cacheKeys)); |
||||
|
return cacheItems; |
||||
|
} |
||||
|
List<string> list = (from x in cacheItems |
||||
|
where x.Value == null |
||||
|
select x.Key).ToList(); |
||||
|
Logger.LogDebug("Not found in the cache: " + string.Join(",", list)); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> source = await SetCacheItemsAsync(providerName, providerKey, list).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> list2 = new List<KeyValuePair<string, PermissionGrantCacheItem>>(); |
||||
|
foreach (string key in cacheKeys) |
||||
|
{ |
||||
|
KeyValuePair<string, PermissionGrantCacheItem> keyValuePair = source.FirstOrDefault((x) => x.Key == key); |
||||
|
if (keyValuePair.Value == null) |
||||
|
{ |
||||
|
keyValuePair = cacheItems.FirstOrDefault((x) => x.Key == key); |
||||
|
} |
||||
|
list2.Add(new KeyValuePair<string, PermissionGrantCacheItem>(key, keyValuePair.Value)); |
||||
|
} |
||||
|
return list2; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<List<KeyValuePair<string, PermissionGrantCacheItem>>> SetCacheItemsAsync(string providerName, string providerKey, List<string> notCacheKeys) |
||||
|
{ |
||||
|
List<PermissionDefinition> permissions = (await PermissionDefinitionManager.GetPermissionsAsync().ConfigureAwait(continueOnCapturedContext: false)).Where((x) => notCacheKeys.Any((k) => GetPermissionNameFormCacheKeyOrNull(k) == x.Name)).ToList(); |
||||
|
Logger.LogDebug("Getting not cache granted permissions from the repository for this provider name,key: " + providerName + "," + providerKey); |
||||
|
HashSet<string> hashSet = new HashSet<string>((await PermissionGrantRepository.GetListAsync(notCacheKeys.Select(new Func<string, string>(GetPermissionNameFormCacheKeyOrNull)).ToArray(), providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)).Select((p) => p.Name)); |
||||
|
Logger.LogDebug($"Setting the cache items. Count: {permissions.Count}"); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> cacheItems = new List<KeyValuePair<string, PermissionGrantCacheItem>>(); |
||||
|
foreach (PermissionDefinition item in permissions) |
||||
|
{ |
||||
|
bool isGranted = hashSet.Contains(item.Name); |
||||
|
cacheItems.Add(new KeyValuePair<string, PermissionGrantCacheItem>(CalculateCacheKey(item.Name, providerName, providerKey), new PermissionGrantCacheItem(isGranted))); |
||||
|
} |
||||
|
await Cache.SetManyAsync(cacheItems).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
Logger.LogDebug($"Finished setting the cache items. Count: {permissions.Count}"); |
||||
|
return cacheItems; |
||||
|
} |
||||
|
|
||||
|
protected virtual string CalculateCacheKey(string name, string providerName, string providerKey) |
||||
|
{ |
||||
|
return PermissionGrantCacheItem.CalculateCacheKey(name, providerName, providerKey); |
||||
|
} |
||||
|
|
||||
|
protected virtual string GetPermissionNameFormCacheKeyOrNull(string key) |
||||
|
{ |
||||
|
return PermissionGrantCacheItem.GetPermissionNameFormCacheKeyOrNull(key); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,153 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using PermissionGrantCacheItem = WinIn.FasterZ.InterfaceDash.Permissions.PermissionGrantCacheItem; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions |
||||
|
{ |
||||
|
public class PermissionStoreAppService : ApplicationService, IPermissionStore, ITransientDependency |
||||
|
{ |
||||
|
public ILogger<Volo.Abp.PermissionManagement.PermissionStore> Logger { get; set; } |
||||
|
|
||||
|
protected IPermissionGrantRepository PermissionGrantRepository { get; } |
||||
|
|
||||
|
protected IPermissionDefinitionManager PermissionDefinitionManager { get; } |
||||
|
|
||||
|
protected IDistributedCache<PermissionGrantCacheItem> Cache { get; } |
||||
|
|
||||
|
public PermissionStoreAppService(IPermissionGrantRepository permissionGrantRepository, IDistributedCache<PermissionGrantCacheItem> cache, IPermissionDefinitionManager permissionDefinitionManager) |
||||
|
{ |
||||
|
PermissionGrantRepository = permissionGrantRepository; |
||||
|
Cache = cache; |
||||
|
PermissionDefinitionManager = permissionDefinitionManager; |
||||
|
Logger = NullLogger<Volo.Abp.PermissionManagement.PermissionStore>.Instance; |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
[Route("api/permissions/get-isGranted")] |
||||
|
public virtual async Task<bool> IsGrantedAsync(string name, string providerName, string providerKey) |
||||
|
{ |
||||
|
return (await GetCacheItemAsync(name, providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)).IsGranted; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<PermissionGrantCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey) |
||||
|
{ |
||||
|
string cacheKey = CalculateCacheKey(name, providerName, providerKey); |
||||
|
Logger.LogDebug("PermissionStore.GetCacheItemAsync: " + cacheKey); |
||||
|
PermissionGrantCacheItem cacheItem2 = await Cache.GetAsync(cacheKey).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
if (cacheItem2 != null) |
||||
|
{ |
||||
|
Logger.LogDebug("Found in the cache: " + cacheKey); |
||||
|
return cacheItem2; |
||||
|
} |
||||
|
Logger.LogDebug("Not found in the cache: " + cacheKey); |
||||
|
cacheItem2 = new PermissionGrantCacheItem(isGranted: false); |
||||
|
await SetCacheItemsAsync(providerName, providerKey, name, cacheItem2).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
return cacheItem2; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task SetCacheItemsAsync(string providerName, string providerKey, string currentName, PermissionGrantCacheItem currentCacheItem) |
||||
|
{ |
||||
|
IReadOnlyList<PermissionDefinition> permissions = PermissionDefinitionManager.GetPermissionsAsync().Result.ToList(); |
||||
|
Logger.LogDebug("Getting all granted permissions from the repository for this provider name,key: " + providerName + "," + providerKey); |
||||
|
HashSet<string> hashSet = new HashSet<string>((await PermissionGrantRepository.GetListAsync(providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)).Select((PermissionGrant p) => p.Name)); |
||||
|
Logger.LogDebug($"Setting the cache items. Count: {permissions.Count}"); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> list = new List<KeyValuePair<string, PermissionGrantCacheItem>>(); |
||||
|
foreach (PermissionDefinition item in permissions) |
||||
|
{ |
||||
|
bool isGranted = hashSet.Contains(item.Name); |
||||
|
list.Add(new KeyValuePair<string, PermissionGrantCacheItem>(CalculateCacheKey(item.Name, providerName, providerKey), new PermissionGrantCacheItem(isGranted))); |
||||
|
if (item.Name == currentName) |
||||
|
{ |
||||
|
currentCacheItem.IsGranted = isGranted; |
||||
|
} |
||||
|
} |
||||
|
await Cache.SetManyAsync(list).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
Logger.LogDebug($"Finished setting the cache items. Count: {permissions.Count}"); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<MultiplePermissionGrantResult> IsGrantedAsync(string[] names, string providerName, string providerKey) |
||||
|
{ |
||||
|
Check.NotNullOrEmpty(names, "names"); |
||||
|
MultiplePermissionGrantResult result = new MultiplePermissionGrantResult(); |
||||
|
if (names.Length == 1) |
||||
|
{ |
||||
|
string text = names.First(); |
||||
|
Dictionary<string, PermissionGrantResult> result2 = result.Result; |
||||
|
string key = text; |
||||
|
result2.Add(key, (await IsGrantedAsync(names.First(), providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)) ? PermissionGrantResult.Granted : PermissionGrantResult.Undefined); |
||||
|
return result; |
||||
|
} |
||||
|
foreach (KeyValuePair<string, PermissionGrantCacheItem> item in await GetCacheItemsAsync(names, providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)) |
||||
|
{ |
||||
|
result.Result.Add(GetPermissionNameFormCacheKeyOrNull(item.Key), (item.Value != null && item.Value.IsGranted) ? PermissionGrantResult.Granted : PermissionGrantResult.Undefined); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<List<KeyValuePair<string, PermissionGrantCacheItem>>> GetCacheItemsAsync(string[] names, string providerName, string providerKey) |
||||
|
{ |
||||
|
List<string> cacheKeys = names.Select((string x) => CalculateCacheKey(x, providerName, providerKey)).ToList(); |
||||
|
Logger.LogDebug("PermissionStore.GetCacheItemAsync: " + string.Join(",", cacheKeys)); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> cacheItems = (await Cache.GetManyAsync(cacheKeys).ConfigureAwait(continueOnCapturedContext: false)).ToList(); |
||||
|
if (cacheItems.All((KeyValuePair<string, PermissionGrantCacheItem> x) => x.Value != null)) |
||||
|
{ |
||||
|
Logger.LogDebug("Found in the cache: " + string.Join(",", cacheKeys)); |
||||
|
return cacheItems; |
||||
|
} |
||||
|
List<string> list = (from x in cacheItems |
||||
|
where x.Value == null |
||||
|
select x.Key).ToList(); |
||||
|
Logger.LogDebug("Not found in the cache: " + string.Join(",", list)); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> source = await SetCacheItemsAsync(providerName, providerKey, list).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> list2 = new List<KeyValuePair<string, PermissionGrantCacheItem>>(); |
||||
|
foreach (string key in cacheKeys) |
||||
|
{ |
||||
|
KeyValuePair<string, PermissionGrantCacheItem> keyValuePair = source.FirstOrDefault((KeyValuePair<string, PermissionGrantCacheItem> x) => x.Key == key); |
||||
|
if (keyValuePair.Value == null) |
||||
|
{ |
||||
|
keyValuePair = cacheItems.FirstOrDefault((KeyValuePair<string, PermissionGrantCacheItem> x) => x.Key == key); |
||||
|
} |
||||
|
list2.Add(new KeyValuePair<string, PermissionGrantCacheItem>(key, keyValuePair.Value)); |
||||
|
} |
||||
|
return list2; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<List<KeyValuePair<string, PermissionGrantCacheItem>>> SetCacheItemsAsync(string providerName, string providerKey, List<string> notCacheKeys) |
||||
|
{ |
||||
|
List<PermissionDefinition> permissions = PermissionDefinitionManager.GetPermissionsAsync().Result.ToList(); |
||||
|
Logger.LogDebug("Getting not cache granted permissions from the repository for this provider name,key: " + providerName + "," + providerKey); |
||||
|
HashSet<string> hashSet = new HashSet<string>((await PermissionGrantRepository.GetListAsync(notCacheKeys.Select(new Func<string, string>(GetPermissionNameFormCacheKeyOrNull)).ToArray(), providerName, providerKey).ConfigureAwait(continueOnCapturedContext: false)).Select((PermissionGrant p) => p.Name)); |
||||
|
Logger.LogDebug($"Setting the cache items. Count: {permissions.Count}"); |
||||
|
List<KeyValuePair<string, PermissionGrantCacheItem>> cacheItems = new List<KeyValuePair<string, PermissionGrantCacheItem>>(); |
||||
|
foreach (PermissionDefinition item in permissions) |
||||
|
{ |
||||
|
bool isGranted = hashSet.Contains(item.Name); |
||||
|
cacheItems.Add(new KeyValuePair<string, PermissionGrantCacheItem>(CalculateCacheKey(item.Name, providerName, providerKey), new PermissionGrantCacheItem(isGranted))); |
||||
|
} |
||||
|
await Cache.SetManyAsync(cacheItems).ConfigureAwait(continueOnCapturedContext: false); |
||||
|
Logger.LogDebug($"Finished setting the cache items. Count: {permissions.Count}"); |
||||
|
return cacheItems; |
||||
|
} |
||||
|
|
||||
|
protected virtual string CalculateCacheKey(string name, string providerName, string providerKey) |
||||
|
{ |
||||
|
return PermissionGrantCacheItem.CalculateCacheKey(name, providerName, providerKey); |
||||
|
} |
||||
|
|
||||
|
protected virtual string GetPermissionNameFormCacheKeyOrNull(string key) |
||||
|
{ |
||||
|
return PermissionGrantCacheItem.GetPermissionNameFormCacheKeyOrNull(key); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
public static class ZAuthAppBuilderExtensions |
||||
|
{ |
||||
|
internal const string AuthenticationMiddlewareSetKey = "__AuthenticationMiddlewareSet"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Adds the <see cref="ZAuthAppBuilderExtensions"/> to the specified <see cref="IApplicationBuilder"/>, which enables authentication capabilities.
|
||||
|
/// </summary>
|
||||
|
/// <param name="app">The <see cref="IApplicationBuilder"/> to add the middleware to.</param>
|
||||
|
/// <returns>A reference to this instance after the operation has completed.</returns>
|
||||
|
public static IApplicationBuilder UseAuthenticationZ(this IApplicationBuilder app) |
||||
|
{ |
||||
|
if (app == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(nameof(app)); |
||||
|
} |
||||
|
|
||||
|
app.Properties[AuthenticationMiddlewareSetKey] = true; |
||||
|
return app.UseMiddleware<ZAuthenticationMiddleware>(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,91 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Authentication; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Http.Features.Authentication; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Middleware that performs authentication.
|
||||
|
/// </summary>
|
||||
|
public class ZAuthenticationMiddleware |
||||
|
{ |
||||
|
private readonly RequestDelegate _next; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of <see cref="ZAuthenticationMiddleware"/>.
|
||||
|
/// </summary>
|
||||
|
/// <param name="next">The next item in the middleware pipeline.</param>
|
||||
|
/// <param name="schemes">The <see cref="IAuthenticationSchemeProvider"/>.</param>
|
||||
|
public ZAuthenticationMiddleware(RequestDelegate next, IAuthenticationSchemeProvider schemes) |
||||
|
{ |
||||
|
if (next == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(nameof(next)); |
||||
|
} |
||||
|
if (schemes == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(nameof(schemes)); |
||||
|
} |
||||
|
|
||||
|
_next = next; |
||||
|
Schemes = schemes; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="IAuthenticationSchemeProvider"/>.
|
||||
|
/// </summary>
|
||||
|
public IAuthenticationSchemeProvider Schemes { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Invokes the middleware performing authentication.
|
||||
|
/// </summary>
|
||||
|
/// <param name="context">The <see cref="HttpContext"/>.</param>
|
||||
|
public async Task Invoke(HttpContext context) |
||||
|
{ |
||||
|
context.Features.Set<IAuthenticationFeature>(new AuthenticationFeature |
||||
|
{ |
||||
|
OriginalPath = context.Request.Path, |
||||
|
OriginalPathBase = context.Request.PathBase |
||||
|
}); |
||||
|
|
||||
|
// Give any IAuthenticationRequestHandler schemes a chance to handle the request
|
||||
|
var handlers = context.RequestServices.GetRequiredService<IAuthenticationHandlerProvider>(); |
||||
|
foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync()) |
||||
|
{ |
||||
|
var handler = await handlers.GetHandlerAsync(context, scheme.Name) as IAuthenticationRequestHandler; |
||||
|
if (handler != null && await handler.HandleRequestAsync()) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
var defaultAuthenticate = await Schemes.GetDefaultAuthenticateSchemeAsync(); |
||||
|
if (defaultAuthenticate != null) |
||||
|
{ |
||||
|
var result = await context.AuthenticateAsync(defaultAuthenticate.Name); |
||||
|
if (result?.Principal == null) |
||||
|
{ |
||||
|
result = await context.AuthenticateAsync("Identity.Application"); |
||||
|
} |
||||
|
if (result?.Principal == null) |
||||
|
{ |
||||
|
result = await context.AuthenticateAsync("Bearer"); |
||||
|
} |
||||
|
if (result?.Principal != null) |
||||
|
{ |
||||
|
context.User = result.Principal; |
||||
|
} |
||||
|
if (result?.Succeeded ?? false) |
||||
|
{ |
||||
|
var authFeatures = new AuthenticationFeatures(result); |
||||
|
context.Features.Set<IHttpAuthenticationFeature>(authFeatures); |
||||
|
context.Features.Set<IAuthenticateResultFeature>(authFeatures); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await _next(context); |
||||
|
} |
||||
|
} |
@ -0,0 +1,89 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Security.Claims; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Security.Claims; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
|
||||
|
public class ZRolePermissionValueProvider : PermissionValueProvider |
||||
|
{ |
||||
|
public const string ProviderName = "R"; |
||||
|
|
||||
|
public override string Name => ProviderName; |
||||
|
|
||||
|
public ZRolePermissionValueProvider(IPermissionStore permissionStore) |
||||
|
: base(permissionStore) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public override async Task<PermissionGrantResult> CheckAsync(PermissionValueCheckContext context) |
||||
|
{ |
||||
|
var roles = context.Principal?.FindAll(ClaimTypes.Role).Select(c => c.Value).ToArray(); |
||||
|
if (roles == null || !roles.Any()) |
||||
|
{ |
||||
|
roles = context.Principal?.FindAll(AbpClaimTypes.Role).Select(c => c.Value).ToArray(); |
||||
|
} |
||||
|
if (roles == null || !roles.Any()) |
||||
|
{ |
||||
|
return PermissionGrantResult.Undefined; |
||||
|
} |
||||
|
|
||||
|
foreach (var role in roles.Distinct()) |
||||
|
{ |
||||
|
if (await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, role)) |
||||
|
{ |
||||
|
return PermissionGrantResult.Granted; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return PermissionGrantResult.Undefined; |
||||
|
} |
||||
|
|
||||
|
public override async Task<MultiplePermissionGrantResult> CheckAsync(PermissionValuesCheckContext context) |
||||
|
{ |
||||
|
var permissionNames = context.Permissions.Select(x => x.Name).Distinct().ToList(); |
||||
|
Check.NotNullOrEmpty(permissionNames, nameof(permissionNames)); |
||||
|
|
||||
|
var result = new MultiplePermissionGrantResult(permissionNames.ToArray()); |
||||
|
|
||||
|
var roles = context.Principal?.FindAll(ClaimTypes.Role).Select(c => c.Value).ToArray(); |
||||
|
if (roles == null || !roles.Any()) |
||||
|
{ |
||||
|
roles = context.Principal?.FindAll(AbpClaimTypes.Role).Select(c => c.Value).ToArray(); |
||||
|
} |
||||
|
if (roles == null || !roles.Any()) |
||||
|
{ |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
foreach (var role in roles.Distinct()) |
||||
|
{ |
||||
|
var multipleResult = await PermissionStore.IsGrantedAsync(permissionNames.ToArray(), Name, role); |
||||
|
|
||||
|
foreach (var grantResult in multipleResult.Result.Where(grantResult => |
||||
|
result.Result.ContainsKey(grantResult.Key) && |
||||
|
result.Result[grantResult.Key] == PermissionGrantResult.Undefined && |
||||
|
grantResult.Value != PermissionGrantResult.Undefined)) |
||||
|
{ |
||||
|
result.Result[grantResult.Key] = grantResult.Value; |
||||
|
permissionNames.RemoveAll(x => x == grantResult.Key); |
||||
|
} |
||||
|
|
||||
|
if (result.AllGranted || result.AllProhibited) |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
if (permissionNames.IsNullOrEmpty()) |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
using System.Runtime.CompilerServices; |
||||
|
[assembly:InternalsVisibleToAttribute("WinIn.FasterZ.AuthSiteCenter.Application.Tests")] |
@ -0,0 +1,37 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace>WinIn.FasterZ.AuthSiteCenter</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Domain\WinIn.FasterZ.AuthSiteCenter.Domain.csproj" /> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Application.Contracts\WinIn.FasterZ.AuthSiteCenter.Application.Contracts.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.2.0" /> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" /> |
||||
|
<PackageReference Include="OpenIddict.Server" Version="4.4.0" /> |
||||
|
<PackageReference Include="Volo.Abp.Account.Application" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.Identity.Application" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.Application" Version="7.3.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Reference Include="Microsoft.AspNetCore.Authentication"> |
||||
|
<HintPath>C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\7.0.10\Microsoft.AspNetCore.Authentication.dll</HintPath> |
||||
|
</Reference> |
||||
|
<Reference Include="Microsoft.AspNetCore.Authentication.Cookies"> |
||||
|
<HintPath>C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\7.0.10\Microsoft.AspNetCore.Authentication.Cookies.dll</HintPath> |
||||
|
</Reference> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,14 @@ |
|||||
|
using WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.DbMigrator; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpAutofacModule), |
||||
|
typeof(AuthSiteCenterEntityFrameworkCoreModule), |
||||
|
typeof(AuthSiteCenterApplicationContractsModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Data; |
||||
|
using Serilog; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.DbMigrator; |
||||
|
|
||||
|
public class DbMigratorHostedService : IHostedService |
||||
|
{ |
||||
|
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime, IConfiguration configuration) |
||||
|
{ |
||||
|
_hostApplicationLifetime = hostApplicationLifetime; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public async Task StartAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
using (var application = await AbpApplicationFactory.CreateAsync<AuthSiteCenterDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(_configuration); |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
options.AddDataMigrationEnvironment(); |
||||
|
})) |
||||
|
{ |
||||
|
await application.InitializeAsync(); |
||||
|
|
||||
|
await application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<AuthSiteCenterDbMigrationService>() |
||||
|
.MigrateAsync(); |
||||
|
|
||||
|
await application.ShutdownAsync(); |
||||
|
|
||||
|
_hostApplicationLifetime.StopApplication(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public Task StopAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
using System.IO; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.DbMigrator; |
||||
|
|
||||
|
class Program |
||||
|
{ |
||||
|
static async Task Main(string[] args) |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("WinIn.FasterZ.AuthSiteCenter", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("WinIn.FasterZ.AuthSiteCenter", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
|
.WriteTo.Async(c => c.Console()) |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
await CreateHostBuilder(args).RunConsoleAsync(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) => |
||||
|
Host.CreateDefaultBuilder(args) |
||||
|
.AddAppSettingsSecretsJson() |
||||
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
||||
|
.ConfigureServices((hostContext, services) => |
||||
|
{ |
||||
|
services.AddHostedService<DbMigratorHostedService>(); |
||||
|
}); |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
|
</Content> |
||||
|
<None Remove="appsettings.secrets.json" /> |
||||
|
<Content Include="appsettings.secrets.json"> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="7.3.2" /> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Application.Contracts\WinIn.FasterZ.AuthSiteCenter.Application.Contracts.csproj" /> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore\WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,30 @@ |
|||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=dev.ccwin-in.com,13319;Database=WMS_DongYang_Faster_AuthSiteCenter;uid=ccwin-in;pwd=Microsoft@2022;timeout=6000;Encrypt=False;" |
||||
|
}, |
||||
|
"Redis": { |
||||
|
"Configuration": "127.0.0.1" |
||||
|
}, |
||||
|
"OpenIddict": { |
||||
|
"Applications": { |
||||
|
"AuthSiteCenter_Web": { |
||||
|
"ClientId": "AuthSiteCenter_Web", |
||||
|
"ClientSecret": "1q2w3e*", |
||||
|
"RootUrl": "http://localhost:60020" |
||||
|
}, |
||||
|
"AuthSiteCenter_App": { |
||||
|
"ClientId": "AuthSiteCenter_App", |
||||
|
"RootUrl": "http://localhost:4200" |
||||
|
}, |
||||
|
"AuthSiteCenter_BlazorServerTiered": { |
||||
|
"ClientId": "AuthSiteCenter_BlazorServerTiered", |
||||
|
"ClientSecret": "1q2w3e*", |
||||
|
"RootUrl": "https://localhost:44316" |
||||
|
}, |
||||
|
"AuthSiteCenter_Swagger": { |
||||
|
"ClientId": "AuthSiteCenter_Swagger", |
||||
|
"RootUrl": "https://localhost:44326" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
{ |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
public static class AuthSiteCenterDomainErrorCodes |
||||
|
{ |
||||
|
/* You can add your business exception error codes here, as constants */ |
||||
|
} |
@ -0,0 +1,58 @@ |
|||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using Volo.Abp.AuditLogging; |
||||
|
using Volo.Abp.BackgroundJobs; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Localization.ExceptionHandling; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.OpenIddict; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
using Volo.Abp.Validation.Localization; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpAuditLoggingDomainSharedModule), |
||||
|
typeof(AbpBackgroundJobsDomainSharedModule), |
||||
|
typeof(AbpFeatureManagementDomainSharedModule), |
||||
|
typeof(AbpIdentityDomainSharedModule), |
||||
|
typeof(AbpOpenIddictDomainSharedModule), |
||||
|
typeof(AbpPermissionManagementDomainSharedModule), |
||||
|
typeof(AbpSettingManagementDomainSharedModule), |
||||
|
typeof(AbpTenantManagementDomainSharedModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterDomainSharedModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
AuthSiteCenterGlobalFeatureConfigurator.Configure(); |
||||
|
AuthSiteCenterModuleExtensionConfigurator.Configure(); |
||||
|
} |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AuthSiteCenterDomainSharedModule>(); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Add<AuthSiteCenterResource>("en") |
||||
|
.AddBaseTypes(typeof(AbpValidationResource)) |
||||
|
.AddVirtualJson("/Localization/AuthSiteCenter"); |
||||
|
|
||||
|
options.DefaultResourceType = typeof(AuthSiteCenterResource); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpExceptionLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.MapCodeNamespace("AuthSiteCenter", typeof(AuthSiteCenterResource)); |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
public static class AuthSiteCenterGlobalFeatureConfigurator |
||||
|
{ |
||||
|
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
||||
|
|
||||
|
public static void Configure() |
||||
|
{ |
||||
|
OneTimeRunner.Run(() => |
||||
|
{ |
||||
|
/* You can configure (enable/disable) global features of the used modules here. |
||||
|
* |
||||
|
* YOU CAN SAFELY DELETE THIS CLASS AND REMOVE ITS USAGES IF YOU DON'T NEED TO IT! |
||||
|
* |
||||
|
* Please refer to the documentation to lear more about the Global Features System: |
||||
|
* https://docs.abp.io/en/abp/latest/Global-Features
|
||||
|
*/ |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,73 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.ObjectExtending; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
public static class AuthSiteCenterModuleExtensionConfigurator |
||||
|
{ |
||||
|
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
||||
|
|
||||
|
public static void Configure() |
||||
|
{ |
||||
|
OneTimeRunner.Run(() => |
||||
|
{ |
||||
|
ConfigureExistingProperties(); |
||||
|
ConfigureExtraProperties(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private static void ConfigureExistingProperties() |
||||
|
{ |
||||
|
/* You can change max lengths for properties of the |
||||
|
* entities defined in the modules used by your application. |
||||
|
* |
||||
|
* Example: Change user and role name max lengths |
||||
|
|
||||
|
IdentityUserConsts.MaxNameLength = 99; |
||||
|
IdentityRoleConsts.MaxNameLength = 99; |
||||
|
|
||||
|
* Notice: It is not suggested to change property lengths |
||||
|
* unless you really need it. Go with the standard values wherever possible. |
||||
|
* |
||||
|
* If you are using EF Core, you will need to run the add-migration command after your changes. |
||||
|
*/ |
||||
|
} |
||||
|
|
||||
|
private static void ConfigureExtraProperties() |
||||
|
{ |
||||
|
/* You can configure extra properties for the |
||||
|
* entities defined in the modules used by your application. |
||||
|
* |
||||
|
* This class can be used to define these extra properties |
||||
|
* with a high level, easy to use API. |
||||
|
* |
||||
|
* Example: Add a new property to the user entity of the identity module |
||||
|
|
||||
|
ObjectExtensionManager.Instance.Modules() |
||||
|
.ConfigureIdentity(identity => |
||||
|
{ |
||||
|
identity.ConfigureUser(user => |
||||
|
{ |
||||
|
user.AddOrUpdateProperty<string>( //property type: string
|
||||
|
"SocialSecurityNumber", //property name
|
||||
|
property => |
||||
|
{ |
||||
|
//validation rules
|
||||
|
property.Attributes.Add(new RequiredAttribute()); |
||||
|
property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); |
||||
|
|
||||
|
property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true; |
||||
|
|
||||
|
//...other configurations for this property
|
||||
|
} |
||||
|
); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
* See the documentation for more: |
||||
|
* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
|
||||
|
*/ |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "ar", |
||||
|
"texts": { |
||||
|
"Menu:Home": "الرئيسية", |
||||
|
"Menu:Home": "الصفحة الرئيسية", |
||||
|
"LongWelcomeMessage": "مرحبا بكم في التطبيق. هذا مشروع بدء تشغيل يعتمد على إطار عمل ABP. لمزيد من المعلومات ، يرجى زيارة abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "cs", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Úvod", |
||||
|
"Welcome": "Vítejte", |
||||
|
"LongWelcomeMessage": "Vítejte v aplikaci. Toto je startovací projekt založený na ABP frameworku. Pro více informací, navštivte abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "de", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Home", |
||||
|
"Welcome": "Willkommen", |
||||
|
"LongWelcomeMessage": "Willkommen bei der Anwendung. Dies ist ein Startup-Projekt, das auf dem ABP-Framework basiert. Weitere Informationen finden Sie unter abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "en-GB", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Home", |
||||
|
"Welcome": "Welcome", |
||||
|
"LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "en", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Home", |
||||
|
"Welcome": "Welcome", |
||||
|
"LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "es", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Inicio", |
||||
|
"Welcome": "Bienvenido", |
||||
|
"LongWelcomeMessage": "Bienvenido a la aplicación, este es un proyecto base basado en el framework ABP. Para más información, visita abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "fi", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Koti", |
||||
|
"Welcome": "Tervetuloa", |
||||
|
"LongWelcomeMessage": "Tervetuloa sovellukseen. Tämä on ABP-kehykseen perustuva käynnistysprojekti. Lisätietoja on osoitteessa abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "fr", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Accueil", |
||||
|
"Welcome": "Bienvenue", |
||||
|
"LongWelcomeMessage": "Bienvenue dans l'application. Il s'agit d'un projet de démarrage basé sur le framework ABP. Pour plus d'informations, visitez abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "hi", |
||||
|
"texts": { |
||||
|
"Menu:Home": "घर", |
||||
|
"Welcome": "स्वागत हे", |
||||
|
"LongWelcomeMessage": "आवेदन करने के लिए आपका स्वागत है। यह एबीपी ढांचे पर आधारित एक स्टार्टअप परियोजना है। अधिक जानकारी के लिए, abp.io पर जाएं।" |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "hr", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Početna", |
||||
|
"Welcome": "Dobrodošli", |
||||
|
"LongWelcomeMessage": "Dobrodošli u aplikaciju. Ovo je startup projekt temeljen na ABP framework-u. Za više informacija posjetite abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "hu", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Kezdőlap", |
||||
|
"Welcome": "Üdvözlöm", |
||||
|
"LongWelcomeMessage": "Üdvözöljük az alkalmazásban. Ez egy ABP keretrendszeren alapuló startup projekt. További információkért látogasson el az abp.io oldalra." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "is", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Heim", |
||||
|
"Welcome": "Velkomin", |
||||
|
"LongWelcomeMessage": "Verið velkomin í forritið. Þetta er startup verkefni sem byggir á ABP. Nánari upplýsingar er að finna á abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "it", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Home", |
||||
|
"Welcome": "Benvenuto", |
||||
|
"LongWelcomeMessage": "Benvenuto nell'applicazione. Questo è un progetto di avvio basato sul framework ABP. Per ulteriori informazioni, visita abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "nl", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Home", |
||||
|
"Welcome": "Welkom", |
||||
|
"LongWelcomeMessage": "Welkom bij de applicatie. Dit is een startup-project gebaseerd op het ABP-framework. Bezoek abp.io voor meer informatie." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "pl-PL", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Home", |
||||
|
"Welcome": "Witaj", |
||||
|
"LongWelcomeMessage": "Witaj w aplikacji. To jest inicjalny projekt bazujący na ABP framework. Po więcej informacji odwiedź stronę abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "pt-BR", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Principal", |
||||
|
"Welcome": "Seja bem-vindo!", |
||||
|
"LongWelcomeMessage": "Bem-vindo a esta aplicação. Este é um projeto inicial baseado no ABP framework. Para mais informações, visite abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "ro-RO", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Acasă", |
||||
|
"Welcome": "Bun venit", |
||||
|
"LongWelcomeMessage": "Bun venit la aplicaţie. Acesta este un proiect de pornire bazat pe framework-ul ABP. Pentru mai multe informaţii, vizitaţi, visit abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "ru", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Главная", |
||||
|
"Welcome": "Добро пожаловать", |
||||
|
"LongWelcomeMessage": "Добро пожаловать в приложение. Этот запущенный проект основан на фреймворке ABP. Для получения дополнительной информации посетите сайт abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "sk", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Domov", |
||||
|
"Welcome": "Vitajte", |
||||
|
"LongWelcomeMessage": "Vitajte v aplikácii. Toto je štartovací projekt založený na ABP frameworku. Viac informácií nájdete na stránke abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "sl", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Domov", |
||||
|
"Welcome": "Dobrodošli", |
||||
|
"LongWelcomeMessage": "Dobrodošli v aplikaciji. To je začetni projekt na osnovi okolja ABP. Za več informacij obiščite abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "tr", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Ana sayfa", |
||||
|
"Welcome": "Hoşgeldiniz", |
||||
|
"LongWelcomeMessage": "Uygulamaya hoşgeldiniz. Bu, ABP framework'ü üzerine bina edilmiş bir başlangıç projesidir. Daha fazla bilgi için abp.io adresini ziyaret edebilirsiniz." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "vi", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Trang chủ", |
||||
|
"Welcome": "Chào mừng bạn", |
||||
|
"LongWelcomeMessage": "Chào mừng bạn đến ứng dụng. Đây là một dự án khởi nghiệp dựa trên khung ABP. Để biết thêm thông tin, hãy truy cập abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"Menu:Home": "首页", |
||||
|
"Welcome": "欢迎", |
||||
|
"LongWelcomeMessage": "欢迎来到该应用程序. 这是一个基于ABP框架的启动项目. 有关更多信息, 请访问 abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hant", |
||||
|
"texts": { |
||||
|
"Menu:Home": "首頁", |
||||
|
"Welcome": "歡迎", |
||||
|
"LongWelcomeMessage": "歡迎來到此應用程式. 這是一個基於ABP框架的起始專案. 有關更多訊息, 請瀏覽 abp.io." |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
using Volo.Abp.Localization; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
|
||||
|
[LocalizationResourceName("AuthSiteCenter")] |
||||
|
public class AuthSiteCenterResource |
||||
|
{ |
||||
|
|
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
namespace WinIn.FasterZ.AuthSiteCenter.MultiTenancy; |
||||
|
|
||||
|
public static class MultiTenancyConsts |
||||
|
{ |
||||
|
/* Enable/disable multi-tenancy easily in a single point. |
||||
|
* If you will never need to multi-tenancy, you can remove |
||||
|
* related modules and code parts, including this file. |
||||
|
*/ |
||||
|
public const bool IsEnabled = true; |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace>WinIn.FasterZ.AuthSiteCenter</RootNamespace> |
||||
|
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Identity.Domain.Shared" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain.Shared" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.AuditLogging.Domain.Shared" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.Domain.Shared" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.Domain.Shared" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Shared" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.Domain.Shared" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.OpenIddict.Domain.Shared" Version="7.3.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<EmbeddedResource Include="Localization\AuthSiteCenter\*.json" /> |
||||
|
<Content Remove="Localization\AuthSiteCenter\*.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,8 @@ |
|||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
public static class AuthSiteCenterConsts |
||||
|
{ |
||||
|
public const string DbTablePrefix = "App"; |
||||
|
|
||||
|
public const string DbSchema = null; |
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.MultiTenancy; |
||||
|
using Volo.Abp.AuditLogging; |
||||
|
using Volo.Abp.BackgroundJobs; |
||||
|
using Volo.Abp.Emailing; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.OpenIddict; |
||||
|
using Volo.Abp.PermissionManagement.Identity; |
||||
|
using Volo.Abp.PermissionManagement.OpenIddict; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AuthSiteCenterDomainSharedModule), |
||||
|
typeof(AbpAuditLoggingDomainModule), |
||||
|
typeof(AbpBackgroundJobsDomainModule), |
||||
|
typeof(AbpFeatureManagementDomainModule), |
||||
|
typeof(AbpIdentityDomainModule), |
||||
|
typeof(AbpOpenIddictDomainModule), |
||||
|
typeof(AbpPermissionManagementDomainOpenIddictModule), |
||||
|
typeof(AbpPermissionManagementDomainIdentityModule), |
||||
|
typeof(AbpSettingManagementDomainModule), |
||||
|
typeof(AbpTenantManagementDomainModule), |
||||
|
typeof(AbpEmailingModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterDomainModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية", "ae")); |
||||
|
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English", "gb")); |
||||
|
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); |
||||
|
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); |
||||
|
options.Languages.Add(new LanguageInfo("hr", "hr", "Croatian")); |
||||
|
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish", "fi")); |
||||
|
options.Languages.Add(new LanguageInfo("fr", "fr", "Français", "fr")); |
||||
|
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); |
||||
|
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); |
||||
|
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); |
||||
|
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский", "ru")); |
||||
|
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak", "sk")); |
||||
|
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe", "tr")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); |
||||
|
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de")); |
||||
|
options.Languages.Add(new LanguageInfo("es", "es", "Español")); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpMultiTenancyOptions>(options => |
||||
|
{ |
||||
|
options.IsEnabled = MultiTenancyConsts.IsEnabled; |
||||
|
}); |
||||
|
|
||||
|
#if DEBUG
|
||||
|
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); |
||||
|
#endif
|
||||
|
} |
||||
|
} |
@ -0,0 +1,218 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Diagnostics; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Data; |
||||
|
|
||||
|
public class AuthSiteCenterDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<AuthSiteCenterDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IEnumerable<IAuthSiteCenterDbSchemaMigrator> _dbSchemaMigrators; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public AuthSiteCenterDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IEnumerable<IAuthSiteCenterDbSchemaMigrator> dbSchemaMigrators, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrators = dbSchemaMigrators; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<AuthSiteCenterDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation( |
||||
|
$"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
|
||||
|
foreach (var migrator in _dbSchemaMigrators) |
||||
|
{ |
||||
|
await migrator.MigrateAsync(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id) |
||||
|
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue) |
||||
|
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return dbMigrationsProjectFolder != null; |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
return dbMigrationsProjectFolder != null && Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string? GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src"); |
||||
|
|
||||
|
return Directory.GetDirectories(srcDirectoryPath) |
||||
|
.FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore")); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (currentDirectory != null && Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (currentDirectory != null && Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Data; |
||||
|
|
||||
|
public interface IAuthSiteCenterDbSchemaMigrator |
||||
|
{ |
||||
|
Task MigrateAsync(); |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Data; |
||||
|
|
||||
|
/* This is used if database provider does't define |
||||
|
* IAuthSiteCenterDbSchemaMigrator implementation. |
||||
|
*/ |
||||
|
public class NullAuthSiteCenterDbSchemaMigrator : IAuthSiteCenterDbSchemaMigrator, ITransientDependency |
||||
|
{ |
||||
|
public Task MigrateAsync() |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
@ -0,0 +1,415 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text.Json; |
||||
|
using System.Threading.Tasks; |
||||
|
using JetBrains.Annotations; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using OpenIddict.Abstractions; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.OpenIddict.Applications; |
||||
|
using Volo.Abp.OpenIddict.Scopes; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.Uow; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.OpenIddict; |
||||
|
|
||||
|
/* Creates initial data that is needed to property run the application |
||||
|
* and make client-to-server communication possible. |
||||
|
*/ |
||||
|
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency |
||||
|
{ |
||||
|
private readonly IConfiguration _configuration; |
||||
|
private readonly IOpenIddictApplicationRepository _openIddictApplicationRepository; |
||||
|
private readonly IAbpApplicationManager _applicationManager; |
||||
|
private readonly IOpenIddictScopeRepository _openIddictScopeRepository; |
||||
|
private readonly IOpenIddictScopeManager _scopeManager; |
||||
|
private readonly IPermissionDataSeeder _permissionDataSeeder; |
||||
|
private readonly IStringLocalizer<OpenIddictResponse> L; |
||||
|
|
||||
|
public OpenIddictDataSeedContributor( |
||||
|
IConfiguration configuration, |
||||
|
IOpenIddictApplicationRepository openIddictApplicationRepository, |
||||
|
IAbpApplicationManager applicationManager, |
||||
|
IOpenIddictScopeRepository openIddictScopeRepository, |
||||
|
IOpenIddictScopeManager scopeManager, |
||||
|
IPermissionDataSeeder permissionDataSeeder, |
||||
|
IStringLocalizer<OpenIddictResponse> l ) |
||||
|
{ |
||||
|
_configuration = configuration; |
||||
|
_openIddictApplicationRepository = openIddictApplicationRepository; |
||||
|
_applicationManager = applicationManager; |
||||
|
_openIddictScopeRepository = openIddictScopeRepository; |
||||
|
_scopeManager = scopeManager; |
||||
|
_permissionDataSeeder = permissionDataSeeder; |
||||
|
L = l; |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task SeedAsync(DataSeedContext context) |
||||
|
{ |
||||
|
await CreateScopesAsync(); |
||||
|
await CreateApplicationsAsync(); |
||||
|
} |
||||
|
|
||||
|
private async Task CreateScopesAsync() |
||||
|
{ |
||||
|
if (await _openIddictScopeRepository.FindByNameAsync("AuthSiteCenter") == null) |
||||
|
{ |
||||
|
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor { |
||||
|
Name = "AuthSiteCenter", DisplayName = "AuthSiteCenter API", Resources = { "AuthSiteCenter" } |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task CreateApplicationsAsync() |
||||
|
{ |
||||
|
var commonScopes = new List<string> { |
||||
|
OpenIddictConstants.Permissions.Scopes.Address, |
||||
|
OpenIddictConstants.Permissions.Scopes.Email, |
||||
|
OpenIddictConstants.Permissions.Scopes.Phone, |
||||
|
OpenIddictConstants.Permissions.Scopes.Profile, |
||||
|
OpenIddictConstants.Permissions.Scopes.Roles, |
||||
|
"AuthSiteCenter" |
||||
|
}; |
||||
|
|
||||
|
var configurationSection = _configuration.GetSection("OpenIddict:Applications"); |
||||
|
|
||||
|
//Web Client
|
||||
|
var webClientId = configurationSection["AuthSiteCenter_Web:ClientId"]; |
||||
|
if (!webClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var webClientRootUrl = configurationSection["AuthSiteCenter_Web:RootUrl"].EnsureEndsWith('/'); |
||||
|
|
||||
|
/* AuthSiteCenter_Web client is only needed if you created a tiered |
||||
|
* solution. Otherwise, you can delete this client. */ |
||||
|
await CreateApplicationAsync( |
||||
|
name: webClientId!, |
||||
|
type: OpenIddictConstants.ClientTypes.Confidential, |
||||
|
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
||||
|
displayName: "Web Application", |
||||
|
secret: configurationSection["AuthSiteCenter_Web:ClientSecret"] ?? "1q2w3e*", |
||||
|
grantTypes: new List<string> //Hybrid flow
|
||||
|
{ |
||||
|
OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit |
||||
|
}, |
||||
|
scopes: commonScopes, |
||||
|
redirectUri: $"{webClientRootUrl}signin-oidc", |
||||
|
clientUri: webClientRootUrl, |
||||
|
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
//Console Test / Angular Client
|
||||
|
var consoleAndAngularClientId = configurationSection["AuthSiteCenter_App:ClientId"]; |
||||
|
if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var consoleAndAngularClientRootUrl = configurationSection["AuthSiteCenter_App:RootUrl"]?.TrimEnd('/'); |
||||
|
await CreateApplicationAsync( |
||||
|
name: consoleAndAngularClientId!, |
||||
|
type: OpenIddictConstants.ClientTypes.Public, |
||||
|
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
||||
|
displayName: "Console Test / Angular Application", |
||||
|
secret: null, |
||||
|
grantTypes: new List<string> { |
||||
|
OpenIddictConstants.GrantTypes.AuthorizationCode, |
||||
|
OpenIddictConstants.GrantTypes.Password, |
||||
|
OpenIddictConstants.GrantTypes.ClientCredentials, |
||||
|
OpenIddictConstants.GrantTypes.RefreshToken |
||||
|
}, |
||||
|
scopes: commonScopes, |
||||
|
redirectUri: consoleAndAngularClientRootUrl, |
||||
|
clientUri: consoleAndAngularClientRootUrl, |
||||
|
postLogoutRedirectUri: consoleAndAngularClientRootUrl |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// Blazor Client
|
||||
|
var blazorClientId = configurationSection["AuthSiteCenter_Blazor:ClientId"]; |
||||
|
if (!blazorClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var blazorRootUrl = configurationSection["AuthSiteCenter_Blazor:RootUrl"]?.TrimEnd('/'); |
||||
|
|
||||
|
await CreateApplicationAsync( |
||||
|
name: blazorClientId!, |
||||
|
type: OpenIddictConstants.ClientTypes.Public, |
||||
|
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
||||
|
displayName: "Blazor Application", |
||||
|
secret: null, |
||||
|
grantTypes: new List<string> { OpenIddictConstants.GrantTypes.AuthorizationCode, }, |
||||
|
scopes: commonScopes, |
||||
|
redirectUri: $"{blazorRootUrl}/authentication/login-callback", |
||||
|
clientUri: blazorRootUrl, |
||||
|
postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback" |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// Blazor Server Tiered Client
|
||||
|
var blazorServerTieredClientId = configurationSection["AuthSiteCenter_BlazorServerTiered:ClientId"]; |
||||
|
if (!blazorServerTieredClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var blazorServerTieredRootUrl = |
||||
|
configurationSection["AuthSiteCenter_BlazorServerTiered:RootUrl"].EnsureEndsWith('/'); |
||||
|
|
||||
|
await CreateApplicationAsync( |
||||
|
name: blazorServerTieredClientId!, |
||||
|
type: OpenIddictConstants.ClientTypes.Confidential, |
||||
|
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
||||
|
displayName: "Blazor Server Application", |
||||
|
secret: configurationSection["AuthSiteCenter_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*", |
||||
|
grantTypes: new List<string> //Hybrid flow
|
||||
|
{ |
||||
|
OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit |
||||
|
}, |
||||
|
scopes: commonScopes, |
||||
|
redirectUri: $"{blazorServerTieredRootUrl}signin-oidc", |
||||
|
clientUri: blazorServerTieredRootUrl, |
||||
|
postLogoutRedirectUri: $"{blazorServerTieredRootUrl}signout-callback-oidc" |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// Swagger Client
|
||||
|
var swaggerClientId = configurationSection["AuthSiteCenter_Swagger:ClientId"]; |
||||
|
if (!swaggerClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var swaggerRootUrl = configurationSection["AuthSiteCenter_Swagger:RootUrl"]?.TrimEnd('/'); |
||||
|
|
||||
|
await CreateApplicationAsync( |
||||
|
name: swaggerClientId!, |
||||
|
type: OpenIddictConstants.ClientTypes.Public, |
||||
|
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
||||
|
displayName: "Swagger Application", |
||||
|
secret: null, |
||||
|
grantTypes: new List<string> { OpenIddictConstants.GrantTypes.AuthorizationCode, }, |
||||
|
scopes: commonScopes, |
||||
|
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", |
||||
|
clientUri: swaggerRootUrl |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task CreateApplicationAsync( |
||||
|
[NotNull] string name, |
||||
|
[NotNull] string type, |
||||
|
[NotNull] string consentType, |
||||
|
string displayName, |
||||
|
string? secret, |
||||
|
List<string> grantTypes, |
||||
|
List<string> scopes, |
||||
|
string? clientUri = null, |
||||
|
string? redirectUri = null, |
||||
|
string? postLogoutRedirectUri = null, |
||||
|
List<string>? permissions = null) |
||||
|
{ |
||||
|
if (!string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Public, |
||||
|
StringComparison.OrdinalIgnoreCase)) |
||||
|
{ |
||||
|
throw new BusinessException(L["NoClientSecretCanBeSetForPublicApplications"]); |
||||
|
} |
||||
|
|
||||
|
if (string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Confidential, |
||||
|
StringComparison.OrdinalIgnoreCase)) |
||||
|
{ |
||||
|
throw new BusinessException(L["TheClientSecretIsRequiredForConfidentialApplications"]); |
||||
|
} |
||||
|
|
||||
|
var client = await _openIddictApplicationRepository.FindByClientIdAsync(name); |
||||
|
|
||||
|
var application = new AbpApplicationDescriptor { |
||||
|
ClientId = name, |
||||
|
Type = type, |
||||
|
ClientSecret = secret, |
||||
|
ConsentType = consentType, |
||||
|
DisplayName = displayName, |
||||
|
ClientUri = clientUri, |
||||
|
}; |
||||
|
|
||||
|
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes)); |
||||
|
Check.NotNullOrEmpty(scopes, nameof(scopes)); |
||||
|
|
||||
|
if (new[] { OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit }.All( |
||||
|
grantTypes.Contains)) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken); |
||||
|
|
||||
|
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken); |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeToken); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout); |
||||
|
} |
||||
|
|
||||
|
var buildInGrantTypes = new[] { |
||||
|
OpenIddictConstants.GrantTypes.Implicit, OpenIddictConstants.GrantTypes.Password, |
||||
|
OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.ClientCredentials, |
||||
|
OpenIddictConstants.GrantTypes.DeviceCode, OpenIddictConstants.GrantTypes.RefreshToken |
||||
|
}; |
||||
|
|
||||
|
foreach (var grantType in grantTypes) |
||||
|
{ |
||||
|
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode); |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Code); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || |
||||
|
grantType == OpenIddictConstants.GrantTypes.Implicit) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || |
||||
|
grantType == OpenIddictConstants.GrantTypes.ClientCredentials || |
||||
|
grantType == OpenIddictConstants.GrantTypes.Password || |
||||
|
grantType == OpenIddictConstants.GrantTypes.RefreshToken || |
||||
|
grantType == OpenIddictConstants.GrantTypes.DeviceCode) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Token); |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Revocation); |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Introspection); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.ClientCredentials) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Implicit); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.Password) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Password); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.RefreshToken) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.RefreshToken); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode); |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device); |
||||
|
} |
||||
|
|
||||
|
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdToken); |
||||
|
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken); |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Token); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (!buildInGrantTypes.Contains(grantType)) |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.GrantType + grantType); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
var buildInScopes = new[] { |
||||
|
OpenIddictConstants.Permissions.Scopes.Address, OpenIddictConstants.Permissions.Scopes.Email, |
||||
|
OpenIddictConstants.Permissions.Scopes.Phone, OpenIddictConstants.Permissions.Scopes.Profile, |
||||
|
OpenIddictConstants.Permissions.Scopes.Roles |
||||
|
}; |
||||
|
|
||||
|
foreach (var scope in scopes) |
||||
|
{ |
||||
|
if (buildInScopes.Contains(scope)) |
||||
|
{ |
||||
|
application.Permissions.Add(scope); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.Scope + scope); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (redirectUri != null) |
||||
|
{ |
||||
|
if (!redirectUri.IsNullOrEmpty()) |
||||
|
{ |
||||
|
if (!Uri.TryCreate(redirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString()) |
||||
|
{ |
||||
|
throw new BusinessException(L["InvalidRedirectUri", redirectUri]); |
||||
|
} |
||||
|
|
||||
|
if (application.RedirectUris.All(x => x != uri)) |
||||
|
{ |
||||
|
application.RedirectUris.Add(uri); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (postLogoutRedirectUri != null) |
||||
|
{ |
||||
|
if (!postLogoutRedirectUri.IsNullOrEmpty()) |
||||
|
{ |
||||
|
if (!Uri.TryCreate(postLogoutRedirectUri, UriKind.Absolute, out var uri) || |
||||
|
!uri.IsWellFormedOriginalString()) |
||||
|
{ |
||||
|
throw new BusinessException(L["InvalidPostLogoutRedirectUri", postLogoutRedirectUri]); |
||||
|
} |
||||
|
|
||||
|
if (application.PostLogoutRedirectUris.All(x => x != uri)) |
||||
|
{ |
||||
|
application.PostLogoutRedirectUris.Add(uri); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (permissions != null) |
||||
|
{ |
||||
|
await _permissionDataSeeder.SeedAsync( |
||||
|
ClientPermissionValueProvider.ProviderName, |
||||
|
name, |
||||
|
permissions, |
||||
|
null |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
if (client == null) |
||||
|
{ |
||||
|
await _applicationManager.CreateAsync(application); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (!HasSameRedirectUris(client, application)) |
||||
|
{ |
||||
|
client.RedirectUris = JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/'))); |
||||
|
client.PostLogoutRedirectUris = JsonSerializer.Serialize(application.PostLogoutRedirectUris.Select(q => q.ToString().TrimEnd('/'))); |
||||
|
|
||||
|
await _applicationManager.UpdateAsync(client.ToModel()); |
||||
|
} |
||||
|
|
||||
|
if (!HasSameScopes(client, application)) |
||||
|
{ |
||||
|
client.Permissions = JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString())); |
||||
|
await _applicationManager.UpdateAsync(client.ToModel()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool HasSameRedirectUris(OpenIddictApplication existingClient, AbpApplicationDescriptor application) |
||||
|
{ |
||||
|
return existingClient.RedirectUris == JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/'))); |
||||
|
} |
||||
|
|
||||
|
private bool HasSameScopes(OpenIddictApplication existingClient, AbpApplicationDescriptor application) |
||||
|
{ |
||||
|
return existingClient.Permissions == JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString().TrimEnd('/'))); |
||||
|
} |
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
using System.Runtime.CompilerServices; |
||||
|
[assembly:InternalsVisibleToAttribute("WinIn.FasterZ.AuthSiteCenter.Domain.Tests")] |
||||
|
[assembly:InternalsVisibleToAttribute("WinIn.FasterZ.AuthSiteCenter.TestBase")] |
@ -0,0 +1,12 @@ |
|||||
|
using Volo.Abp.Settings; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Settings; |
||||
|
|
||||
|
public class AuthSiteCenterSettingDefinitionProvider : SettingDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
//Define your own settings here. Example:
|
||||
|
//context.Add(new SettingDefinition(AuthSiteCenterSettings.MySetting1));
|
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Settings; |
||||
|
|
||||
|
public static class AuthSiteCenterSettings |
||||
|
{ |
||||
|
private const string Prefix = "AuthSiteCenter"; |
||||
|
|
||||
|
//Add your own setting names here. Example:
|
||||
|
//public const string MySetting1 = Prefix + ".MySetting1";
|
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace>WinIn.FasterZ.AuthSiteCenter</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Domain.Shared\WinIn.FasterZ.AuthSiteCenter.Domain.Shared.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Emailing" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.Identity.Domain" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.OpenIddict.Domain" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.OpenIddict" Version="7.3.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,86 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.AuditLogging.EntityFrameworkCore; |
||||
|
using Volo.Abp.BackgroundJobs.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Identity.EntityFrameworkCore; |
||||
|
using Volo.Abp.OpenIddict.EntityFrameworkCore; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
using Volo.Abp.TenantManagement.EntityFrameworkCore; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore; |
||||
|
|
||||
|
[ReplaceDbContext(typeof(IIdentityDbContext))] |
||||
|
[ReplaceDbContext(typeof(ITenantManagementDbContext))] |
||||
|
[ConnectionStringName("Default")] |
||||
|
public class AuthSiteCenterDbContext : |
||||
|
AbpDbContext<AuthSiteCenterDbContext>, |
||||
|
IIdentityDbContext, |
||||
|
ITenantManagementDbContext |
||||
|
{ |
||||
|
/* Add DbSet properties for your Aggregate Roots / Entities here. */ |
||||
|
|
||||
|
#region Entities from the modules
|
||||
|
|
||||
|
/* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext |
||||
|
* and replaced them for this DbContext. This allows you to perform JOIN |
||||
|
* queries for the entities of these modules over the repositories easily. You |
||||
|
* typically don't need that for other modules. But, if you need, you can |
||||
|
* implement the DbContext interface of the needed module and use ReplaceDbContext |
||||
|
* attribute just like IIdentityDbContext and ITenantManagementDbContext. |
||||
|
* |
||||
|
* More info: Replacing a DbContext of a module ensures that the related module |
||||
|
* uses this DbContext on runtime. Otherwise, it will use its own DbContext class. |
||||
|
*/ |
||||
|
|
||||
|
//Identity
|
||||
|
public DbSet<IdentityUser> Users { get; set; } |
||||
|
public DbSet<IdentityRole> Roles { get; set; } |
||||
|
public DbSet<IdentityClaimType> ClaimTypes { get; set; } |
||||
|
public DbSet<OrganizationUnit> OrganizationUnits { get; set; } |
||||
|
public DbSet<IdentitySecurityLog> SecurityLogs { get; set; } |
||||
|
public DbSet<IdentityLinkUser> LinkUsers { get; set; } |
||||
|
public DbSet<IdentityUserDelegation> UserDelegations { get; set; } |
||||
|
|
||||
|
// Tenant Management
|
||||
|
public DbSet<Tenant> Tenants { get; set; } |
||||
|
public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; } |
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
public AuthSiteCenterDbContext(DbContextOptions<AuthSiteCenterDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder builder) |
||||
|
{ |
||||
|
base.OnModelCreating(builder); |
||||
|
|
||||
|
/* Include modules to your migration db context */ |
||||
|
|
||||
|
builder.ConfigurePermissionManagement(); |
||||
|
builder.ConfigureSettingManagement(); |
||||
|
builder.ConfigureBackgroundJobs(); |
||||
|
builder.ConfigureAuditLogging(); |
||||
|
builder.ConfigureIdentity(); |
||||
|
builder.ConfigureOpenIddict(); |
||||
|
builder.ConfigureFeatureManagement(); |
||||
|
builder.ConfigureTenantManagement(); |
||||
|
|
||||
|
/* Configure your own tables/entities inside here */ |
||||
|
|
||||
|
//builder.Entity<YourEntity>(b =>
|
||||
|
//{
|
||||
|
// b.ToTable(AuthSiteCenterConsts.DbTablePrefix + "YourEntities", AuthSiteCenterConsts.DbSchema);
|
||||
|
// b.ConfigureByConvention(); //auto configure for the base class props
|
||||
|
// //...
|
||||
|
//});
|
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
using System.IO; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore; |
||||
|
|
||||
|
/* This class is needed for EF Core console commands |
||||
|
* (like Add-Migration and Update-Database commands) */ |
||||
|
public class AuthSiteCenterDbContextFactory : IDesignTimeDbContextFactory<AuthSiteCenterDbContext> |
||||
|
{ |
||||
|
public AuthSiteCenterDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
AuthSiteCenterEfCoreEntityExtensionMappings.Configure(); |
||||
|
|
||||
|
var configuration = BuildConfiguration(); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<AuthSiteCenterDbContext>() |
||||
|
.UseSqlServer(configuration.GetConnectionString("Default")); |
||||
|
|
||||
|
return new AuthSiteCenterDbContext(builder.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../WinIn.FasterZ.AuthSiteCenter.DbMigrator/")) |
||||
|
.AddJsonFile("appsettings.json", optional: false); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.ObjectExtending; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore; |
||||
|
|
||||
|
public static class AuthSiteCenterEfCoreEntityExtensionMappings |
||||
|
{ |
||||
|
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
||||
|
|
||||
|
public static void Configure() |
||||
|
{ |
||||
|
AuthSiteCenterGlobalFeatureConfigurator.Configure(); |
||||
|
AuthSiteCenterModuleExtensionConfigurator.Configure(); |
||||
|
|
||||
|
OneTimeRunner.Run(() => |
||||
|
{ |
||||
|
/* You can configure extra properties for the |
||||
|
* entities defined in the modules used by your application. |
||||
|
* |
||||
|
* This class can be used to map these extra properties to table fields in the database. |
||||
|
* |
||||
|
* USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING. |
||||
|
* USE AuthSiteCenterModuleExtensionConfigurator CLASS (in the Domain.Shared project) |
||||
|
* FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES |
||||
|
* |
||||
|
* Example: Map a property to a table field: |
||||
|
|
||||
|
ObjectExtensionManager.Instance |
||||
|
.MapEfCoreProperty<IdentityUser, string>( |
||||
|
"MyProperty", |
||||
|
(entityBuilder, propertyBuilder) => |
||||
|
{ |
||||
|
propertyBuilder.HasMaxLength(128); |
||||
|
} |
||||
|
); |
||||
|
|
||||
|
* See the documentation for more: |
||||
|
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
|
||||
|
*/ |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
using System; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Volo.Abp.AuditLogging.EntityFrameworkCore; |
||||
|
using Volo.Abp.BackgroundJobs.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore.SqlServer; |
||||
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Identity.EntityFrameworkCore; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.OpenIddict.EntityFrameworkCore; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.TenantManagement.EntityFrameworkCore; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AuthSiteCenterDomainModule), |
||||
|
typeof(AbpIdentityEntityFrameworkCoreModule), |
||||
|
typeof(AbpOpenIddictEntityFrameworkCoreModule), |
||||
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpEntityFrameworkCoreSqlServerModule), |
||||
|
typeof(AbpBackgroundJobsEntityFrameworkCoreModule), |
||||
|
typeof(AbpAuditLoggingEntityFrameworkCoreModule), |
||||
|
typeof(AbpTenantManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterEntityFrameworkCoreModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
AuthSiteCenterEfCoreEntityExtensionMappings.Configure(); |
||||
|
} |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddAbpDbContext<AuthSiteCenterDbContext>(options => |
||||
|
{ |
||||
|
/* Remove "includeAllEntities: true" to create |
||||
|
* default repositories only for aggregate roots */ |
||||
|
options.AddDefaultRepositories(includeAllEntities: true); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
/* The main point to change your DBMS. |
||||
|
* See also AuthSiteCenterMigrationsDbContextFactory for EF Core tooling. */ |
||||
|
options.UseSqlServer(); |
||||
|
}); |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore; |
||||
|
|
||||
|
public class EntityFrameworkCoreAuthSiteCenterDbSchemaMigrator |
||||
|
: IAuthSiteCenterDbSchemaMigrator, ITransientDependency |
||||
|
{ |
||||
|
private readonly IServiceProvider _serviceProvider; |
||||
|
|
||||
|
public EntityFrameworkCoreAuthSiteCenterDbSchemaMigrator( |
||||
|
IServiceProvider serviceProvider) |
||||
|
{ |
||||
|
_serviceProvider = serviceProvider; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
/* We intentionally resolving the AuthSiteCenterDbContext |
||||
|
* from IServiceProvider (instead of directly injecting it) |
||||
|
* to properly get the connection string of the current tenant in the |
||||
|
* current scope. |
||||
|
*/ |
||||
|
|
||||
|
await _serviceProvider |
||||
|
.GetRequiredService<AuthSiteCenterDbContext>() |
||||
|
.Database |
||||
|
.MigrateAsync(); |
||||
|
} |
||||
|
} |
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,2 @@ |
|||||
|
using System.Runtime.CompilerServices; |
||||
|
[assembly:InternalsVisibleToAttribute("WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore.Tests")] |
@ -0,0 +1,31 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace>WinIn.FasterZ.AuthSiteCenter</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Domain\WinIn.FasterZ.AuthSiteCenter.Domain.csproj" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.BackgroundJobs.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="7.3.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.1"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,38 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Account; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AuthSiteCenterApplicationContractsModule), |
||||
|
typeof(AbpAccountHttpApiClientModule), |
||||
|
typeof(AbpIdentityHttpApiClientModule), |
||||
|
typeof(AbpPermissionManagementHttpApiClientModule), |
||||
|
typeof(AbpTenantManagementHttpApiClientModule), |
||||
|
typeof(AbpFeatureManagementHttpApiClientModule), |
||||
|
typeof(AbpSettingManagementHttpApiClientModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterHttpApiClientModule : AbpModule |
||||
|
{ |
||||
|
public const string RemoteServiceName = "Default"; |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddHttpClientProxies( |
||||
|
typeof(AuthSiteCenterApplicationContractsModule).Assembly, |
||||
|
RemoteServiceName |
||||
|
); |
||||
|
|
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AuthSiteCenterHttpApiClientModule>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace>WinIn.FasterZ.AuthSiteCenter</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Application.Contracts\WinIn.FasterZ.AuthSiteCenter.Application.Contracts.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Account.HttpApi.Client" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi.Client" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi.Client" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi.Client" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.HttpApi.Client" Version="7.3.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<EmbeddedResource Include="**\*generate-proxy.json" /> |
||||
|
<Content Remove="**\*generate-proxy.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,41 @@ |
|||||
|
using Localization.Resources.AbpUi; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using Volo.Abp.Account; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.HttpApi; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AuthSiteCenterApplicationContractsModule), |
||||
|
typeof(AbpAccountHttpApiModule), |
||||
|
typeof(AbpIdentityHttpApiModule), |
||||
|
typeof(AbpPermissionManagementHttpApiModule), |
||||
|
typeof(AbpTenantManagementHttpApiModule), |
||||
|
typeof(AbpFeatureManagementHttpApiModule), |
||||
|
typeof(AbpSettingManagementHttpApiModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterHttpApiModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
ConfigureLocalization(); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureLocalization() |
||||
|
{ |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Get<AuthSiteCenterResource>() |
||||
|
.AddBaseTypes( |
||||
|
typeof(AbpUiResource) |
||||
|
); |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Controllers; |
||||
|
|
||||
|
/* Inherit your controllers from this class. |
||||
|
*/ |
||||
|
public abstract class AuthSiteCenterController : AbpControllerBase |
||||
|
{ |
||||
|
protected AuthSiteCenterController() |
||||
|
{ |
||||
|
LocalizationResource = typeof(AuthSiteCenterResource); |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Models.Test; |
||||
|
|
||||
|
public class TestModel |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public DateTime BirthDate { get; set; } |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace>WinIn.FasterZ.AuthSiteCenter</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WinIn.FasterZ.AuthSiteCenter.Application.Contracts\WinIn.FasterZ.AuthSiteCenter.Application.Contracts.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Account.HttpApi" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.Identity.HttpApi" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" Version="7.3.2" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.HttpApi" Version="7.3.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,17 @@ |
|||||
|
using AutoMapper; |
||||
|
using Volo.Abp.Identity; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Web.Controllers; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web; |
||||
|
|
||||
|
public class AuthSiteCenterAutoMapperProfile : Profile |
||||
|
{ |
||||
|
public AuthSiteCenterAutoMapperProfile() |
||||
|
{ |
||||
|
/* You can configure your AutoMapper mapping configuration here. |
||||
|
* Alternatively, you can split your mapping configurations |
||||
|
* into multiple profile classes for a better organization. */ |
||||
|
|
||||
|
CreateMap<IdentityUser, LoginOutput>(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
using Volo.Abp.Ui.Branding; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web; |
||||
|
|
||||
|
[Dependency(ReplaceServices = true)] |
||||
|
public class AuthSiteCenterBrandingProvider : DefaultBrandingProvider |
||||
|
{ |
||||
|
public override string AppName => "AuthSiteCenter"; |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
using AutoMapper; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web; |
||||
|
|
||||
|
public class AuthSiteCenterWebAutoMapperProfile : Profile |
||||
|
{ |
||||
|
public AuthSiteCenterWebAutoMapperProfile() |
||||
|
{ |
||||
|
//Define your AutoMapper configuration here for the Web project.
|
||||
|
} |
||||
|
} |
@ -0,0 +1,343 @@ |
|||||
|
using System.IO; |
||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.AspNetCore.Extensions.DependencyInjection; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.EntityFrameworkCore; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.MultiTenancy; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Web.Menus; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using OpenIddict.Validation.AspNetCore; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Account.Web; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.Localization; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; |
||||
|
using Volo.Abp.AspNetCore.Serilog; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Volo.Abp.Caching.StackExchangeRedis; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity.Web; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.Web; |
||||
|
using Volo.Abp.SettingManagement.Web; |
||||
|
using Volo.Abp.Swashbuckle; |
||||
|
using Volo.Abp.TenantManagement.Web; |
||||
|
using Volo.Abp.UI.Navigation.Urls; |
||||
|
using Volo.Abp.UI; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
//using WinIn.FasterZ.Store;
|
||||
|
using Microsoft.AspNetCore.DataProtection; |
||||
|
using StackExchange.Redis; |
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using Volo.Abp.BackgroundJobs; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Medallion.Threading; |
||||
|
using Medallion.Threading.Redis; |
||||
|
using Microsoft.AspNetCore.Cors; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect; |
||||
|
using Microsoft.AspNetCore.Http.Features; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Permissions; |
||||
|
using WinIn.FasterZ.InterfaceDash; |
||||
|
//using WinIn.FasterZ.Job;
|
||||
|
using Volo.Abp.AspNetCore.Mvc.AntiForgery; |
||||
|
using Autofac.Core; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AuthSiteCenterHttpApiModule), |
||||
|
typeof(AuthSiteCenterApplicationModule), |
||||
|
typeof(AuthSiteCenterEntityFrameworkCoreModule), |
||||
|
typeof(AbpAutofacModule), |
||||
|
typeof(AbpCachingStackExchangeRedisModule), |
||||
|
typeof(AbpIdentityWebModule), |
||||
|
typeof(AbpSettingManagementWebModule), |
||||
|
typeof(AbpAccountWebOpenIddictModule), |
||||
|
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule), |
||||
|
typeof(AbpTenantManagementWebModule), |
||||
|
typeof(AbpAspNetCoreSerilogModule), |
||||
|
|
||||
|
//----------权限添加
|
||||
|
//typeof(StoreApplicationContractsModule),
|
||||
|
//typeof(JobApplicationContractsModule),
|
||||
|
//typeof(InterfaceDashApplicationContractsModule)
|
||||
|
|
||||
|
typeof(AbpSwashbuckleModule) |
||||
|
)] |
||||
|
public class AuthSiteCenterWebModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.AddAssemblyResource( |
||||
|
typeof(AuthSiteCenterResource), |
||||
|
typeof(AuthSiteCenterDomainModule).Assembly, |
||||
|
typeof(AuthSiteCenterDomainSharedModule).Assembly, |
||||
|
typeof(AuthSiteCenterApplicationModule).Assembly, |
||||
|
typeof(AuthSiteCenterApplicationContractsModule).Assembly, |
||||
|
typeof(AuthSiteCenterWebModule).Assembly |
||||
|
); |
||||
|
}); |
||||
|
|
||||
|
PreConfigure<OpenIddictBuilder>(builder => |
||||
|
{ |
||||
|
builder.AddValidation(options => |
||||
|
{ |
||||
|
options.AddAudiences("AuthSiteCenter Z Store Job"); |
||||
|
options.UseLocalServer(); |
||||
|
options.UseAspNetCore(); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpAntiForgeryOptions>(options => |
||||
|
{ |
||||
|
options.AutoValidate = false; |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpAutoMapperOptions>(options => |
||||
|
{ |
||||
|
options.AddMaps<AuthSiteCenterAutoMapperProfile>(); |
||||
|
}); |
||||
|
|
||||
|
RemoveOnlyHttps(context); |
||||
|
} |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
||||
|
var configuration = context.Services.GetConfiguration(); |
||||
|
|
||||
|
ConfigureAuthentication(context, configuration); |
||||
|
ConfigureUrls(configuration); |
||||
|
ConfigureBundles(); |
||||
|
ConfigureAutoMapper(); |
||||
|
ConfigureVirtualFileSystem(hostingEnvironment); |
||||
|
ConfigureNavigationServices(); |
||||
|
ConfigureAutoApiControllers(); |
||||
|
ConfigureSwaggerServices(context.Services); |
||||
|
|
||||
|
Configure<AbpBackgroundJobOptions>(options => |
||||
|
{ |
||||
|
options.IsJobExecutionEnabled = false; |
||||
|
}); |
||||
|
|
||||
|
Configure<FormOptions>(options => |
||||
|
{ |
||||
|
options.ValueCountLimit = 5000; // 5000 items max
|
||||
|
options.ValueLengthLimit = 1024 * 1024 * 100; // 100MB max len form data
|
||||
|
}); |
||||
|
|
||||
|
Configure<AbpDistributedCacheOptions>(options => |
||||
|
{ |
||||
|
options.KeyPrefix = "AuthSiteCenter:"; |
||||
|
}); |
||||
|
|
||||
|
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("AuthSiteCenter"); |
||||
|
if (!hostingEnvironment.IsDevelopment()) |
||||
|
{ |
||||
|
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
|
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "AuthSiteCenter-Protection-Keys"); |
||||
|
} |
||||
|
|
||||
|
context.Services.AddSingleton<IDistributedLockProvider>(sp => |
||||
|
{ |
||||
|
var connection = ConnectionMultiplexer |
||||
|
.Connect(configuration["Redis:Configuration"]); |
||||
|
return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); |
||||
|
}); |
||||
|
|
||||
|
context.Services.AddCors(options => |
||||
|
{ |
||||
|
options.AddDefaultPolicy(builder => |
||||
|
{ |
||||
|
builder |
||||
|
.WithOrigins( |
||||
|
configuration["App:CorsOrigins"]? |
||||
|
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
||||
|
.Select(o => o.RemovePostFix("/")) |
||||
|
.ToArray() ?? Array.Empty<string>() |
||||
|
) |
||||
|
.WithAbpExposedHeaders() |
||||
|
.SetIsOriginAllowedToAllowWildcardSubdomains() |
||||
|
.AllowAnyHeader() |
||||
|
.AllowAnyMethod() |
||||
|
.AllowCredentials(); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) |
||||
|
{ |
||||
|
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); |
||||
|
|
||||
|
//自定义权限检查器
|
||||
|
Configure<AbpPermissionOptions>(options => |
||||
|
{ |
||||
|
options.ValueProviders.Clear(); |
||||
|
options.ValueProviders.Add<UserPermissionValueProvider>(); |
||||
|
options.ValueProviders.Add<ZRolePermissionValueProvider>(); |
||||
|
options.ValueProviders.Add<ClientPermissionValueProvider>(); |
||||
|
}); |
||||
|
|
||||
|
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
|
.AddJwtBearer(options => |
||||
|
{ |
||||
|
options.Authority = configuration["AuthServer:Authority"]; |
||||
|
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); |
||||
|
options.Audience = "AuthSiteCenter"; |
||||
|
}) |
||||
|
.AddCookie("Cookies"); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureUrls(IConfiguration configuration) |
||||
|
{ |
||||
|
Configure<AppUrlOptions>(options => |
||||
|
{ |
||||
|
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; |
||||
|
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? Array.Empty<string>()); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureBundles() |
||||
|
{ |
||||
|
Configure<AbpBundlingOptions>(options => |
||||
|
{ |
||||
|
options.StyleBundles.Configure( |
||||
|
LeptonXLiteThemeBundles.Styles.Global, |
||||
|
bundle => |
||||
|
{ |
||||
|
bundle.AddFiles("/global-styles.css"); |
||||
|
} |
||||
|
); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAutoMapper() |
||||
|
{ |
||||
|
Configure<AbpAutoMapperOptions>(options => |
||||
|
{ |
||||
|
options.AddMaps<AuthSiteCenterWebModule>(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) |
||||
|
{ |
||||
|
if (hostingEnvironment.IsDevelopment()) |
||||
|
{ |
||||
|
Configure<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.ReplaceEmbeddedByPhysical<AuthSiteCenterDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}WinIn.FasterZ.AuthSiteCenter.Domain.Shared")); |
||||
|
options.FileSets.ReplaceEmbeddedByPhysical<AuthSiteCenterDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}WinIn.FasterZ.AuthSiteCenter.Domain")); |
||||
|
options.FileSets.ReplaceEmbeddedByPhysical<AuthSiteCenterApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}WinIn.FasterZ.AuthSiteCenter.Application.Contracts")); |
||||
|
options.FileSets.ReplaceEmbeddedByPhysical<AuthSiteCenterApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}WinIn.FasterZ.AuthSiteCenter.Application")); |
||||
|
options.FileSets.ReplaceEmbeddedByPhysical<AuthSiteCenterWebModule>(hostingEnvironment.ContentRootPath); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ConfigureNavigationServices() |
||||
|
{ |
||||
|
Configure<AbpNavigationOptions>(options => |
||||
|
{ |
||||
|
options.MenuContributors.Add(new AuthSiteCenterMenuContributor()); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureAutoApiControllers() |
||||
|
{ |
||||
|
Configure<AbpAspNetCoreMvcOptions>(options => |
||||
|
{ |
||||
|
options.ConventionalControllers.Create(typeof(AuthSiteCenterApplicationModule).Assembly); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfigureSwaggerServices(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "AuthSiteCenter API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
options.CustomSchemaIds(type => type.FullName); |
||||
|
} |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
var app = context.GetApplicationBuilder(); |
||||
|
var env = context.GetEnvironment(); |
||||
|
|
||||
|
if (env.IsDevelopment()) |
||||
|
{ |
||||
|
app.UseDeveloperExceptionPage(); |
||||
|
} |
||||
|
|
||||
|
app.UseAbpRequestLocalization(); |
||||
|
|
||||
|
if (!env.IsDevelopment()) |
||||
|
{ |
||||
|
app.UseErrorPage(); |
||||
|
} |
||||
|
|
||||
|
app.UseCorrelationId(); |
||||
|
app.UseStaticFiles(); |
||||
|
app.UseRouting(); |
||||
|
app.UseAuthenticationZ(); |
||||
|
app.UseAbpOpenIddictValidation(); |
||||
|
|
||||
|
if (MultiTenancyConsts.IsEnabled) |
||||
|
{ |
||||
|
app.UseMultiTenancy(); |
||||
|
} |
||||
|
|
||||
|
app.UseUnitOfWork(); |
||||
|
app.UseAuthorization(); |
||||
|
|
||||
|
app.UseCors(); |
||||
|
|
||||
|
app.UseSwagger(); |
||||
|
app.UseAbpSwaggerUI(options => |
||||
|
{ |
||||
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "AuthSiteCenter API"); |
||||
|
}); |
||||
|
app.UseAuditing(); |
||||
|
app.UseAbpSerilogEnrichers(); |
||||
|
app.UseConfiguredEndpoints(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 去掉只允许https的限制
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
/// <returns></returns>
|
||||
|
private OpenIddictBuilder RemoveOnlyHttps(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
return context.Services.AddOpenIddict() |
||||
|
.AddServer(option => |
||||
|
{ |
||||
|
option.SetAccessTokenLifetime(TimeSpan.FromSeconds(7200)); |
||||
|
option.AllowPasswordFlow(); |
||||
|
option.AllowRefreshTokenFlow(); |
||||
|
option.UseAspNetCore() |
||||
|
.DisableTransportSecurityRequirement(); |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -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 |
@ -0,0 +1,151 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Linq; |
||||
|
using System.Net.Http; |
||||
|
using System.Net.Http.Headers; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Newtonsoft.Json; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web.Controllers; |
||||
|
|
||||
|
[ApiController] |
||||
|
[Route("CustAccount")] |
||||
|
public class CustAccountController : AbpController |
||||
|
{ |
||||
|
private readonly IdentityUserManager _userManager; |
||||
|
private readonly IHttpClientFactory _httpClientFactory; |
||||
|
private IConfiguration _configuration; |
||||
|
|
||||
|
public CustAccountController(IdentityUserManager userManager, IHttpClientFactory httpClientFactory, IConfiguration configuration) |
||||
|
{ |
||||
|
_userManager = userManager; |
||||
|
_httpClientFactory = httpClientFactory; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
[HttpPost("login")] |
||||
|
public async Task<LoginOutput> LoginAsync([FromBody]LoginInput input) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var client = _httpClientFactory.CreateClient("login"); |
||||
|
client.BaseAddress = new Uri(_configuration["AuthServer:Authority"]); |
||||
|
var dic = new Dictionary<string, object> |
||||
|
{ |
||||
|
{"client_id","AuthSiteCenter_App"}, |
||||
|
{"scope","offline_access AuthSiteCenter Z Job Store profile"}, |
||||
|
//{"scope","AuthSiteCenter Z Job Store"},
|
||||
|
//{"scope","AuthSiteCenter"},
|
||||
|
{"grant_type","password"}, |
||||
|
{"username",input.Name}, |
||||
|
{"password",input.Password}, |
||||
|
}; |
||||
|
var dicStr = dic.Select(m => m.Key + "=" + m.Value).DefaultIfEmpty().Aggregate((m, n) => m + "&" + n); |
||||
|
HttpContent httpContent = new StringContent(dicStr); |
||||
|
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); |
||||
|
var oauthRep = await client.PostAsync("connect/token", httpContent); |
||||
|
var oauthStr = await oauthRep.Content.ReadAsStringAsync(); |
||||
|
var oauthResult = default(Id4TokenOutput); |
||||
|
if (oauthRep.IsSuccessStatusCode) |
||||
|
{ |
||||
|
if (!string.IsNullOrEmpty(oauthStr)) |
||||
|
oauthResult = JsonConvert.DeserializeObject<Id4TokenOutput>(oauthStr); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (string.IsNullOrEmpty(oauthStr)) |
||||
|
throw new BusinessException(oauthRep.ReasonPhrase); |
||||
|
} |
||||
|
var user = await _userManager.FindByNameAsync(input.Name); |
||||
|
if (user == null) |
||||
|
{ |
||||
|
throw new UserFriendlyException("用户名或密码错误"); |
||||
|
} |
||||
|
|
||||
|
if (!user.IsActive) |
||||
|
{ |
||||
|
throw new UserFriendlyException("用户已锁定"); |
||||
|
} |
||||
|
return await BuildResult(user, oauthResult?.access_token); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Console.WriteLine(e); |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#region 私有方法
|
||||
|
private async Task<LoginOutput> BuildResult(IdentityUser user, string token) |
||||
|
{ |
||||
|
var roles = await _userManager.GetRolesAsync(user); |
||||
|
if (roles == null || roles.Count == 0) |
||||
|
{ |
||||
|
throw new UserFriendlyException("当前用户未分配角色"); |
||||
|
} |
||||
|
|
||||
|
var loginOutput = ObjectMapper.Map<IdentityUser, LoginOutput>(user); |
||||
|
loginOutput.token = token; |
||||
|
loginOutput.roles = roles.ToList(); |
||||
|
return loginOutput; |
||||
|
} |
||||
|
#endregion
|
||||
|
} |
||||
|
|
||||
|
public class LoginInput : IValidatableObject |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 用户名或者邮箱
|
||||
|
/// </summary>
|
||||
|
public string? Name { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 密码
|
||||
|
/// </summary>
|
||||
|
public string? Password { get; set; } |
||||
|
|
||||
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) |
||||
|
{ |
||||
|
if (Name.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
yield return new ValidationResult("Name can not be null", new[] { "Name" }); |
||||
|
} |
||||
|
|
||||
|
if (Password.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
yield return new ValidationResult("Password can not be null", new[] { "Password" }); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class LoginOutput |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 用户名或者邮箱
|
||||
|
/// </summary>
|
||||
|
public string token { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 密码
|
||||
|
/// </summary>
|
||||
|
public List<string> roles { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class Id4TokenOutput |
||||
|
{ |
||||
|
public string access_token { get; set; } |
||||
|
|
||||
|
public int expires_in { get; set; } |
||||
|
|
||||
|
public string token_type { get; set; } |
||||
|
|
||||
|
public string refresh_token { get; set; } |
||||
|
|
||||
|
public string scope { get; set; } |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using WinIn.FasterZ.AuthSiteCenter.MultiTenancy; |
||||
|
using Volo.Abp.Identity.Web.Navigation; |
||||
|
using Volo.Abp.SettingManagement.Web.Navigation; |
||||
|
using Volo.Abp.TenantManagement.Web.Navigation; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web.Menus; |
||||
|
|
||||
|
public class AuthSiteCenterMenuContributor : IMenuContributor |
||||
|
{ |
||||
|
public async Task ConfigureMenuAsync(MenuConfigurationContext context) |
||||
|
{ |
||||
|
if (context.Menu.Name == StandardMenus.Main) |
||||
|
{ |
||||
|
await ConfigureMainMenuAsync(context); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private Task ConfigureMainMenuAsync(MenuConfigurationContext context) |
||||
|
{ |
||||
|
var administration = context.Menu.GetAdministration(); |
||||
|
var l = context.GetLocalizer<AuthSiteCenterResource>(); |
||||
|
|
||||
|
context.Menu.Items.Insert( |
||||
|
0, |
||||
|
new ApplicationMenuItem( |
||||
|
AuthSiteCenterMenus.Home, |
||||
|
l["Menu:Home"], |
||||
|
"~/", |
||||
|
icon: "fas fa-home", |
||||
|
order: 0 |
||||
|
) |
||||
|
); |
||||
|
|
||||
|
if (MultiTenancyConsts.IsEnabled) |
||||
|
{ |
||||
|
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); |
||||
|
} |
||||
|
|
||||
|
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); |
||||
|
administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3); |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web.Menus; |
||||
|
|
||||
|
public class AuthSiteCenterMenus |
||||
|
{ |
||||
|
private const string Prefix = "AuthSiteCenter"; |
||||
|
public const string Home = Prefix + ".Home"; |
||||
|
|
||||
|
//Add your menu items here...
|
||||
|
|
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
using WinIn.FasterZ.AuthSiteCenter.Localization; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
||||
|
|
||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web.Pages; |
||||
|
|
||||
|
/* Inherit your PageModel classes from this class. |
||||
|
*/ |
||||
|
public abstract class AuthSiteCenterPageModel : AbpPageModel |
||||
|
{ |
||||
|
protected AuthSiteCenterPageModel() |
||||
|
{ |
||||
|
LocalizationResourceType = typeof(AuthSiteCenterResource); |
||||
|
} |
||||
|
} |
@ -0,0 +1,187 @@ |
|||||
|
@page |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using WinIn.FasterZ.AuthSiteCenter.Localization |
||||
|
@using Volo.Abp.Users |
||||
|
@model WinIn.FasterZ.AuthSiteCenter.Web.Pages.IndexModel |
||||
|
@inject IHtmlLocalizer<AuthSiteCenterResource> L |
||||
|
@inject ICurrentUser CurrentUser |
||||
|
@section styles { |
||||
|
<abp-style src="/Pages/Index.css" /> |
||||
|
} |
||||
|
@section scripts { |
||||
|
<abp-script src="/Pages/Index.js" /> |
||||
|
} |
||||
|
<div class="container"> |
||||
|
<div class="p-5 text-center"> |
||||
|
<div class="d-inline-block bg-success text-white p-1 h5 rounded mb-4 " role="alert"> |
||||
|
<h5 class="m-1"> <i class="fas fa-rocket"></i> Congratulations, <strong>AuthSiteCenter</strong> is successfully running!</h5> |
||||
|
</div> |
||||
|
<h1>Welcome to the Application</h1> |
||||
|
|
||||
|
<p class="lead px-lg-5 mx-lg-5">@L["LongWelcomeMessage"]</p> |
||||
|
|
||||
|
@if (!CurrentUser.IsAuthenticated) |
||||
|
{ |
||||
|
<a abp-button="Primary" href="~/Account/Login"><i class="fa fa-sign-in"></i> @L["Login"]</a> |
||||
|
} |
||||
|
|
||||
|
</div> |
||||
|
<div class="card"> |
||||
|
<div class="card-body"> |
||||
|
<div class="row"> |
||||
|
<div class="col-md-auto text-center"> |
||||
|
<img src="https://abp.io/assets/png/mastering-abp-framework.webp" style="max-width: 400px;" class="w-100 mb-5 my-md-3"> |
||||
|
</div> |
||||
|
<div class="col-md d-flex align-items-center"> |
||||
|
<div class="pe-0 pe-md-4"> |
||||
|
<small class="text-uppercase text-muted">THE OFFICIAL GUIDE</small> |
||||
|
<h2 class="mb-4">Mastering ABP Framework</h2> |
||||
|
<p class="mb-4">Written by the creator of the ABP Framework, this book will help you gain a complete understanding of the framework and modern web application development techniques.</p> |
||||
|
<div class="mb-4"> |
||||
|
<a href="https://www.amazon.com/gp/product/B097Z2DM8Q/ref=dbs_a_def_rwt_hsch_vapi_tkin_p1_i0" class="btn btn-success mb-1"> |
||||
|
Buy on Amazon US |
||||
|
</a> |
||||
|
<a href="https://www.packtpub.com/product/mastering-abp-framework/9781801079242" class="btn btn-primary mb-1"> |
||||
|
Buy on PACKT |
||||
|
</a> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="my-3 text-center"> |
||||
|
<h3>Let's improve your application!</h3> |
||||
|
<p>Here are some links to help you get started:</p> |
||||
|
</div> |
||||
|
<div class="card mt-4 mb-5"> |
||||
|
<div class="card-body"> |
||||
|
<div class="row text-center justify-content-md-center"> |
||||
|
<div class="col-lg-4"> |
||||
|
<div class="p-4"> |
||||
|
<h5 class="mb-3"><i class="fas fa-book text-secondary d-block my-3 fa-2x"></i> Learn the ABP Framework</h5> |
||||
|
<p>Explore the compherensive documentation to learn how to build a modern web application.</p> |
||||
|
<a href="https://docs.abp.io/en/abp/latest?ref=tmpl" target="_blank" class="btn btn-link px-1">See Documents <i class="fas fa-chevron-right"></i></a> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-4 border-start"> |
||||
|
<div class="p-4"> |
||||
|
<h5 class="mb-3"><i class="fas fa-cubes text-secondary d-block my-3 fa-2x"></i> Samples</h5> |
||||
|
<p>See the example projects built with the ABP Framework.</p> |
||||
|
<a href="https://docs.abp.io/en/abp/latest/Samples/Index?ref=tmpl" target="_blank" class="btn btn-link px-1">All samples <i class="fas fa-chevron-right"></i></a> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-4 border-start"> |
||||
|
<div class="p-4"> |
||||
|
<h5 class="mb-3"><i class="fas fa-users text-secondary d-block my-3 fa-2x"></i> ABP Community</h5> |
||||
|
<p>Get involved with a vibrant community and become a contributor.</p> |
||||
|
<a href="https://community.abp.io/" target="_blank" class="btn btn-link px-1">Community <i class="fas fa-chevron-right"></i></a> |
||||
|
<a href="https://docs.abp.io/en/abp/latest/Contribution/Index?ref=tmpl" target="_blank" class="btn btn-link px-1">Contribute <i class="fas fa-chevron-right"></i></a> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="row text-center mt-lg-3 justify-content-md-center"> |
||||
|
<div class="col-lg-4"> |
||||
|
<div class="p-4"> |
||||
|
<h5 class="mb-3"><i class="fas fa-pen-nib text-secondary d-block my-3 fa-2x"></i> ABP Blog</h5> |
||||
|
<p>Take a look at our recently published articles.</p> |
||||
|
<a href="https://blog.abp.io/abp?ref=tmpl" target="_blank" class="btn btn-link px-1">See Blog <i class="fas fa-chevron-right"></i></a> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-4 border-start"> |
||||
|
<div class="p-4"> |
||||
|
<h5 class="mb-3"><i class="fab fa-github text-secondary d-block my-3 fa-2x"></i> Github</h5> |
||||
|
<p>Do you love the ABP Framework? Please <strong>give a star</strong> to support it!</p> |
||||
|
<p class="mb-1"> |
||||
|
<a class="github-button" href="https://github.com/abpframework/abp" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star abpframework/abp on GitHub">Star</a> |
||||
|
<a class="github-button" href="https://github.com/abpframework/abp/issues" data-icon="octicon-issue-opened" data-size="large" data-show-count="false" aria-label="Issue abpframework/abp on GitHub">Issue</a> |
||||
|
<a class="github-button" href="https://github.com/abpframework/abp/fork" data-icon="octicon-repo-forked" data-size="large" data-show-count="false" aria-label="Fork abpframework/abp on GitHub">Fork</a> |
||||
|
</p> |
||||
|
<a href="https://github.com/abpframework/abp/issues/new?template=feature.md" target="_blank" class="btn btn-link px-1">Request a feature <i class="fas fa-chevron-right"></i></a> |
||||
|
<script async defer src="https://buttons.github.io/buttons.js"></script> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-4 border-start"> |
||||
|
<div class="p-4"> |
||||
|
<h5 class="mb-3"><i class="fab fa-stack-overflow text-secondary d-block my-3 fa-2x"></i> Stackoverflow</h5> |
||||
|
<p>See answers to previously asked questions or ask a new one.</p> |
||||
|
<a href="https://stackoverflow.com/questions/tagged/abp" target="_blank" class="btn btn-link px-1">Questions <i class="fas fa-chevron-right"></i></a> |
||||
|
<a href="https://stackoverflow.com/questions/ask" target="_blank" class="btn btn-link px-1">Ask a Question <i class="fas fa-chevron-right"></i></a> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="mt-5 my-3 text-center"> |
||||
|
<h3>Meet the ABP Commercial</h3> |
||||
|
<p>A Complete Web Application Platform Built on the ABP Framework</p> |
||||
|
</div> |
||||
|
|
||||
|
<div class="card mt-4 mb-5"> |
||||
|
<div class="card-body"> |
||||
|
<p class="px-lg-5 mx-lg-5 py-3 text-center"> |
||||
|
<a href="https://commercial.abp.io/" target="_blank">ABP Commercial</a> is a platform based on the open source ABP framework. It provides pre-built application modules, |
||||
|
rapid application development tooling, professional UI themes, premium support and more. |
||||
|
</p> |
||||
|
|
||||
|
<div class="row text-center justify-content-md-center"> |
||||
|
<div class="col-lg-2"> |
||||
|
<div class="p-3"> |
||||
|
<h6> |
||||
|
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Startup Templates |
||||
|
<a href="https://commercial.abp.io/startup-templates?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a> |
||||
|
</h6> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-2 border-start"> |
||||
|
<div class="p-3"> |
||||
|
<h6> |
||||
|
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Application Modules |
||||
|
<a href="https://commercial.abp.io/modules?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a> |
||||
|
</h6> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-2 border-start"> |
||||
|
<div class="p-3"> |
||||
|
<h6> |
||||
|
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Developer<br />Tools |
||||
|
<a href="https://commercial.abp.io/tools?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a> |
||||
|
</h6> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-2 border-start"> |
||||
|
<div class="p-3"> |
||||
|
<h6> |
||||
|
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> UI<br /> Themes |
||||
|
<a href="https://commercial.abp.io/themes?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a> |
||||
|
</h6> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-2 border-start"> |
||||
|
<div class="p-3"> |
||||
|
<h6> |
||||
|
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Premium Support |
||||
|
<a href="https://support.abp.io/QA/Questions?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a> |
||||
|
</h6> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-lg-2 border-start"> |
||||
|
<div class="p-3"> |
||||
|
<h6> |
||||
|
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Additional Services |
||||
|
<a href="https://commercial.abp.io/additional-services?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a> |
||||
|
</h6> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="mb-5 text-center"> |
||||
|
<p class="align-middle"> |
||||
|
<a href="https://twitter.com/abpframework" target="_blank" class="mx-2"><i class="fa fa-twitter"></i><span class="text-secondary"> Abp Framework</span></a> |
||||
|
<a href="https://twitter.com/abpcommercial" target="_blank" class="mx-2"><i class="fa fa-twitter"></i><span class="text-secondary"> Abp Commercial</span></a> |
||||
|
<a href="https://github.com/abpframework/abp" target="_blank" class="mx-2"><i class="fa fa-github"></i><span class="text-secondary"> abpframework</span></a> |
||||
|
</p> |
||||
|
</div> |
||||
|
</div> |
@ -0,0 +1,9 @@ |
|||||
|
namespace WinIn.FasterZ.AuthSiteCenter.Web.Pages; |
||||
|
|
||||
|
public class IndexModel : AuthSiteCenterPageModel |
||||
|
{ |
||||
|
public void OnGet() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue