Add project files.
This commit is contained in:
parent
ad652bc070
commit
7d760b589e
367
.gitignore
vendored
Normal file
367
.gitignore
vendored
Normal file
@ -0,0 +1,367 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Oo]ut/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
CerberosServiceSettings.development.json
|
||||||
|
/Core.Cerberos.Service.API/cerberosprivkey.pem
|
||||||
|
/Core.Cerberos.Service.API/cerberospubkey.pem
|
||||||
59
.pipelines/GitVersion.yml
Normal file
59
.pipelines/GitVersion.yml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
mode: mainline
|
||||||
|
assembly-versioning-scheme: MajorMinorPatch
|
||||||
|
tag-prefix: '[vV]'
|
||||||
|
major-version-bump-message: '\+semver:\s?(breaking|major)'
|
||||||
|
minor-version-bump-message: '\+semver:\s?(feature|minor)'
|
||||||
|
patch-version-bump-message: '\+semver:\s?(fix|patch)'
|
||||||
|
no-bump-message: '\+semver:\s?(none|skip)'
|
||||||
|
legacy-semver-padding: 4
|
||||||
|
build-metadata-padding: 4
|
||||||
|
commits-since-version-source-padding: 4
|
||||||
|
commit-message-incrementing: Enabled
|
||||||
|
branches:
|
||||||
|
main:
|
||||||
|
regex: ^master$|^main$
|
||||||
|
tag: ''
|
||||||
|
increment: Patch
|
||||||
|
prevent-increment-of-merged-branch-version: true
|
||||||
|
track-merge-target: false
|
||||||
|
source-branches: [ 'develop', 'release' ]
|
||||||
|
tracks-release-branches: false
|
||||||
|
is-release-branch: false
|
||||||
|
is-mainline: true
|
||||||
|
pre-release-weight: 55000
|
||||||
|
feature:
|
||||||
|
regex: ^features?[/-]
|
||||||
|
tag: useBranchName
|
||||||
|
increment: Inherit
|
||||||
|
prevent-increment-of-merged-branch-version: false
|
||||||
|
track-merge-target: false
|
||||||
|
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
|
||||||
|
tracks-release-branches: false
|
||||||
|
is-release-branch: false
|
||||||
|
is-mainline: false
|
||||||
|
pre-release-weight: 30000
|
||||||
|
release:
|
||||||
|
regex: ^releases?[/-]
|
||||||
|
tag: beta
|
||||||
|
increment: None
|
||||||
|
is-mainline: true
|
||||||
|
regex: ^releases?[/-]
|
||||||
|
prevent-increment-of-merged-branch-version: true
|
||||||
|
track-merge-target: false
|
||||||
|
source-branches: [ 'develop', 'main', 'support', 'release' ]
|
||||||
|
tracks-release-branches: false
|
||||||
|
is-release-branch: true
|
||||||
|
is-mainline: false
|
||||||
|
pre-release-weight: 30000
|
||||||
|
hotfix:
|
||||||
|
regex: ^hotfix(es)?[/-]
|
||||||
|
increment: Patch
|
||||||
|
prevent-increment-of-merged-branch-version: false
|
||||||
|
track-merge-target: false
|
||||||
|
source-branches: [ 'develop', 'main', 'support' ]
|
||||||
|
tracks-release-branches: false
|
||||||
|
is-release-branch: false
|
||||||
|
is-mainline: false
|
||||||
|
pre-release-weight: 30000
|
||||||
|
ignore:
|
||||||
|
sha: []
|
||||||
57
.pipelines/templated-pipeline.yml
Normal file
57
.pipelines/templated-pipeline.yml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
pool:
|
||||||
|
vmImage: 'windows-latest'
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- release/*
|
||||||
|
- feature/*
|
||||||
|
- hotfix/*
|
||||||
|
- bugfix/*
|
||||||
|
- development
|
||||||
|
|
||||||
|
variables:
|
||||||
|
project: 'Core.Cerberos.Service.API/Core.Cerberos.Service.API.csproj'
|
||||||
|
solution: 'Core.Cerberos.Service.API.sln'
|
||||||
|
buildConfiguration: 'Release'
|
||||||
|
artifactName: 'drop'
|
||||||
|
snykConnectionEndpoint: 'SnykConnection'
|
||||||
|
projectNameOnSonar: 'Core.Cerberos.Service.API'
|
||||||
|
projectKeyOnSonar: 'heathpbu_Core.Cerberos.Service.API'
|
||||||
|
feed: '1b3770f1-17db-4bf2-a43d-49f305aa7a22'
|
||||||
|
projectFileName: 'Core.Cerberos.Service.API.csproj'
|
||||||
|
projectPath: 'Core.Cerberos.Service.API/'
|
||||||
|
|
||||||
|
resources:
|
||||||
|
repositories:
|
||||||
|
- repository: templates
|
||||||
|
name: "Template.DevOps.Pipelines"
|
||||||
|
type: "git"
|
||||||
|
project: "SharedLibs"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- job: CI
|
||||||
|
steps:
|
||||||
|
- template: templates/dotnet/v1/step1_setup.yml@templates
|
||||||
|
- template: templates/dotnet/v1/step2_versioning.yml@templates
|
||||||
|
parameters:
|
||||||
|
projectFileName: '$(projectFileName)'
|
||||||
|
path: '$(projectPath)'
|
||||||
|
- template: templates/dotnet/v1/step3_restore_and_build.yml@templates
|
||||||
|
parameters:
|
||||||
|
project: '$(project)'
|
||||||
|
solution: '$(solution)'
|
||||||
|
buildConfiguration: '$(buildConfiguration)'
|
||||||
|
projectNameOnSonar: '$(projectNameOnSonar)'
|
||||||
|
projectKeyOnSonar: '$(projectKeyOnSonar)'
|
||||||
|
feed: '$(feed)'
|
||||||
|
|
||||||
|
- template: templates/dotnet/v1/step5_snyk_analysis.yml@templates
|
||||||
|
parameters:
|
||||||
|
snykConnectionEndpoint: '$(snykConnectionEndpoint)'
|
||||||
|
solutionToScan: '$(solution)'
|
||||||
|
|
||||||
|
- template: templates/dotnet/v1/step6_release.yml@templates
|
||||||
|
parameters:
|
||||||
|
artifactName: '$(artifactName)'
|
||||||
|
project: '$(project)'
|
||||||
20
Core.Cerberos.Application/Core.Cerberos.Application.csproj
Normal file
20
Core.Cerberos.Application/Core.Cerberos.Application.csproj
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Core.Blueprint.Storage" Version="0.3.0-alpha0049" />
|
||||||
|
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||||
|
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="0.9.0-alpha0001" />
|
||||||
|
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Core.Cerberos.External\Core.Cerberos.External.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Adapter
|
||||||
|
{
|
||||||
|
public class ModulePort : BasePresenter, IModulePort
|
||||||
|
{
|
||||||
|
public void Success(ModuleAdapter output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
public void Success(List<ModuleAdapter> output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||||
|
{
|
||||||
|
public class ChangeModuleStatusRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public StatusEnum Status { get; set; }
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||||
|
{
|
||||||
|
public class CreateModuleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public string? Icon { get; set; }
|
||||||
|
public string? Route { get; set; }
|
||||||
|
public int? Order { get; set; }
|
||||||
|
public ApplicationsEnum? Application { get; set; } = null!;
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Name != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||||
|
{
|
||||||
|
public class GetAllModulesByListRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string[] Modules { get; set; }
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Modules != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||||
|
{
|
||||||
|
public class GetAllModulesRequest : ICommand
|
||||||
|
{
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||||
|
{
|
||||||
|
public class GetModuleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||||
|
{
|
||||||
|
public class UpdateModuleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; } = null!;
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public string? Icon { get; set; }
|
||||||
|
public string Route { get; set; } = null!;
|
||||||
|
public int? Order { get; set; }
|
||||||
|
public ApplicationsEnum? Application { get; set; } = null!;
|
||||||
|
public StatusEnum Status { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
219
Core.Cerberos.Application/UseCases/Modules/ModuleHandler.cs
Normal file
219
Core.Cerberos.Application/UseCases/Modules/ModuleHandler.cs
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||||
|
using Core.Cerberos.External.Clients;
|
||||||
|
using Core.Cerberos.External.Clients.Requests;
|
||||||
|
using FluentValidation;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules
|
||||||
|
{
|
||||||
|
public class ModuleHandler :
|
||||||
|
IComponentHandler<ChangeModuleStatusRequest>,
|
||||||
|
IComponentHandler<GetAllModulesRequest>,
|
||||||
|
IComponentHandler<GetAllModulesByListRequest>,
|
||||||
|
IComponentHandler<UpdateModuleRequest>,
|
||||||
|
IComponentHandler<GetModuleRequest>,
|
||||||
|
IComponentHandler<CreateModuleRequest>
|
||||||
|
{
|
||||||
|
private readonly IModulePort _port;
|
||||||
|
private readonly IValidator<ChangeModuleStatusRequest> _changeModuleStatusValidator;
|
||||||
|
private readonly IValidator<CreateModuleRequest> _registerModuleValidator;
|
||||||
|
private readonly IValidator<UpdateModuleRequest> _updateModuleValidator;
|
||||||
|
private readonly IValidator<GetAllModulesByListRequest> _modulesByListValidator;
|
||||||
|
private readonly ICerberosServiceClient _cerberosDALService;
|
||||||
|
|
||||||
|
public ModuleHandler(
|
||||||
|
IModulePort port,
|
||||||
|
IValidator<ChangeModuleStatusRequest> changeModuleStatusValidator,
|
||||||
|
IValidator<CreateModuleRequest> registerModuleValidator,
|
||||||
|
IValidator<UpdateModuleRequest> updateModuleValidator,
|
||||||
|
IValidator<GetAllModulesByListRequest> modulesByListValidator,
|
||||||
|
ICerberosServiceClient cerberosDALService)
|
||||||
|
{
|
||||||
|
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||||
|
_changeModuleStatusValidator = changeModuleStatusValidator ?? throw new ArgumentNullException(nameof(changeModuleStatusValidator));
|
||||||
|
_registerModuleValidator = registerModuleValidator ?? throw new ArgumentNullException(nameof(registerModuleValidator));
|
||||||
|
_updateModuleValidator = updateModuleValidator ?? throw new ArgumentNullException(nameof(updateModuleValidator));
|
||||||
|
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||||
|
_modulesByListValidator = modulesByListValidator ?? throw new ArgumentNullException(nameof(modulesByListValidator));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetModuleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.GetModuleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetAllModulesRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var _result = await _cerberosDALService.GetAllModulesAsync().ConfigureAwait(false);
|
||||||
|
if (!_result.Any())
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_port.Success(_result.ToList());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetAllModulesByListRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_modulesByListValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _result = await _cerberosDALService.GetAllModulesByListAsync(command.Modules, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (!_result.Any())
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_port.Success(_result.ToList());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(ChangeModuleStatusRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_changeModuleStatusValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.ChangeStatusModuleAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(CreateModuleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_registerModuleValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new ModuleRequest
|
||||||
|
{
|
||||||
|
Name = command.Name,
|
||||||
|
Description = command.Description,
|
||||||
|
Icon = command.Icon,
|
||||||
|
Route = command.Route,
|
||||||
|
Order = command.Order,
|
||||||
|
Application = command.Application,
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.CreateModuleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(UpdateModuleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_updateModuleValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new ModuleAdapter
|
||||||
|
{
|
||||||
|
Id = command.Id,
|
||||||
|
Name = command.Name,
|
||||||
|
Description = command.Description,
|
||||||
|
Application = command.Application,
|
||||||
|
Route = command.Route,
|
||||||
|
Order = command.Order,
|
||||||
|
Icon = command.Icon,
|
||||||
|
Status = command.Status
|
||||||
|
};
|
||||||
|
|
||||||
|
string id = command.Id;
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Ports
|
||||||
|
{
|
||||||
|
public interface IModulePort : IBasePort,
|
||||||
|
ICommandSuccessPort<ModuleAdapter>,
|
||||||
|
ICommandSuccessPort<List<ModuleAdapter>>,
|
||||||
|
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||||
|
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||||
|
{
|
||||||
|
public class ChangeModuleStatusValidator : AbstractValidator<ChangeModuleStatusRequest>
|
||||||
|
{
|
||||||
|
public ChangeModuleStatusValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Module ID").WithMessage("Module ID is Obligatory.");
|
||||||
|
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||||
|
{
|
||||||
|
public class CreateModuleValidator : AbstractValidator<CreateModuleRequest>
|
||||||
|
{
|
||||||
|
public CreateModuleValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Module Name").WithMessage("Module Name is Obligatory.");
|
||||||
|
RuleFor(i => i.Route).NotEmpty().NotNull().OverridePropertyName(x => x.Route).WithName("Module Route").WithMessage("Module Route is Obligatory.");
|
||||||
|
RuleFor(i => i.Application).NotEmpty().NotNull().OverridePropertyName(x => x.Application).WithName("Application").WithMessage("Application is Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||||
|
{
|
||||||
|
public class GetAllModulesByListValidator : AbstractValidator<GetAllModulesByListRequest>
|
||||||
|
{
|
||||||
|
public GetAllModulesByListValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Modules).NotEmpty().NotNull().OverridePropertyName(x => x.Modules).WithName("Modules").WithMessage("Modules are Obligatory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||||
|
{
|
||||||
|
public class UpdateModuleValidator : AbstractValidator<UpdateModuleRequest>
|
||||||
|
{
|
||||||
|
public UpdateModuleValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Module Name").WithMessage("Module Name is Obligatory.");
|
||||||
|
RuleFor(i => i.Application).NotEmpty().NotNull().OverridePropertyName(x => x.Application).WithName("Application").WithMessage("Application is Obligatory.");
|
||||||
|
RuleFor(i => i.Route).NotEmpty().NotNull().OverridePropertyName(x => x.Route).WithName("Module Route").WithMessage("Module Route is Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Adapter
|
||||||
|
{
|
||||||
|
public class PermissionPort : BasePresenter, IPermissionPort
|
||||||
|
{
|
||||||
|
public void Success(PermissionAdapter output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
public void Success(List<PermissionAdapter> output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||||
|
{
|
||||||
|
public class ChangePermissionStatusRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public StatusEnum Status { get; set; }
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||||
|
{
|
||||||
|
public class CreatePermissionRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string Description { get; set; } = null!;
|
||||||
|
public AccessLevelEnum? AccessLevel { get; set; } = null!;
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Name != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||||
|
{
|
||||||
|
public class GetAllPermissionsByListRequest : ICommand
|
||||||
|
{
|
||||||
|
public string[]? Permissions { get; set; }
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Permissions != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||||
|
{
|
||||||
|
public class GetAllPermissionsRequest : ICommand
|
||||||
|
{
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||||
|
{
|
||||||
|
public class GetPermissionRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||||
|
{
|
||||||
|
public class UpdatePermissionRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; } = null!;
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public AccessLevelEnum? AccessLevel { get; set; } = null!;
|
||||||
|
public StatusEnum Status { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,204 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||||
|
using Core.Cerberos.External.Clients;
|
||||||
|
using Core.Cerberos.External.Clients.Requests;
|
||||||
|
using FluentValidation;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions
|
||||||
|
{
|
||||||
|
public class PermissionHandler :
|
||||||
|
IComponentHandler<ChangePermissionStatusRequest>,
|
||||||
|
IComponentHandler<GetAllPermissionsRequest>,
|
||||||
|
IComponentHandler<GetAllPermissionsByListRequest>,
|
||||||
|
IComponentHandler<UpdatePermissionRequest>,
|
||||||
|
IComponentHandler<GetPermissionRequest>,
|
||||||
|
IComponentHandler<CreatePermissionRequest>
|
||||||
|
{
|
||||||
|
private readonly IPermissionPort _port;
|
||||||
|
private readonly IValidator<ChangePermissionStatusRequest> _changePermissionStatusValidator;
|
||||||
|
private readonly IValidator<CreatePermissionRequest> _registerPermissionValidator;
|
||||||
|
private readonly IValidator<UpdatePermissionRequest> _updatePermissionValidator;
|
||||||
|
private readonly ICerberosServiceClient _cerberosDALService;
|
||||||
|
|
||||||
|
public PermissionHandler(
|
||||||
|
IPermissionPort port,
|
||||||
|
IValidator<ChangePermissionStatusRequest> changePermissionStatusValidator,
|
||||||
|
IValidator<CreatePermissionRequest> registerPermissionValidator,
|
||||||
|
IValidator<UpdatePermissionRequest> updatePermissionValidator,
|
||||||
|
ICerberosServiceClient cerberosDALService)
|
||||||
|
{
|
||||||
|
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||||
|
_changePermissionStatusValidator = changePermissionStatusValidator ?? throw new ArgumentNullException(nameof(changePermissionStatusValidator));
|
||||||
|
_registerPermissionValidator = registerPermissionValidator ?? throw new ArgumentNullException(nameof(registerPermissionValidator));
|
||||||
|
_updatePermissionValidator = updatePermissionValidator ?? throw new ArgumentNullException(nameof(updatePermissionValidator));
|
||||||
|
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetPermissionRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.GetPermissionByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetAllPermissionsRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var _result = await _cerberosDALService.GetAllPermissionsAsync().ConfigureAwait(false);
|
||||||
|
if (!_result.Any())
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_port.Success(_result.ToList());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetAllPermissionsByListRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var _result = await _cerberosDALService.GetAllPermissionsByListAsync(command.Permissions, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (!_result.Any())
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_port.Success(_result.ToList());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(ChangePermissionStatusRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_changePermissionStatusValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.ChangeStatusPermissionAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(CreatePermissionRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_registerPermissionValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new PermissionRequest
|
||||||
|
{
|
||||||
|
Name = command.Name,
|
||||||
|
Description = command.Description,
|
||||||
|
AccessLevel = command.AccessLevel
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.CreatePermissionAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(UpdatePermissionRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_updatePermissionValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new PermissionAdapter
|
||||||
|
{
|
||||||
|
Id = command.Id,
|
||||||
|
Name = command.Name,
|
||||||
|
Description = command.Description,
|
||||||
|
AccessLevel = command.AccessLevel,
|
||||||
|
Status = command.Status
|
||||||
|
};
|
||||||
|
|
||||||
|
string id = command.Id;
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Ports
|
||||||
|
{
|
||||||
|
public interface IPermissionPort : IBasePort,
|
||||||
|
ICommandSuccessPort<PermissionAdapter>,
|
||||||
|
ICommandSuccessPort<List<PermissionAdapter>>,
|
||||||
|
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||||
|
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||||
|
{
|
||||||
|
public class ChangePermissionStatusValidator : AbstractValidator<ChangePermissionStatusRequest>
|
||||||
|
{
|
||||||
|
public ChangePermissionStatusValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Permission ID").WithMessage("Permission ID is Obligatory.");
|
||||||
|
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||||
|
{
|
||||||
|
public class CreatePermissionValidator : AbstractValidator<CreatePermissionRequest>
|
||||||
|
{
|
||||||
|
public CreatePermissionValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Permission Name").WithMessage("Permission Name is Obligatory.");
|
||||||
|
RuleFor(i => i.Description).NotEmpty().NotNull().OverridePropertyName(x => x.Description).WithName("Permission Description").WithMessage("Permission Description is Obligatory.");
|
||||||
|
RuleFor(i => i.AccessLevel).NotEmpty().NotNull().OverridePropertyName(x => x.AccessLevel).WithName("AccesLevel").WithMessage("AccesLevel is Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||||
|
{
|
||||||
|
public class UpdatePermissionValidator : AbstractValidator<UpdatePermissionRequest>
|
||||||
|
{
|
||||||
|
public UpdatePermissionValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Permission Name").WithMessage("Permission Name is Obligatory.");
|
||||||
|
RuleFor(i => i.Description).NotEmpty().NotNull().OverridePropertyName(x => x.Description).WithName("Permission Description").WithMessage("Permission Description is Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Core.Cerberos.Application/UseCases/Roles/Adapter/RolePort.cs
Normal file
19
Core.Cerberos.Application/UseCases/Roles/Adapter/RolePort.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Adapter
|
||||||
|
{
|
||||||
|
public class RolePort : BasePresenter, IRolePort
|
||||||
|
{
|
||||||
|
public void Success(RoleAdapter output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
public void Success(List<RoleAdapter> output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||||
|
{
|
||||||
|
public class AddApplicationToRoleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string RoleId { get; set; }
|
||||||
|
public ApplicationsEnum Application { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||||
|
{
|
||||||
|
public class ChangeRoleStatusRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public StatusEnum Status { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||||
|
{
|
||||||
|
public class CreateRoleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string Description { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonConverter(typeof(EnumArrayJsonConverter<ApplicationsEnum>))]
|
||||||
|
public ApplicationsEnum[]? Applications { get; set; } = null!;
|
||||||
|
public string[] Modules { get; set; } = null!;
|
||||||
|
public string[] Permissions { get; set; } = null!;
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Name != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||||
|
{
|
||||||
|
public class GetAllRolesRequest : ICommand
|
||||||
|
{
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||||
|
{
|
||||||
|
public class GetRoleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||||
|
{
|
||||||
|
public class RemoveApplicationFromRoleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string RoleId { get; set; }
|
||||||
|
public ApplicationsEnum Application { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||||
|
{
|
||||||
|
public class UpdateRoleRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; } = null!;
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(EnumArrayJsonConverter<ApplicationsEnum>))]
|
||||||
|
public ApplicationsEnum[]? Applications { get; set; }
|
||||||
|
public string[] Modules { get; set; } = null!;
|
||||||
|
public string[] Permissions { get; set; } = null!;
|
||||||
|
public StatusEnum Status { get; set; }
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Core.Cerberos.Application/UseCases/Roles/Ports/IRolePort.cs
Normal file
12
Core.Cerberos.Application/UseCases/Roles/Ports/IRolePort.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Ports
|
||||||
|
{
|
||||||
|
public interface IRolePort : IBasePort,
|
||||||
|
ICommandSuccessPort<RoleAdapter>, ICommandSuccessPort<List<RoleAdapter>>,
|
||||||
|
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||||
|
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
235
Core.Cerberos.Application/UseCases/Roles/RoleHandler.cs
Normal file
235
Core.Cerberos.Application/UseCases/Roles/RoleHandler.cs
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||||
|
using Core.Cerberos.External.Clients;
|
||||||
|
using Core.Cerberos.External.Clients.Requests;
|
||||||
|
using FluentValidation;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Role
|
||||||
|
{
|
||||||
|
public class RoleHandler :
|
||||||
|
IComponentHandler<ChangeRoleStatusRequest>,
|
||||||
|
IComponentHandler<GetAllRolesRequest>,
|
||||||
|
IComponentHandler<UpdateRoleRequest>,
|
||||||
|
IComponentHandler<CreateRoleRequest>,
|
||||||
|
IComponentHandler<GetRoleRequest>,
|
||||||
|
IComponentHandler<AddApplicationToRoleRequest>,
|
||||||
|
IComponentHandler<RemoveApplicationFromRoleRequest>
|
||||||
|
|
||||||
|
{
|
||||||
|
private readonly IRolePort _port;
|
||||||
|
private readonly IValidator<ChangeRoleStatusRequest> _changeRoleStatusValidator;
|
||||||
|
private readonly IValidator<CreateRoleRequest> _registerRoleValidator;
|
||||||
|
private readonly IValidator<UpdateRoleRequest> _updateRoleValidator;
|
||||||
|
private readonly ICerberosServiceClient _cerberosDALService;
|
||||||
|
|
||||||
|
public RoleHandler(
|
||||||
|
IRolePort port,
|
||||||
|
IValidator<ChangeRoleStatusRequest> changeRoleStatusValidator,
|
||||||
|
IValidator<CreateRoleRequest> registerRoleValidator,
|
||||||
|
IValidator<UpdateRoleRequest> updateRoleValidator,
|
||||||
|
ICerberosServiceClient cerberosDALService)
|
||||||
|
{
|
||||||
|
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||||
|
_changeRoleStatusValidator = changeRoleStatusValidator ?? throw new ArgumentNullException(nameof(changeRoleStatusValidator));
|
||||||
|
_registerRoleValidator = registerRoleValidator ?? throw new ArgumentNullException(nameof(registerRoleValidator));
|
||||||
|
_updateRoleValidator = updateRoleValidator ?? throw new ArgumentNullException(nameof(updateRoleValidator));
|
||||||
|
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetRoleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.GetRoleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetAllRolesRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var _result = await _cerberosDALService.GetAllRolesAsync().ConfigureAwait(false);
|
||||||
|
if (!_result.Any())
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_port.Success(_result.ToList());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(ChangeRoleStatusRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_changeRoleStatusValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.ChangeRoleStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(CreateRoleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_registerRoleValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new RoleRequest
|
||||||
|
{
|
||||||
|
Name = command.Name,
|
||||||
|
Description = command.Description,
|
||||||
|
Applications = command.Applications,
|
||||||
|
Modules = command.Modules,
|
||||||
|
Permissions = command.Permissions
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.CreateRoleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(UpdateRoleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_updateRoleValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new RoleAdapter
|
||||||
|
{
|
||||||
|
Id = command.Id,
|
||||||
|
Name = command.Name,
|
||||||
|
Description = command.Description,
|
||||||
|
Applications = command.Applications,
|
||||||
|
Modules = command.Modules,
|
||||||
|
Permissions = command.Permissions,
|
||||||
|
Status = command.Status
|
||||||
|
};
|
||||||
|
|
||||||
|
string id = command.Id;
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(AddApplicationToRoleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.AddApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(RemoveApplicationFromRoleRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.RemoveApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||||
|
{
|
||||||
|
public class ChangeRoleStatusValidator : AbstractValidator<ChangeRoleStatusRequest>
|
||||||
|
{
|
||||||
|
public ChangeRoleStatusValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Role ID").WithMessage("Role ID is Obligatory.");
|
||||||
|
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||||
|
{
|
||||||
|
public class CreateRoleValidator : AbstractValidator<CreateRoleRequest>
|
||||||
|
{
|
||||||
|
public CreateRoleValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Role Name").WithMessage("Role Name is Obligatory.");
|
||||||
|
RuleFor(i => i.Description).NotEmpty().NotNull().OverridePropertyName(x => x.Description).WithName("Role Description").WithMessage("Role Description is Obligatory.");
|
||||||
|
RuleFor(i => i.Applications).NotNull().OverridePropertyName(x => x.Applications).WithName("AccesLevel").WithMessage("Role must have at least one application.");
|
||||||
|
RuleFor(i => i.Permissions).NotEmpty().NotNull().OverridePropertyName(x => x.Applications).WithName("Role permissions").WithMessage("Role Permissions are Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||||
|
{
|
||||||
|
public class UpdateRoleValidator : AbstractValidator<UpdateRoleRequest>
|
||||||
|
{
|
||||||
|
public UpdateRoleValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Role Name").WithMessage("Role Name is Obligatory.");
|
||||||
|
RuleFor(i => i.Description).NotEmpty().NotNull().OverridePropertyName(x => x.Description).WithName("Role Description").WithMessage("Role Description is Obligatory.");
|
||||||
|
RuleFor(i => i.Applications).NotEmpty().NotNull().OverridePropertyName(x => x.Applications).WithName("Role applications").WithMessage("Role Applications are Obligatory.");
|
||||||
|
RuleFor(i => i.Permissions).NotEmpty().NotNull().OverridePropertyName(x => x.Applications).WithName("Role permissions").WithMessage("Role Permissions are Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
Core.Cerberos.Application/UseCases/Users/Adapter/UserPort.cs
Normal file
33
Core.Cerberos.Application/UseCases/Users/Adapter/UserPort.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using Core.Blueprint.Storage.Adapters;
|
||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Adapter
|
||||||
|
{
|
||||||
|
public class UserPort : BasePresenter, IUserPort
|
||||||
|
{
|
||||||
|
public void Success(UserAdapter output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
public void Success(List<UserAdapter> output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Success(UserExistenceAdapter output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
public void Success(TokenAdapter output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
public void Success(BlobDownloadUriAdapter output)
|
||||||
|
{
|
||||||
|
ViewModel = new OkObjectResult(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class AcceptUserConsentFormRequest : ICommand
|
||||||
|
{
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class AddCompanyToUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string UserId { get; set; }
|
||||||
|
public string CompanyId { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class AddProjectToUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string UserId { get; set; }
|
||||||
|
public string ProjectId { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class ChangeUserStatusRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public StatusEnum Status { get; set; }
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class CreateUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Email { get; set; } = null!;
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string MiddleName { get; set; } = null!;
|
||||||
|
public string LastName { get; set; } = null!;
|
||||||
|
public string RoleId { get; set; } = null!;
|
||||||
|
public string[] Companies { get; set; } = null!;
|
||||||
|
public string[]? Projects { get; set; }
|
||||||
|
public bool SendInvitation { get; set; }
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Name != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class GetAllUsersRequest : ICommand
|
||||||
|
{
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class GetConsentFormPDFRequest : ICommand
|
||||||
|
{
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class GetTokenAdapterRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Email { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Email != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class GetUserByEmailRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Email { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Email != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class GetUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class LoginUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Email { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Email != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class LogoutUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Email { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Email != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class RemoveCompanyFromUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string UserId { get; set; }
|
||||||
|
public string CompanyId { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class RemoveProjectFromUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string UserId { get; set; }
|
||||||
|
public string ProjectId { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class UpdateUserRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; } = null!;
|
||||||
|
public string Email { get; set; } = null!;
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? MiddleName { get; set; }
|
||||||
|
public string LastName { get; set; } = null!;
|
||||||
|
public string RoleId { get; set; } = null!;
|
||||||
|
public string[] Companies { get; set; } = null!;
|
||||||
|
public string[]? Projects { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Email != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||||
|
{
|
||||||
|
public class ValidateUserExistenceRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Email { get; set; }
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Email != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Core.Cerberos.Application/UseCases/Users/Ports/IUserPort.cs
Normal file
17
Core.Cerberos.Application/UseCases/Users/Ports/IUserPort.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Core.Blueprint.Storage.Adapters;
|
||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Ports
|
||||||
|
{
|
||||||
|
public interface IUserPort : IBasePort,
|
||||||
|
ICommandSuccessPort<UserAdapter>,
|
||||||
|
ICommandSuccessPort<UserExistenceAdapter>,
|
||||||
|
ICommandSuccessPort<List<UserAdapter>>,
|
||||||
|
ICommandSuccessPort<TokenAdapter>,
|
||||||
|
ICommandSuccessPort<BlobDownloadUriAdapter>,
|
||||||
|
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||||
|
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
439
Core.Cerberos.Application/UseCases/Users/UserHandler.cs
Normal file
439
Core.Cerberos.Application/UseCases/Users/UserHandler.cs
Normal file
@ -0,0 +1,439 @@
|
|||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||||
|
using Core.Cerberos.External.Clients;
|
||||||
|
using Core.Cerberos.External.Clients.Requests;
|
||||||
|
using FluentValidation;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users
|
||||||
|
{
|
||||||
|
public class UserHandler :
|
||||||
|
IComponentHandler<ChangeUserStatusRequest>,
|
||||||
|
IComponentHandler<GetAllUsersRequest>,
|
||||||
|
IComponentHandler<UpdateUserRequest>,
|
||||||
|
IComponentHandler<GetUserRequest>,
|
||||||
|
IComponentHandler<GetUserByEmailRequest>,
|
||||||
|
IComponentHandler<CreateUserRequest>,
|
||||||
|
IComponentHandler<AddProjectToUserRequest>,
|
||||||
|
IComponentHandler<RemoveProjectFromUserRequest>,
|
||||||
|
IComponentHandler<AddCompanyToUserRequest>,
|
||||||
|
IComponentHandler<RemoveCompanyFromUserRequest>,
|
||||||
|
IComponentHandler<LoginUserRequest>,
|
||||||
|
IComponentHandler<LogoutUserRequest>,
|
||||||
|
IComponentHandler<ValidateUserExistenceRequest>,
|
||||||
|
IComponentHandler<GetTokenAdapterRequest>,
|
||||||
|
IComponentHandler<GetConsentFormPDFRequest>,
|
||||||
|
IComponentHandler<AcceptUserConsentFormRequest>
|
||||||
|
{
|
||||||
|
private readonly IUserPort _port;
|
||||||
|
private readonly IValidator<ChangeUserStatusRequest> _changeUserStatusValidator;
|
||||||
|
private readonly IValidator<CreateUserRequest> _registerUserValidator;
|
||||||
|
private readonly IValidator<UpdateUserRequest> _updateUserValidator;
|
||||||
|
private readonly ICerberosServiceClient _cerberosDALService;
|
||||||
|
|
||||||
|
public UserHandler(
|
||||||
|
IUserPort port,
|
||||||
|
IValidator<ChangeUserStatusRequest> changeUserStatusValidator,
|
||||||
|
IValidator<CreateUserRequest> registerUserValidator,
|
||||||
|
IValidator<UpdateUserRequest> updateUserValidator,
|
||||||
|
ICerberosServiceClient cerberosDALService)
|
||||||
|
{
|
||||||
|
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||||
|
_changeUserStatusValidator = changeUserStatusValidator ?? throw new ArgumentNullException(nameof(changeUserStatusValidator));
|
||||||
|
_registerUserValidator = registerUserValidator ?? throw new ArgumentNullException(nameof(registerUserValidator));
|
||||||
|
_updateUserValidator = updateUserValidator ?? throw new ArgumentNullException(nameof(updateUserValidator));
|
||||||
|
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.GetUserByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetUserByEmailRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.GetUserByEmailAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(ValidateUserExistenceRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.ValidateUserExistence(command.Email, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetAllUsersRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var _result = await _cerberosDALService.GetAllUsersAsync().ConfigureAwait(false);
|
||||||
|
if (!_result.Any())
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_port.Success(_result.ToList());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(ChangeUserStatusRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_changeUserStatusValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.ChangeUserStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(CreateUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_registerUserValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new UserRequest
|
||||||
|
{
|
||||||
|
Email = command.Email,
|
||||||
|
Name = command.Name,
|
||||||
|
MiddleName = command.MiddleName,
|
||||||
|
LastName = command.LastName,
|
||||||
|
RoleId = command.RoleId,
|
||||||
|
Companies = command.Companies,
|
||||||
|
Projects = command.Projects,
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(UpdateUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
if (!command.IsValid(_updateUserValidator))
|
||||||
|
{
|
||||||
|
_port.ValidationErrors(command.Notifications);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = new UserAdapter
|
||||||
|
{
|
||||||
|
Id = command.Id,
|
||||||
|
Email = command.Email,
|
||||||
|
Name = command.Name,
|
||||||
|
MiddleName = command.MiddleName,
|
||||||
|
LastName = command.LastName,
|
||||||
|
RoleId = command.RoleId,
|
||||||
|
Companies = command.Companies,
|
||||||
|
Projects = command.Projects
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.UpdateUserAsync(request, request.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(LoginUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.LoginUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(LogoutUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.LogoutUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(AddCompanyToUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.AddCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(RemoveCompanyFromUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.RemoveCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(AddProjectToUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.AddProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(RemoveProjectFromUserRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.RemoveProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetTokenAdapterRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.GetTokenAdapter(command.Email, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(GetConsentFormPDFRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var _result = await _cerberosDALService.GetConsentFormPDFAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
if (_result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_port.Success(_result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask ExecuteAsync(AcceptUserConsentFormRequest command, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
|
var result = await _cerberosDALService.AcceptUserConsentFormAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
_port.NoContentSuccess();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_port.Success(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||||
|
{
|
||||||
|
public class ChangeUserStatusValidator : AbstractValidator<ChangeUserStatusRequest>
|
||||||
|
{
|
||||||
|
public ChangeUserStatusValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("User ID").WithMessage("User ID is Obligatory.");
|
||||||
|
RuleFor(i => i.Status).NotNull().NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||||
|
{
|
||||||
|
public class CreateUserValidator : AbstractValidator<CreateUserRequest>
|
||||||
|
{
|
||||||
|
public CreateUserValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("Email is Obligatory.");
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("User Name").WithMessage("User Name is Obligatory.");
|
||||||
|
RuleFor(i => i.LastName).NotEmpty().NotNull().OverridePropertyName(x => x.LastName).WithName("User LastName").WithMessage("User LastName is Obligatory.");
|
||||||
|
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("Role Id").WithMessage("Role Id is Obligatory.");
|
||||||
|
RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||||
|
{
|
||||||
|
public class UpdateUserValidator : AbstractValidator<UpdateUserRequest>
|
||||||
|
{
|
||||||
|
public UpdateUserValidator()
|
||||||
|
{
|
||||||
|
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("Email is Obligatory.");
|
||||||
|
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("User Name").WithMessage("User Name is Obligatory.");
|
||||||
|
RuleFor(i => i.LastName).NotEmpty().NotNull().OverridePropertyName(x => x.LastName).WithName("User LastName").WithMessage("User LastName is Obligatory.");
|
||||||
|
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("Role Id").WithMessage("Role Id is Obligatory.");
|
||||||
|
RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
using Core.Cerberos.External.Clients;
|
||||||
|
using Core.Cerberos.External.GatewayConfigurations;
|
||||||
|
using Core.Cerberos.External.Helpers.Token;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Refit;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.ClientConfiguration
|
||||||
|
{
|
||||||
|
public static class RegisterClientConfiguration
|
||||||
|
{
|
||||||
|
public static IServiceCollection RegisterExternalLayer(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
var gatewayConfiguration = new GatewayConfiguration();
|
||||||
|
var gatewaySettingsConfiguration = new GatewaySettingsConfigurations(configuration);
|
||||||
|
|
||||||
|
// Register GatewayConfiguration as a singleton
|
||||||
|
services.AddSingleton(gatewayConfiguration);
|
||||||
|
|
||||||
|
// Register IHttpContextAccessor
|
||||||
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
|
|
||||||
|
// Register ITokenProvider
|
||||||
|
services.AddSingleton<ITokenProvider, HttpContextTokenProvider>();
|
||||||
|
|
||||||
|
// Register the custom AuthenticatedHttpClientHandler
|
||||||
|
services.AddTransient(provider =>
|
||||||
|
{
|
||||||
|
var tokenProvider = provider.GetRequiredService<ITokenProvider>();
|
||||||
|
var handler = new AuthenticatedHttpClientHandler(tokenProvider)
|
||||||
|
{
|
||||||
|
InnerHandler = new HttpClientHandler() // Setting the InnerHandler manually
|
||||||
|
};
|
||||||
|
return handler;
|
||||||
|
});
|
||||||
|
|
||||||
|
var cerberosServiceApiUrl = GatewaySettingsConfigurations.GetCerberosServiceAPIEndpoint().Endpoint.Url;
|
||||||
|
|
||||||
|
// Register ICerberosServiceClient with the manually created HttpClient
|
||||||
|
services.AddScoped<ICerberosServiceClient>(provider =>
|
||||||
|
{
|
||||||
|
var handler = provider.GetRequiredService<AuthenticatedHttpClientHandler>();
|
||||||
|
var httpClient = new HttpClient(handler)
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri(cerberosServiceApiUrl),
|
||||||
|
Timeout = TimeSpan.FromMinutes(1)
|
||||||
|
};
|
||||||
|
return RestService.For<ICerberosServiceClient>(httpClient);
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddScoped<IAuthenticationService, AuthenticationService>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
118
Core.Cerberos.External/Clients/ICerberosServiceClient.cs
Normal file
118
Core.Cerberos.External/Clients/ICerberosServiceClient.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
using Core.Blueprint.Storage.Adapters;
|
||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using Core.Cerberos.External.Clients.Requests;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Refit;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.Clients
|
||||||
|
{
|
||||||
|
public interface ICerberosServiceClient
|
||||||
|
{
|
||||||
|
[Get("/v1/User")]
|
||||||
|
Task<IEnumerable<UserAdapter>> GetAllUsersAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/User/" + Routes.Id)]
|
||||||
|
Task<UserAdapter> GetUserByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/User/" + Routes.Email)]
|
||||||
|
Task<UserAdapter> GetUserByEmailAsync([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/User/{email}/ValidateExistence")]
|
||||||
|
Task<UserExistenceAdapter> ValidateUserExistence([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/User/" + Routes.Register)]
|
||||||
|
Task<UserAdapter> CreateUserAsync([FromBody] UserRequest newUser, [FromRoute] bool sendInvitation, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Put("/v1/User/" + Routes.Id)]
|
||||||
|
Task<UserAdapter> UpdateUserAsync([FromBody] UserAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Patch("/v1/User/" + Routes.LogIn)]
|
||||||
|
Task<UserAdapter> LoginUserAsync([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Patch("/v1/User/" + Routes.LogOut)]
|
||||||
|
Task<UserAdapter> LogoutUserAsync([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Patch("/v1/User/" + Routes.ChangeStatus)]
|
||||||
|
Task<UserAdapter> ChangeUserStatusAsync([FromRoute] string id, StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/User/{email}/GetTokenAdapter")]
|
||||||
|
Task<TokenAdapter> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/User/" + Routes.AddCompany)]
|
||||||
|
Task<UserAdapter> AddCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Delete("/v1/User/" + Routes.RemoveCompany)]
|
||||||
|
Task<UserAdapter> RemoveCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/User/" + Routes.AddProject)]
|
||||||
|
Task<UserAdapter> AddProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Delete("/v1/User/" + Routes.RemoveProject)]
|
||||||
|
Task<UserAdapter> RemoveProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/User/GetConsentFormPDF")]
|
||||||
|
Task<BlobDownloadUriAdapter> GetConsentFormPDFAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Patch("/v1/User/AcceptUserConsentForm")]
|
||||||
|
Task<UserAdapter> AcceptUserConsentFormAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/Role")]
|
||||||
|
Task<IEnumerable<RoleAdapter>> GetAllRolesAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/Role/" + Routes.Id)]
|
||||||
|
Task<RoleAdapter> GetRoleByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/Role")]
|
||||||
|
Task<RoleAdapter> CreateRoleAsync([FromBody] RoleRequest newRole, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Put("/v1/Role/" + Routes.Id)]
|
||||||
|
Task<RoleAdapter> UpdateRoleAsync([FromBody] RoleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Patch("/v1/Role/" + Routes.ChangeStatus)]
|
||||||
|
Task<RoleAdapter> ChangeRoleStatusAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/Role/" + Routes.AddApplication)]
|
||||||
|
Task<RoleAdapter> AddApplicationToRoleAsync([FromRoute] string RoleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Delete("/v1/Role/" + Routes.RemoveApplication)]
|
||||||
|
Task<RoleAdapter> RemoveApplicationToRoleAsync([FromRoute] string RoleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/Permission")]
|
||||||
|
Task<IEnumerable<PermissionAdapter>> GetAllPermissionsAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/Permission/" + Routes.GetPermissionList)]
|
||||||
|
Task<IEnumerable<PermissionAdapter>> GetAllPermissionsByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/Permission/" + Routes.Id)]
|
||||||
|
Task<PermissionAdapter> GetPermissionByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/Permission")]
|
||||||
|
Task<PermissionAdapter> CreatePermissionAsync([FromBody] PermissionRequest newPermission, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Put("/v1/Permission/" + Routes.Id)]
|
||||||
|
Task<PermissionAdapter> UpdatePermissionAsync([FromBody] PermissionAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Patch("/v1/Permission/" + Routes.ChangeStatus)]
|
||||||
|
Task<PermissionAdapter> ChangeStatusPermissionAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/Module")]
|
||||||
|
Task<IEnumerable<ModuleAdapter>> GetAllModulesAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/Module/" + Routes.GetModuleList)]
|
||||||
|
Task<IEnumerable<ModuleAdapter>> GetAllModulesByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Get("/v1/Module/" + Routes.Id)]
|
||||||
|
Task<ModuleAdapter> GetModuleByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Post("/v1/Module")]
|
||||||
|
Task<ModuleAdapter> CreateModuleAsync([FromBody] ModuleRequest newModule, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Put("/v1/Module/" + Routes.Id)]
|
||||||
|
Task<ModuleAdapter> UpdateModuleAsync([FromBody] ModuleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Patch("/v1/Module/" + Routes.ChangeStatus)]
|
||||||
|
Task<ModuleAdapter> ChangeStatusModuleAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Core.Cerberos.External/Clients/Requests/ModuleRequest.cs
Normal file
16
Core.Cerberos.External/Clients/Requests/ModuleRequest.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.Clients.Requests
|
||||||
|
{
|
||||||
|
public class ModuleRequest
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public string? Icon { get; set; }
|
||||||
|
public string? Route { get; set; }
|
||||||
|
public int? Order { get; set; }
|
||||||
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
|
public ApplicationsEnum? Application { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Core.Cerberos.External/Clients/Requests/PermissionRequest.cs
Normal file
12
Core.Cerberos.External/Clients/Requests/PermissionRequest.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.Clients.Requests
|
||||||
|
{
|
||||||
|
public class PermissionRequest
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public string? RoleId { get; set; }
|
||||||
|
public AccessLevelEnum? AccessLevel { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Core.Cerberos.External/Clients/Requests/RoleRequest.cs
Normal file
16
Core.Cerberos.External/Clients/Requests/RoleRequest.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Core.Cerberos.Adapters.Common.Enums;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.Clients.Requests
|
||||||
|
{
|
||||||
|
public class RoleRequest
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? Description { get; set; }
|
||||||
|
[JsonConverter(typeof(EnumArrayJsonConverter<ApplicationsEnum>))]
|
||||||
|
public ApplicationsEnum[]? Applications { get; set; }
|
||||||
|
public string[] Modules { get; set; } = null!;
|
||||||
|
public string[] Permissions { get; set; } = null!;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Core.Cerberos.External/Clients/Requests/UserRequest.cs
Normal file
13
Core.Cerberos.External/Clients/Requests/UserRequest.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace Core.Cerberos.External.Clients.Requests
|
||||||
|
{
|
||||||
|
public class UserRequest
|
||||||
|
{
|
||||||
|
public string Email { get; set; } = null!;
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? MiddleName { get; set; }
|
||||||
|
public string LastName { get; set; } = null!;
|
||||||
|
public string RoleId { get; set; } = null!;
|
||||||
|
public string[] Companies { get; set; } = null!;
|
||||||
|
public string[]? Projects { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Core.Cerberos.External/Core.Cerberos.External.csproj
Normal file
16
Core.Cerberos.External/Core.Cerberos.External.csproj
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Core.Blueprint.Storage" Version="0.3.0-alpha0049" />
|
||||||
|
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||||
|
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="0.9.0-alpha0001" />
|
||||||
|
<PackageReference Include="Refit" Version="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
using Core.Blueprint.External;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.GatewayConfigurations
|
||||||
|
{
|
||||||
|
public record GatewayConfiguration
|
||||||
|
{
|
||||||
|
public GatewayConfiguration()
|
||||||
|
{
|
||||||
|
CerberosService = new CerberosServiceAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CerberosServiceAPI CerberosService { get; set; }
|
||||||
|
}
|
||||||
|
public record CerberosServiceAPI
|
||||||
|
{
|
||||||
|
public string Channel { get; set; }
|
||||||
|
public BaseEndpoint Endpoint { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
using Core.Blueprint.External;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.GatewayConfigurations
|
||||||
|
{
|
||||||
|
public class GatewaySettingsConfigurations
|
||||||
|
{
|
||||||
|
private static GatewayConfiguration GatewayConfigurations { get; set; } = new GatewayConfiguration();
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
|
public GatewaySettingsConfigurations(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_configuration = configuration;
|
||||||
|
this.SetCerberosServiceAPIEndpoint();
|
||||||
|
}
|
||||||
|
public static CerberosServiceAPI GetCerberosServiceAPIEndpoint()
|
||||||
|
{
|
||||||
|
return GatewayConfigurations.CerberosService;
|
||||||
|
}
|
||||||
|
private GatewayConfiguration SetCerberosServiceAPIEndpoint()
|
||||||
|
{
|
||||||
|
IConfigurationSection source;
|
||||||
|
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
|
||||||
|
|
||||||
|
if (environment == "Local")
|
||||||
|
source = _configuration.GetSection("LocalGateways");
|
||||||
|
else
|
||||||
|
source = _configuration.GetSection("Gateways");
|
||||||
|
|
||||||
|
var endpoint = source["CerberosDAL"] ?? string.Empty;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Cerberos DAL endpoint is empty or null");
|
||||||
|
|
||||||
|
GatewayConfigurations.CerberosService = new CerberosServiceAPI()
|
||||||
|
{
|
||||||
|
Endpoint = new BaseEndpoint()
|
||||||
|
{
|
||||||
|
Uri = new Uri(endpoint),
|
||||||
|
Url = endpoint,
|
||||||
|
Token = string.Empty,
|
||||||
|
APIName = "Cerberos Service"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return GatewayConfigurations;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="AuthenticatedHttpClientHandler.cs">
|
||||||
|
// Heath
|
||||||
|
// </copyright>
|
||||||
|
// ***********************************************************************
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.Helpers.Token
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to inject the token in all requests.
|
||||||
|
/// </summary>
|
||||||
|
public class AuthenticatedHttpClientHandler : DelegatingHandler
|
||||||
|
{
|
||||||
|
private readonly ITokenProvider _tokenProvider;
|
||||||
|
|
||||||
|
public AuthenticatedHttpClientHandler(ITokenProvider tokenProvider)
|
||||||
|
{
|
||||||
|
_tokenProvider = tokenProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var token = _tokenProvider.GetToken();
|
||||||
|
if (!string.IsNullOrEmpty(token))
|
||||||
|
{
|
||||||
|
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await base.SendAsync(request, cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="HttpContextTokenProvider.cs">
|
||||||
|
// Heath
|
||||||
|
// </copyright>
|
||||||
|
// ***********************************************************************
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.Helpers.Token
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to return the access token to controllers.
|
||||||
|
/// </summary>
|
||||||
|
public class HttpContextTokenProvider : ITokenProvider
|
||||||
|
{
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public HttpContextTokenProvider(IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get token from headers.
|
||||||
|
/// </summary>
|
||||||
|
public string GetToken()
|
||||||
|
{
|
||||||
|
return _httpContextAccessor.HttpContext?.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Core.Cerberos.External/Helpers/Token/ITokenProvider.cs
Normal file
19
Core.Cerberos.External/Helpers/Token/ITokenProvider.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="ITokenProvider.cs">
|
||||||
|
// Heath
|
||||||
|
// </copyright>
|
||||||
|
// ***********************************************************************
|
||||||
|
|
||||||
|
namespace Core.Cerberos.External.Helpers.Token
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for token provider.
|
||||||
|
/// </summary>
|
||||||
|
public interface ITokenProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get token from headers.
|
||||||
|
/// </summary>
|
||||||
|
string GetToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
46
Core.Cerberos.Service.API.sln
Normal file
46
Core.Cerberos.Service.API.sln
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.10.34928.147
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Cerberos.Service.API", "Core.Cerberos.Service.API\Core.Cerberos.Service.API.csproj", "{00F5B578-77EE-44A9-A611-5D753FDF158D}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{F33D7786-EFE5-4618-9D47-C0272227C095}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{685F19C0-CE60-4BFB-9EDB-6834D01A6161}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Cerberos.External", "Core.Cerberos.External\Core.Cerberos.External.csproj", "{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Cerberos.Application", "Core.Cerberos.Application\Core.Cerberos.Application.csproj", "{F1980B4D-35C3-4495-84CF-09E1D3822CDA}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{00F5B578-77EE-44A9-A611-5D753FDF158D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{00F5B578-77EE-44A9-A611-5D753FDF158D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{00F5B578-77EE-44A9-A611-5D753FDF158D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{00F5B578-77EE-44A9-A611-5D753FDF158D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F1980B4D-35C3-4495-84CF-09E1D3822CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F1980B4D-35C3-4495-84CF-09E1D3822CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F1980B4D-35C3-4495-84CF-09E1D3822CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F1980B4D-35C3-4495-84CF-09E1D3822CDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{00F5B578-77EE-44A9-A611-5D753FDF158D} = {685F19C0-CE60-4BFB-9EDB-6834D01A6161}
|
||||||
|
{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137} = {F33D7786-EFE5-4618-9D47-C0272227C095}
|
||||||
|
{F1980B4D-35C3-4495-84CF-09E1D3822CDA} = {F33D7786-EFE5-4618-9D47-C0272227C095}
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {8FA6398B-A66F-49A1-AB06-EDCEA5A4715E}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Core.Cerberos.Service.API/Cerberos.Service.API.http
Normal file
6
Core.Cerberos.Service.API/Cerberos.Service.API.http
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@Core.Cerberos.Service.API_HostAddress = http://localhost:5145
|
||||||
|
|
||||||
|
GET {{Core.Cerberos.Service.API_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
200
Core.Cerberos.Service.API/Controllers/ModuleController.cs
Normal file
200
Core.Cerberos.Service.API/Controllers/ModuleController.cs
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
using Asp.Versioning;
|
||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Adapters.Attributes;
|
||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Service.API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles all services and business rules related to <see cref="ModuleController"/>.
|
||||||
|
/// </summary>
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[ApiController]
|
||||||
|
public class ModuleController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IComponentHandler<GetModuleRequest> getModuleHandler;
|
||||||
|
private readonly IComponentHandler<GetAllModulesRequest> getAllModulesHandler;
|
||||||
|
private readonly IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler;
|
||||||
|
private readonly IComponentHandler<CreateModuleRequest> createModuleHandler;
|
||||||
|
private readonly IComponentHandler<UpdateModuleRequest> updateModuleHandler;
|
||||||
|
private readonly IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler;
|
||||||
|
private readonly IModulePort port;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles all services and business rules related to <see cref="ModuleController"/>.
|
||||||
|
/// </summary>
|
||||||
|
public ModuleController(
|
||||||
|
IComponentHandler<GetModuleRequest> getModuleHandler,
|
||||||
|
IComponentHandler<GetAllModulesRequest> getAllModulesHandler,
|
||||||
|
IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler,
|
||||||
|
IComponentHandler<CreateModuleRequest> createModuleHandler,
|
||||||
|
IComponentHandler<UpdateModuleRequest> updateModuleHandler,
|
||||||
|
IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler,
|
||||||
|
IModulePort port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.createModuleHandler = createModuleHandler;
|
||||||
|
this.updateModuleHandler = updateModuleHandler;
|
||||||
|
this.changeModuleStatusHandler = changeModuleStatusHandler;
|
||||||
|
this.getAllModulesHandler = getAllModulesHandler;
|
||||||
|
this.getModuleHandler = getModuleHandler;
|
||||||
|
this.getAllModulesByListHandler = getAllModulesByListHandler;
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the modules.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("GetAll")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("ModuleManagement.Read, RoleManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetAllModulesAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await getAllModulesHandler.ExecuteAsync(new GetAllModulesRequest { }, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the modules by module identifiers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request containing the list of module identifiers.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param>
|
||||||
|
/// <returns>The <see cref="IActionResult"/> representing the result of the service call.</returns>
|
||||||
|
/// <response code="200">The modules found.</response>
|
||||||
|
/// <response code="204">No content if no modules are found.</response>
|
||||||
|
/// <response code="400">Bad request if the module identifiers are missing or invalid.</response>
|
||||||
|
/// <response code="401">Unauthorized if the user is not authenticated.</response>
|
||||||
|
/// <response code="412">Precondition failed if the request does not meet expected conditions.</response>
|
||||||
|
/// <response code="422">Unprocessable entity if the request cannot be processed.</response>
|
||||||
|
/// <response code="500">Internal server error if an unexpected error occurs.</response>
|
||||||
|
[HttpPost]
|
||||||
|
[Route(Routes.GetModuleList)]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("ModuleManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (request == null || request.Modules == null || !request.Modules.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("Module identifiers are required.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await getAllModulesByListHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the module by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("GetById")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("ModuleManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetModuleById([FromBody] GetModuleRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (request.Id == null || !request.Id.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("Invalid Module Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
await getModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new module.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("Create")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("ModuleManagement.Write")]
|
||||||
|
public async Task<IActionResult> CreateModuleAsync([FromBody] CreateModuleRequest newModule, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await createModuleHandler.ExecuteAsync(newModule, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a full module by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPut("Update")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("ModuleManagement.Write")]
|
||||||
|
public async Task<IActionResult> UpdateModuleAsync([FromBody] UpdateModuleRequest request, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await updateModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the status of the module.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPatch]
|
||||||
|
[Route("ChangeStatus")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("ModuleManagement.Write")]
|
||||||
|
public async Task<IActionResult> ChangeModuleStatusAsync([FromBody] ChangeModuleStatusRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid module identifier"); }
|
||||||
|
|
||||||
|
await changeModuleStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
200
Core.Cerberos.Service.API/Controllers/PermissionController.cs
Normal file
200
Core.Cerberos.Service.API/Controllers/PermissionController.cs
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
using Asp.Versioning;
|
||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Adapters.Attributes;
|
||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Service.API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles all services and business rules related to <see cref="PermissionController"/>.
|
||||||
|
/// </summary>
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[ApiController]
|
||||||
|
public class PermissionController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IComponentHandler<GetPermissionRequest> getPermissionHandler;
|
||||||
|
private readonly IComponentHandler<GetAllPermissionsRequest> getAllPermissionsHandler;
|
||||||
|
private readonly IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler;
|
||||||
|
private readonly IComponentHandler<CreatePermissionRequest> createPermissionHandler;
|
||||||
|
private readonly IComponentHandler<UpdatePermissionRequest> updatePermissionHandler;
|
||||||
|
private readonly IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler;
|
||||||
|
private readonly IPermissionPort port;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles all services and business rules related to <see cref="PermissionController"/>.
|
||||||
|
/// </summary>
|
||||||
|
public PermissionController(
|
||||||
|
IComponentHandler<GetPermissionRequest> getPermissionHandler,
|
||||||
|
IComponentHandler<GetAllPermissionsRequest> getAllPermissionsHandler,
|
||||||
|
IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler,
|
||||||
|
IComponentHandler<CreatePermissionRequest> createPermissionHandler,
|
||||||
|
IComponentHandler<UpdatePermissionRequest> updatePermissionHandler,
|
||||||
|
IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler,
|
||||||
|
IPermissionPort port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.createPermissionHandler = createPermissionHandler;
|
||||||
|
this.updatePermissionHandler = updatePermissionHandler;
|
||||||
|
this.changePermissionStatusHandler = changePermissionStatusHandler;
|
||||||
|
this.getAllPermissionsHandler = getAllPermissionsHandler;
|
||||||
|
this.getPermissionHandler = getPermissionHandler;
|
||||||
|
this.getAllPermissionsByListHandler = getAllPermissionsByListHandler;
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the permissions.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("GetAll")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("PermissionManagement.Read, RoleManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetAllPermissionsAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await getAllPermissionsHandler.ExecuteAsync(new GetAllPermissionsRequest { }, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the permissions by permission identifiers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request containing the list of permission identifiers.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param>
|
||||||
|
/// <returns>The <see cref="IActionResult"/> representing the result of the service call.</returns>
|
||||||
|
/// <response code="200">The permissions found.</response>
|
||||||
|
/// <response code="204">No content if no permissions are found.</response>
|
||||||
|
/// <response code="400">Bad request if the permission identifiers are missing or invalid.</response>
|
||||||
|
/// <response code="401">Unauthorized if the user is not authenticated.</response>
|
||||||
|
/// <response code="412">Precondition failed if the request does not meet expected conditions.</response>
|
||||||
|
/// <response code="422">Unprocessable entity if the request cannot be processed.</response>
|
||||||
|
/// <response code="500">Internal server error if an unexpected error occurs.</response>
|
||||||
|
[HttpPost]
|
||||||
|
[Route(Routes.GetPermissionList)]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("PermissionManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetAllPermissionsByListAsync([FromBody] GetAllPermissionsByListRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (request == null || request.Permissions == null || !request.Permissions.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("Permission identifiers are required.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await getAllPermissionsByListHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the permission by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("GetById")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("PermissionManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetPermissionById([FromBody] GetPermissionRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (request.Id == null || !request.Id.Any())
|
||||||
|
{
|
||||||
|
return BadRequest("Invalid Permission Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
await getPermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new permission.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("Create")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("PermissionManagement.Write")]
|
||||||
|
public async Task<IActionResult> CreatePermissionAsync([FromBody] CreatePermissionRequest newPermission, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await createPermissionHandler.ExecuteAsync(newPermission, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a full permission by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPut("Update")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("PermissionManagement.Write")]
|
||||||
|
public async Task<IActionResult> UpdatePermissionAsync([FromBody] UpdatePermissionRequest request, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await updatePermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the status of the permission.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPatch]
|
||||||
|
[Route("ChangeStatus")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("PermissionManagement.Write")]
|
||||||
|
public async Task<IActionResult> ChangePermissionStatusAsync([FromBody] ChangePermissionStatusRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid permission identifier"); }
|
||||||
|
|
||||||
|
await changePermissionStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
208
Core.Cerberos.Service.API/Controllers/RoleController.cs
Normal file
208
Core.Cerberos.Service.API/Controllers/RoleController.cs
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
using Asp.Versioning;
|
||||||
|
using Core.Cerberos.Adapters.Attributes;
|
||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Service.API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles all requests for role authentication.
|
||||||
|
/// </summary>
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
public class RoleController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IComponentHandler<GetRoleRequest> getRoleHandler;
|
||||||
|
private readonly IComponentHandler<GetAllRolesRequest> getAllRolesHandler;
|
||||||
|
private readonly IComponentHandler<CreateRoleRequest> createRoleHandler;
|
||||||
|
private readonly IComponentHandler<UpdateRoleRequest> updateRoleHandler;
|
||||||
|
private readonly IComponentHandler<ChangeRoleStatusRequest> changeStatusRoleHandler;
|
||||||
|
private readonly IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler;
|
||||||
|
private readonly IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler;
|
||||||
|
private readonly IRolePort port;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles all requests for role authentication.
|
||||||
|
/// </summary>
|
||||||
|
public RoleController(
|
||||||
|
IComponentHandler<GetRoleRequest> getRoleHandler,
|
||||||
|
IComponentHandler<GetAllRolesRequest> getAllRolesHandler,
|
||||||
|
IComponentHandler<CreateRoleRequest> createRoleHandler,
|
||||||
|
IComponentHandler<UpdateRoleRequest> updateRoleHandler,
|
||||||
|
IComponentHandler<ChangeRoleStatusRequest> changeRoleStatusHandler,
|
||||||
|
IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler,
|
||||||
|
IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler,
|
||||||
|
IRolePort port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.createRoleHandler = createRoleHandler;
|
||||||
|
this.updateRoleHandler = updateRoleHandler;
|
||||||
|
this.changeStatusRoleHandler = changeRoleStatusHandler;
|
||||||
|
this.getAllRolesHandler = getAllRolesHandler;
|
||||||
|
this.getRoleHandler = getRoleHandler;
|
||||||
|
this.addApplicationToRoleHandler = addApplicationToRoleHandler;
|
||||||
|
this.removeApplicationToRoleHandler = removeApplicationToRoleHandler;
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the roles.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("GetAll")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("RoleManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetAllRolesAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await getAllRolesHandler.ExecuteAsync(new GetAllRolesRequest { }, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the role by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("GetById")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("RoleManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetRoleById([FromBody] GetRoleRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
|
||||||
|
|
||||||
|
await getRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new role.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("Create")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("RoleManagement.Write")]
|
||||||
|
public async Task<IActionResult> CreateRoleAsync([FromBody] CreateRoleRequest newRole, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await createRoleHandler.ExecuteAsync(newRole, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a full role by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPut("Update")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("RoleManagement.Write")]
|
||||||
|
public async Task<IActionResult> UpdateRoleAsync([FromBody] UpdateRoleRequest entity, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await updateRoleHandler.ExecuteAsync(entity, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the status of the role.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPatch]
|
||||||
|
[Route("ChangeStatus")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("RoleManagement.Write")]
|
||||||
|
public async Task<IActionResult> ChageRoleStatusAsync(ChangeRoleStatusRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
|
||||||
|
|
||||||
|
await changeStatusRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an application to the role's list of applications.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("AddApplication")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("RoleManagement.Write")]
|
||||||
|
public async Task<IActionResult> AddApplicationToRoleAsync(AddApplicationToRoleRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
|
||||||
|
|
||||||
|
await addApplicationToRoleHandler.ExecuteAsync(request, cancellationToken);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes an application from the role's list of applications.
|
||||||
|
/// </summary>
|
||||||
|
[HttpDelete]
|
||||||
|
[Route("RemoveApplication")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("RoleManagement.Write")]
|
||||||
|
public async Task<IActionResult> RemoveApplicationToRoleAsync(RemoveApplicationFromRoleRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
|
||||||
|
|
||||||
|
await removeApplicationToRoleHandler.ExecuteAsync(request, cancellationToken);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
432
Core.Cerberos.Service.API/Controllers/UserController.cs
Normal file
432
Core.Cerberos.Service.API/Controllers/UserController.cs
Normal file
@ -0,0 +1,432 @@
|
|||||||
|
using Asp.Versioning;
|
||||||
|
using Core.Cerberos.Adapters;
|
||||||
|
using Core.Cerberos.Adapters.Attributes;
|
||||||
|
using Core.Cerberos.Adapters.Common.Constants;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Service.API.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles all requests for user.
|
||||||
|
/// </summary>
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[ApiController]
|
||||||
|
public class UserController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IComponentHandler<GetUserRequest> getUserHandler;
|
||||||
|
private readonly IComponentHandler<GetUserByEmailRequest> getUserByEmailHandler;
|
||||||
|
private readonly IComponentHandler<GetAllUsersRequest> getAllUsersHandler;
|
||||||
|
private readonly IComponentHandler<CreateUserRequest> createUserHandler;
|
||||||
|
private readonly IComponentHandler<UpdateUserRequest> updateUserHandler;
|
||||||
|
private readonly IComponentHandler<ChangeUserStatusRequest> ChangeUserStatusHandler;
|
||||||
|
private readonly IComponentHandler<AddCompanyToUserRequest> addCompanyToUserHandler;
|
||||||
|
private readonly IComponentHandler<RemoveCompanyFromUserRequest> removeCompanyFromUserHandler;
|
||||||
|
private readonly IComponentHandler<AddProjectToUserRequest> addProjectToUserHandler;
|
||||||
|
private readonly IComponentHandler<RemoveProjectFromUserRequest> removeProjectFromUserHandler;
|
||||||
|
private readonly IComponentHandler<LoginUserRequest> loginUserHandler;
|
||||||
|
private readonly IComponentHandler<LogoutUserRequest> logoutUserHandler;
|
||||||
|
private readonly IComponentHandler<ValidateUserExistenceRequest> validateUserHandler;
|
||||||
|
private readonly IComponentHandler<GetTokenAdapterRequest> getTokenAdapterHandler;
|
||||||
|
private readonly IComponentHandler<GetConsentFormPDFRequest> getConsentFormPDFHandler;
|
||||||
|
private readonly IComponentHandler<AcceptUserConsentFormRequest> acceptUserConsentFormHandler;
|
||||||
|
private readonly IUserPort port;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of UserController.
|
||||||
|
/// </summary>
|
||||||
|
public UserController(
|
||||||
|
IComponentHandler<GetUserRequest> getUserHandler,
|
||||||
|
IComponentHandler<GetUserByEmailRequest> getUserByEmailHandler,
|
||||||
|
IComponentHandler<GetAllUsersRequest> getAllUsersHandler,
|
||||||
|
IComponentHandler<CreateUserRequest> createUserHandler,
|
||||||
|
IComponentHandler<UpdateUserRequest> updateUserHandler,
|
||||||
|
IComponentHandler<ChangeUserStatusRequest> changeUserStatusHandler,
|
||||||
|
IComponentHandler<AddCompanyToUserRequest> addCompanyToUserHandler,
|
||||||
|
IComponentHandler<RemoveCompanyFromUserRequest> removeCompanyFromUserHandler,
|
||||||
|
IComponentHandler<AddProjectToUserRequest> addProjectToUserHandler,
|
||||||
|
IComponentHandler<RemoveProjectFromUserRequest> removeProjectFromUserHandler,
|
||||||
|
IComponentHandler<LoginUserRequest> loginUserHandler,
|
||||||
|
IComponentHandler<LogoutUserRequest> logoutUserHandler,
|
||||||
|
IComponentHandler<ValidateUserExistenceRequest> validateUserHandler,
|
||||||
|
IComponentHandler<GetTokenAdapterRequest> getTokenAdapterHandler,
|
||||||
|
IComponentHandler<GetConsentFormPDFRequest> getConsentFormPDFHandler,
|
||||||
|
IComponentHandler<AcceptUserConsentFormRequest> acceptUserConsentFormHandler,
|
||||||
|
IUserPort port
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.createUserHandler = createUserHandler;
|
||||||
|
this.updateUserHandler = updateUserHandler;
|
||||||
|
this.ChangeUserStatusHandler = changeUserStatusHandler;
|
||||||
|
this.getAllUsersHandler = getAllUsersHandler;
|
||||||
|
this.getUserHandler = getUserHandler;
|
||||||
|
this.getUserByEmailHandler = getUserByEmailHandler;
|
||||||
|
this.addCompanyToUserHandler = addCompanyToUserHandler;
|
||||||
|
this.removeCompanyFromUserHandler = removeCompanyFromUserHandler;
|
||||||
|
this.addProjectToUserHandler = addProjectToUserHandler;
|
||||||
|
this.removeProjectFromUserHandler = removeProjectFromUserHandler;
|
||||||
|
this.loginUserHandler = loginUserHandler;
|
||||||
|
this.logoutUserHandler = logoutUserHandler;
|
||||||
|
this.validateUserHandler = validateUserHandler;
|
||||||
|
this.getTokenAdapterHandler = getTokenAdapterHandler;
|
||||||
|
this.getConsentFormPDFHandler = getConsentFormPDFHandler;
|
||||||
|
this.acceptUserConsentFormHandler = acceptUserConsentFormHandler;
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all the users.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetAll")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetAllUsersAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await getAllUsersHandler.ExecuteAsync(new GetAllUsersRequest { }, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the user by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("GetById")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetUserById([FromBody] GetUserRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); }
|
||||||
|
|
||||||
|
await getUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the user by email.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("GetByEmail")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||||
|
public async Task<IActionResult> GetUserByEmail([FromBody] GetUserByEmailRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||||
|
|
||||||
|
await getUserByEmailHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new user.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("Create")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Write")]
|
||||||
|
public async Task<IActionResult> CreateUserAsync([FromBody] CreateUserRequest newUser, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await createUserHandler.ExecuteAsync(newUser, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a full user by identifier.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPut("Update")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Write")]
|
||||||
|
public async Task<IActionResult> UpdateUserAsync([FromBody] UpdateUserRequest request,
|
||||||
|
CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
await updateUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs in the user.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPatch("LoginUser")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||||
|
public async Task<IActionResult> LoginUserAsync([FromBody] LoginUserRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||||
|
|
||||||
|
await loginUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs in the user.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPatch("LogOutUser")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<IActionResult> LogOutUserSessionAsync([FromBody] LogoutUserRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||||
|
|
||||||
|
await logoutUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the status of the user.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPatch]
|
||||||
|
[Route("ChangeStatus")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Write")]
|
||||||
|
public async Task<IActionResult> ChangeUserStatusAsync([FromBody] ChangeUserStatusRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); }
|
||||||
|
|
||||||
|
await ChangeUserStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a company to the user's list of companies.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("AddCompany")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Write")]
|
||||||
|
public async Task<IActionResult> AddCompanyToUserAsync([FromBody] AddCompanyToUserRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||||
|
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
|
||||||
|
|
||||||
|
await addCompanyToUserHandler.ExecuteAsync(request, cancellationToken);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a company from the user's list of companies.
|
||||||
|
/// </summary>
|
||||||
|
[HttpDelete]
|
||||||
|
[Route("RemoveCompany")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Write")]
|
||||||
|
public async Task<IActionResult> RemoveCompanyFromUserAsync([FromBody] RemoveCompanyFromUserRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||||
|
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
|
||||||
|
|
||||||
|
await removeCompanyFromUserHandler.ExecuteAsync(request, cancellationToken);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a project to the user's list of projects.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("AddProject")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Write")]
|
||||||
|
public async Task<IActionResult> AddProjectToUserAsync([FromBody] AddProjectToUserRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||||
|
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
|
||||||
|
|
||||||
|
await addProjectToUserHandler.ExecuteAsync(request, cancellationToken);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a project from the user's list of projects.
|
||||||
|
/// </summary>
|
||||||
|
[HttpDelete]
|
||||||
|
[Route("RemoveProject")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Write")]
|
||||||
|
public async Task<IActionResult> RemoveProjectFromUserAsync([FromBody] RemoveProjectFromUserRequest request,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||||
|
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
|
||||||
|
|
||||||
|
await removeProjectFromUserHandler.ExecuteAsync(request, cancellationToken);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates if a user exists on the database.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("ValidateExistence")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<IActionResult> ValidateUserExistenceAsync([FromBody] ValidateUserExistenceRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||||
|
|
||||||
|
await validateUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a token for the user, including roles, permissions, and modules.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("GetTokenAdapter")]
|
||||||
|
[ProducesResponseType(typeof(TokenAdapter), StatusCodes.Status200OK)]
|
||||||
|
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||||
|
public async Task<IActionResult> GetTokenAdapter([FromBody] GetTokenAdapterRequest request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||||
|
|
||||||
|
await getTokenAdapterHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Consent Form PDF.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetConsentFormPDF")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||||
|
[Permission("UserManagement.Read")]
|
||||||
|
public async Task<IActionResult> GetConsentFormPDFAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await getConsentFormPDFHandler.ExecuteAsync(new GetConsentFormPDFRequest { }, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Accept user consent form.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPatch("AcceptUserConsentForm")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||||
|
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||||
|
public async Task<IActionResult> AcceptUserConsentFormAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await acceptUserConsentFormHandler.ExecuteAsync(new AcceptUserConsentFormRequest { }, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return port.ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
Core.Cerberos.Service.API/Core.Cerberos.Service.API.csproj
Normal file
27
Core.Cerberos.Service.API/Core.Cerberos.Service.API.csproj
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Core.Cerberos.Application\Core.Cerberos.Application.csproj" />
|
||||||
|
<ProjectReference Include="..\Core.Cerberos.External\Core.Cerberos.External.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="appsettings.Local.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
99
Core.Cerberos.Service.API/Extensions/SwaggerExtensions.cs
Normal file
99
Core.Cerberos.Service.API/Extensions/SwaggerExtensions.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using Asp.Versioning.ApiExplorer;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
|
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||||
|
|
||||||
|
namespace Core.Cerberos.Service.API.Extensions
|
||||||
|
{
|
||||||
|
public static class SwaggerExtensions
|
||||||
|
{
|
||||||
|
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddEndpointsApiExplorer();
|
||||||
|
AddSwaggerGen(services, configuration);
|
||||||
|
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures Swagger generation with OAuth2 security and XML comments.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
|
||||||
|
/// <param name="configuration">The <see cref="IConfiguration"/> containing Swagger and OAuth2 configuration settings.</param>
|
||||||
|
public static void AddSwaggerGen(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddSwaggerGen(c =>
|
||||||
|
{
|
||||||
|
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Description = "JWT Authorization header using the Bearer scheme",
|
||||||
|
Name = "Authorization",
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Type = SecuritySchemeType.Http,
|
||||||
|
Scheme = "bearer",
|
||||||
|
BearerFormat = "JWT"
|
||||||
|
});
|
||||||
|
|
||||||
|
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||||
|
{
|
||||||
|
{
|
||||||
|
new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Reference = new OpenApiReference
|
||||||
|
{
|
||||||
|
Type = ReferenceType.SecurityScheme,
|
||||||
|
Id = "Bearer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Array.Empty<string>()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public static void ConfigureSwagger(this WebApplication app)
|
||||||
|
{
|
||||||
|
//Swagger Stuff Goes Here
|
||||||
|
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(options =>
|
||||||
|
{
|
||||||
|
foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName))
|
||||||
|
options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version);
|
||||||
|
|
||||||
|
options.DisplayRequestDuration();
|
||||||
|
options.EnableTryItOutByDefault();
|
||||||
|
options.DocExpansion(DocExpansion.None);
|
||||||
|
});
|
||||||
|
|
||||||
|
// app.MapGet("/", () => Results.Redirect("/swagger/index.html")).WithTags(string.Empty);
|
||||||
|
}
|
||||||
|
public static IServiceCollection AddVersioning(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddApiVersioning(options => options.ReportApiVersions = true)
|
||||||
|
.AddApiExplorer(options =>
|
||||||
|
{
|
||||||
|
options.GroupNameFormat = "'v'VVV";
|
||||||
|
options.SubstituteApiVersionInUrl = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) : IConfigureOptions<SwaggerGenOptions>
|
||||||
|
{
|
||||||
|
private readonly IApiVersionDescriptionProvider _provider = provider;
|
||||||
|
|
||||||
|
public void Configure(SwaggerGenOptions options)
|
||||||
|
{
|
||||||
|
foreach (var description in _provider.ApiVersionDescriptions)
|
||||||
|
options.SwaggerDoc(description.GroupName, new()
|
||||||
|
{
|
||||||
|
Title = AppDomain.CurrentDomain.FriendlyName,
|
||||||
|
Version = description.ApiVersion.ToString()
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
options.CustomSchemaIds(type => type.ToString().Replace("+", "."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
170
Core.Cerberos.Service.API/Program.cs
Normal file
170
Core.Cerberos.Service.API/Program.cs
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
using Core.Cerberos.Adapters.Extensions;
|
||||||
|
using Core.Cerberos.Adapters.Helpers;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Adapter;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||||
|
using Core.Cerberos.Application.UseCases.Modules.Validator;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Adapter;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||||
|
using Core.Cerberos.Application.UseCases.Permissions.Validator;
|
||||||
|
using Core.Cerberos.Application.UseCases.Role;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Adapter;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||||
|
using Core.Cerberos.Application.UseCases.Roles.Validator;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Adapter;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||||
|
using Core.Cerberos.Application.UseCases.Users.Validator;
|
||||||
|
using Core.Cerberos.External.ClientConfiguration;
|
||||||
|
using Core.Cerberos.Service.API.Extensions;
|
||||||
|
using FluentValidation;
|
||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
using Microsoft.AspNetCore.ResponseCompression;
|
||||||
|
using System.IO.Compression;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
var authSettings = AuthHelper.GetAuthSettings(builder, "cerberos_service");
|
||||||
|
|
||||||
|
builder.Services.ConfigureAuthentication(builder.Configuration, authSettings);
|
||||||
|
|
||||||
|
builder.Host.ConfigureServices((context, services) =>
|
||||||
|
{
|
||||||
|
services.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("AllowAll", policyBuilder =>
|
||||||
|
policyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
|
||||||
|
});
|
||||||
|
services.AddMvc().AddJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.JsonSerializerOptions.WriteIndented = true;
|
||||||
|
options.JsonSerializerOptions.MaxDepth = 20;
|
||||||
|
options.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
||||||
|
});
|
||||||
|
services.Configure<BrotliCompressionProviderOptions>(options =>
|
||||||
|
{
|
||||||
|
options.Level = CompressionLevel.SmallestSize;
|
||||||
|
});
|
||||||
|
services.Configure<GzipCompressionProviderOptions>(options =>
|
||||||
|
{
|
||||||
|
options.Level = CompressionLevel.SmallestSize;
|
||||||
|
});
|
||||||
|
services.AddResponseCompression(options =>
|
||||||
|
{
|
||||||
|
options.EnableForHttps = true;
|
||||||
|
options.Providers.Add<BrotliCompressionProvider>();
|
||||||
|
options.Providers.Add<GzipCompressionProvider>();
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddResponseCaching();
|
||||||
|
services.AddControllers();
|
||||||
|
services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwagger(builder.Configuration, "Core.Cerberos.Service.API.xml", authSettings);
|
||||||
|
builder.Services.AddVersioning(builder.Configuration);
|
||||||
|
services.AddLogging();
|
||||||
|
services.AddProblemDetails();
|
||||||
|
|
||||||
|
//Register Stuff
|
||||||
|
services.RegisterExternalLayer(builder.Configuration);
|
||||||
|
|
||||||
|
services.AddScoped<IUserPort, UserPort>();
|
||||||
|
services.AddScoped<IComponentHandler<GetAllUsersRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetUserRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<LoginUserRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<LogoutUserRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetUserByEmailRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<AddCompanyToUserRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<RemoveCompanyFromUserRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<AddProjectToUserRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<RemoveProjectFromUserRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<ValidateUserExistenceRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetTokenAdapterRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetConsentFormPDFRequest>, UserHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<AcceptUserConsentFormRequest>, UserHandler>();
|
||||||
|
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<CreateUserValidator>();
|
||||||
|
services.AddScoped<IValidator<CreateUserRequest>, CreateUserValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<CreateUserRequest>, UserHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<UpdateUserValidator>();
|
||||||
|
services.AddScoped<IValidator<UpdateUserRequest>, UpdateUserValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<UpdateUserRequest>, UserHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<ChangeUserStatusValidator>();
|
||||||
|
services.AddScoped<IValidator<ChangeUserStatusRequest>, ChangeUserStatusValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<ChangeUserStatusRequest>, UserHandler>();
|
||||||
|
|
||||||
|
services.AddScoped<IRolePort, RolePort>();
|
||||||
|
services.AddScoped<IComponentHandler<GetAllRolesRequest>, RoleHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetRoleRequest>, RoleHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<AddApplicationToRoleRequest>, RoleHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<RemoveApplicationFromRoleRequest>, RoleHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<CreateRoleValidator>();
|
||||||
|
services.AddScoped<IValidator<CreateRoleRequest>, CreateRoleValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<CreateRoleRequest>, RoleHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<UpdateRoleValidator>();
|
||||||
|
services.AddScoped<IValidator<UpdateRoleRequest>, UpdateRoleValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<UpdateRoleRequest>, RoleHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<ChangeRoleStatusValidator>();
|
||||||
|
services.AddScoped<IValidator<ChangeRoleStatusRequest>, ChangeRoleStatusValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<ChangeRoleStatusRequest>, RoleHandler>();
|
||||||
|
|
||||||
|
services.AddScoped<IPermissionPort, PermissionPort>();
|
||||||
|
services.AddScoped<IComponentHandler<GetAllPermissionsRequest>, PermissionHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetPermissionRequest>, PermissionHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetAllPermissionsByListRequest>, PermissionHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<CreatePermissionValidator>();
|
||||||
|
services.AddScoped<IValidator<CreatePermissionRequest>, CreatePermissionValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<CreatePermissionRequest>, PermissionHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<UpdatePermissionValidator>();
|
||||||
|
services.AddScoped<IValidator<UpdatePermissionRequest>, UpdatePermissionValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<UpdatePermissionRequest>, PermissionHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<ChangePermissionStatusValidator>();
|
||||||
|
services.AddScoped<IValidator<ChangePermissionStatusRequest>, ChangePermissionStatusValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<ChangePermissionStatusRequest>, PermissionHandler>();
|
||||||
|
|
||||||
|
services.AddScoped<IModulePort, ModulePort>();
|
||||||
|
services.AddScoped<IComponentHandler<GetAllModulesRequest>, ModuleHandler>();
|
||||||
|
services.AddScoped<IComponentHandler<GetModuleRequest>, ModuleHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<GetAllModulesByListValidator>();
|
||||||
|
services.AddScoped<IValidator<GetAllModulesByListRequest>, GetAllModulesByListValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<GetAllModulesByListRequest>, ModuleHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<CreateModuleValidator>();
|
||||||
|
services.AddScoped<IValidator<CreateModuleRequest>, CreateModuleValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<CreateModuleRequest>, ModuleHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<UpdateModuleValidator>();
|
||||||
|
services.AddScoped<IValidator<UpdateModuleRequest>, UpdateModuleValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<UpdateModuleRequest>, ModuleHandler>();
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssemblyContaining<ChangeModuleStatusValidator>();
|
||||||
|
services.AddScoped<IValidator<ChangeModuleStatusRequest>, ChangeModuleStatusValidator>();
|
||||||
|
services.AddScoped<IComponentHandler<ChangeModuleStatusRequest>, ModuleHandler>();
|
||||||
|
});
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
app.UseSwaggerUI(builder.Configuration, authSettings);
|
||||||
|
app.ConfigureSwagger(builder.Configuration);
|
||||||
|
app.UseResponseCompression();
|
||||||
|
app.UseResponseCaching();
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseCors("AllowAll");
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
41
Core.Cerberos.Service.API/Properties/launchSettings.json
Normal file
41
Core.Cerberos.Service.API/Properties/launchSettings.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:56379",
|
||||||
|
"sslPort": 44312
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5145",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Local"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7253;http://localhost:5145",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Local"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Local"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Core.Cerberos.Service.API/appsettings.Development.json
Normal file
9
Core.Cerberos.Service.API/appsettings.Development.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
12
Core.Cerberos.Service.API/appsettings.Local.json
Normal file
12
Core.Cerberos.Service.API/appsettings.Local.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"LocalGateways": {
|
||||||
|
"CerberosDAL": "https://localhost:7031/api"
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Core.Cerberos.Service.API/appsettings.json
Normal file
12
Core.Cerberos.Service.API/appsettings.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"Endpoints": {
|
||||||
|
"AppConfigurationURI": "https://sandbox-hci-usc-appcg.azconfig.io"
|
||||||
|
}
|
||||||
|
}
|
||||||
30
Core.Cerberos.Service.API/sample.settings.Development.json
Normal file
30
Core.Cerberos.Service.API/sample.settings.Development.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"Gateways": {
|
||||||
|
"CerberosDAL": "" // Data access layer endpoint
|
||||||
|
},
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"KeyVault": "" //KeyVault Uri
|
||||||
|
},
|
||||||
|
"JwtIssuerOptions": {
|
||||||
|
"Audience": "", // Audience for token creation, specifies intended recipients
|
||||||
|
"Issuer": "" // Issuer for token creation, identifies the issuer of the token
|
||||||
|
},
|
||||||
|
"AzureAdB2C": {
|
||||||
|
"Instance": "", // Azure AD instance URL (STORED IN KEY VAULT)
|
||||||
|
"TenantId": "", // Azure AD tenant ID (STORED IN KEY VAULT)
|
||||||
|
"ClientId": "", // Azure AD application client ID (STORED IN KEY VAULT)
|
||||||
|
"ClientSecret": "", // Azure AD application client secret (STORED IN KEY VAULT)
|
||||||
|
"CallbackPath": "", // Path for redirect after authentication
|
||||||
|
"Scopes": "" // Access scopes for user permissions
|
||||||
|
},
|
||||||
|
"HeathCerberosApp": {
|
||||||
|
"AuthorizationUrl": "", // URL for authorization endpoint (STORED IN KEY VAULT)
|
||||||
|
"TokenUrl": "", // URL for token endpoint (STORED IN KEY VAULT)
|
||||||
|
"Scope": "", // Scope for application permissions (STORED IN KEY VAULT)
|
||||||
|
"ClientId": "" // Client ID for Cerberos application (STORED IN KEY VAULT)
|
||||||
|
},
|
||||||
|
"MicrosoftGraph": {
|
||||||
|
"Scopes": "", // Scopes for Microsoft Graph API access
|
||||||
|
"BaseUrl": "" // Base URL for Microsoft Graph API
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user