Compare commits
6 Commits
main
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55cee7b0d3 | ||
|
|
dcf801beff | ||
|
|
82ebe4408b | ||
|
|
46ebccf797 | ||
|
|
614cc00290 | ||
|
|
f6595ed1df |
@@ -1,20 +0,0 @@
|
||||
<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>
|
||||
@@ -1,6 +0,0 @@
|
||||
@Core.Cerberos.Service.API_HostAddress = http://localhost:5145
|
||||
|
||||
GET {{Core.Cerberos.Service.API_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -1,170 +0,0 @@
|
||||
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();
|
||||
|
||||
21
Core.Thalos.Application/Core.Thalos.Application.csproj
Normal file
21
Core.Thalos.Application/Core.Thalos.Application.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core.Thalos.External\Core.Thalos.External.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="UseCases\Users\Ports\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,9 +1,9 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Modules.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Adapter
|
||||
{
|
||||
public class ModulePort : BasePresenter, IModulePort
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class ChangeModuleStatusRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class CreateModuleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class GetAllModulesByListRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class GetAllModulesRequest : ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class GetModuleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class UpdateModuleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -12,7 +12,6 @@ namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
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;
|
||||
@@ -1,13 +1,13 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules
|
||||
namespace Core.Thalos.Application.UseCases.Modules
|
||||
{
|
||||
public class ModuleHandler :
|
||||
IComponentHandler<ChangeModuleStatusRequest>,
|
||||
@@ -22,7 +22,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
private readonly IValidator<CreateModuleRequest> _registerModuleValidator;
|
||||
private readonly IValidator<UpdateModuleRequest> _updateModuleValidator;
|
||||
private readonly IValidator<GetAllModulesByListRequest> _modulesByListValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public ModuleHandler(
|
||||
IModulePort port,
|
||||
@@ -30,13 +30,13 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
IValidator<CreateModuleRequest> registerModuleValidator,
|
||||
IValidator<UpdateModuleRequest> updateModuleValidator,
|
||||
IValidator<GetAllModulesByListRequest> modulesByListValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_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));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
_modulesByListValidator = modulesByListValidator ?? throw new ArgumentNullException(nameof(modulesByListValidator));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetModuleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetModuleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllModulesAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllModulesAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -94,7 +94,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
return;
|
||||
}
|
||||
|
||||
var _result = await _cerberosDALService.GetAllModulesByListAsync(command.Modules, cancellationToken).ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllModulesByListAsync(command.Modules, cancellationToken).ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -120,7 +120,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeStatusModuleAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeStatusModuleAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
Application = command.Application,
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreateModuleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreateModuleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -194,13 +194,12 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
Application = command.Application,
|
||||
Route = command.Route,
|
||||
Order = command.Order,
|
||||
Icon = command.Icon,
|
||||
Status = command.Status
|
||||
Icon = command.Icon
|
||||
};
|
||||
|
||||
string id = command.Id;
|
||||
|
||||
var result = await _cerberosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -1,13 +1,14 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.Adapters;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Ports
|
||||
{
|
||||
public interface IModulePort : IBasePort,
|
||||
ICommandSuccessPort<ModuleAdapter>,
|
||||
ICommandSuccessPort<List<ModuleAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class ChangeModuleStatusValidator : AbstractValidator<ChangeModuleStatusRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class CreateModuleValidator : AbstractValidator<CreateModuleRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class GetAllModulesByListValidator : AbstractValidator<GetAllModulesByListRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class UpdateModuleValidator : AbstractValidator<UpdateModuleRequest>
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Adapter
|
||||
{
|
||||
public class PermissionPort : BasePresenter, IPermissionPort
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class ChangePermissionStatusRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class CreatePermissionRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class GetAllPermissionsByListRequest : ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class GetAllPermissionsRequest : ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class GetPermissionRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,8 +1,8 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class UpdatePermissionRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
namespace Core.Thalos.Application.UseCases.Permissions
|
||||
{
|
||||
public class PermissionHandler :
|
||||
IComponentHandler<ChangePermissionStatusRequest>,
|
||||
@@ -21,20 +21,20 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
private readonly IValidator<ChangePermissionStatusRequest> _changePermissionStatusValidator;
|
||||
private readonly IValidator<CreatePermissionRequest> _registerPermissionValidator;
|
||||
private readonly IValidator<UpdatePermissionRequest> _updatePermissionValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public PermissionHandler(
|
||||
IPermissionPort port,
|
||||
IValidator<ChangePermissionStatusRequest> changePermissionStatusValidator,
|
||||
IValidator<CreatePermissionRequest> registerPermissionValidator,
|
||||
IValidator<UpdatePermissionRequest> updatePermissionValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_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));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetPermissionRequest command, CancellationToken cancellationToken = default)
|
||||
@@ -43,7 +43,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetPermissionByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetPermissionByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -65,7 +65,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllPermissionsAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllPermissionsAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -85,7 +85,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllPermissionsByListAsync(command.Permissions, cancellationToken).ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllPermissionsByListAsync(command.Permissions, cancellationToken).ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -111,7 +111,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeStatusPermissionAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeStatusPermissionAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
AccessLevel = command.AccessLevel
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreatePermissionAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreatePermissionAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -179,13 +179,12 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
Id = command.Id,
|
||||
Name = command.Name,
|
||||
Description = command.Description,
|
||||
AccessLevel = command.AccessLevel,
|
||||
Status = command.Status
|
||||
AccessLevel = command.AccessLevel
|
||||
};
|
||||
|
||||
string id = command.Id;
|
||||
|
||||
var result = await _cerberosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -1,13 +1,14 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.Adapters;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Ports
|
||||
{
|
||||
public interface IPermissionPort : IBasePort,
|
||||
ICommandSuccessPort<PermissionAdapter>,
|
||||
ICommandSuccessPort<List<PermissionAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Validator
|
||||
{
|
||||
public class ChangePermissionStatusValidator : AbstractValidator<ChangePermissionStatusRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Validator
|
||||
{
|
||||
public class CreatePermissionValidator : AbstractValidator<CreatePermissionRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Validator
|
||||
{
|
||||
public class UpdatePermissionValidator : AbstractValidator<UpdatePermissionRequest>
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Roles.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Adapter
|
||||
{
|
||||
public class RolePort : BasePresenter, IRolePort
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class AddApplicationToRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class ChangeRoleStatusRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,8 +1,8 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class CreateRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class GetAllRolesRequest : ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class GetRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class RemoveApplicationFromRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,8 +1,8 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class UpdateRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,12 +1,13 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.Adapters;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Ports
|
||||
{
|
||||
public interface IRolePort : IBasePort,
|
||||
ICommandSuccessPort<RoleAdapter>, ICommandSuccessPort<List<RoleAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Role
|
||||
namespace Core.Thalos.Application.UseCases.Role
|
||||
{
|
||||
public class RoleHandler :
|
||||
IComponentHandler<ChangeRoleStatusRequest>,
|
||||
@@ -23,20 +23,20 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
private readonly IValidator<ChangeRoleStatusRequest> _changeRoleStatusValidator;
|
||||
private readonly IValidator<CreateRoleRequest> _registerRoleValidator;
|
||||
private readonly IValidator<UpdateRoleRequest> _updateRoleValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public RoleHandler(
|
||||
IRolePort port,
|
||||
IValidator<ChangeRoleStatusRequest> changeRoleStatusValidator,
|
||||
IValidator<CreateRoleRequest> registerRoleValidator,
|
||||
IValidator<UpdateRoleRequest> updateRoleValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_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));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetRoleRequest command, CancellationToken cancellationToken = default)
|
||||
@@ -45,7 +45,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetRoleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetRoleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllRolesAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllRolesAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -93,7 +93,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeRoleStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeRoleStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreateRoleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreateRoleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -166,13 +166,12 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
Description = command.Description,
|
||||
Applications = command.Applications,
|
||||
Modules = command.Modules,
|
||||
Permissions = command.Permissions,
|
||||
Status = command.Status
|
||||
Permissions = command.Permissions
|
||||
};
|
||||
|
||||
string id = command.Id;
|
||||
|
||||
var result = await _cerberosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -194,7 +193,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.AddApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.AddApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -216,7 +215,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.RemoveApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.RemoveApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Validator
|
||||
{
|
||||
public class ChangeRoleStatusValidator : AbstractValidator<ChangeRoleStatusRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Validator
|
||||
{
|
||||
public class CreateRoleValidator : AbstractValidator<CreateRoleRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Validator
|
||||
{
|
||||
public class UpdateRoleValidator : AbstractValidator<UpdateRoleRequest>
|
||||
{
|
||||
@@ -1,10 +1,10 @@
|
||||
using Core.Blueprint.Storage.Adapters;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Users.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Users.Adapter
|
||||
{
|
||||
public class UserPort : BasePresenter, IUserPort
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AcceptUserConsentFormRequest : ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AddCompanyToUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AddProjectToUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class ChangeUserStatusRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class CreateUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetAllUsersRequest : ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetConsentFormPDFRequest : ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetTokenAdapterRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetUserByEmailRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class LoginUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class LogoutUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class RemoveCompanyFromUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class RemoveProjectFromUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class UpdateUserRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class ValidateUserExistenceRequest : Notificator, ICommand
|
||||
{
|
||||
@@ -1,8 +1,8 @@
|
||||
using Core.Blueprint.Storage.Adapters;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.Adapters;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Users.Ports
|
||||
{
|
||||
public interface IUserPort : IBasePort,
|
||||
ICommandSuccessPort<UserAdapter>,
|
||||
@@ -11,7 +11,8 @@ namespace Core.Cerberos.Application.UseCases.Users.Ports
|
||||
ICommandSuccessPort<TokenAdapter>,
|
||||
ICommandSuccessPort<BlobDownloadUriAdapter>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
namespace Core.Cerberos.Application.UseCases.Users
|
||||
namespace Core.Thalos.Application.UseCases.Users
|
||||
{
|
||||
public class UserHandler :
|
||||
IComponentHandler<ChangeUserStatusRequest>,
|
||||
@@ -22,28 +22,26 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
IComponentHandler<LoginUserRequest>,
|
||||
IComponentHandler<LogoutUserRequest>,
|
||||
IComponentHandler<ValidateUserExistenceRequest>,
|
||||
IComponentHandler<GetTokenAdapterRequest>,
|
||||
IComponentHandler<GetConsentFormPDFRequest>,
|
||||
IComponentHandler<AcceptUserConsentFormRequest>
|
||||
IComponentHandler<GetTokenAdapterRequest>
|
||||
{
|
||||
private readonly IUserPort _port;
|
||||
private readonly IValidator<ChangeUserStatusRequest> _changeUserStatusValidator;
|
||||
private readonly IValidator<CreateUserRequest> _registerUserValidator;
|
||||
private readonly IValidator<UpdateUserRequest> _updateUserValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public UserHandler(
|
||||
IUserPort port,
|
||||
IValidator<ChangeUserStatusRequest> changeUserStatusValidator,
|
||||
IValidator<CreateUserRequest> registerUserValidator,
|
||||
IValidator<UpdateUserRequest> updateUserValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_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));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetUserRequest command, CancellationToken cancellationToken = default)
|
||||
@@ -52,7 +50,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetUserByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetUserByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -74,7 +72,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetUserByEmailAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetUserByEmailAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -96,7 +94,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.ValidateUserExistence(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ValidateUserExistence(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -118,7 +116,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllUsersAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllUsersAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -144,7 +142,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeUserStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeUserStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -183,7 +181,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
Projects = command.Projects,
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -223,7 +221,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
Projects = command.Projects
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.UpdateUserAsync(request, request.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdateUserAsync(request, request.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -245,7 +243,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.LoginUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.LoginUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -267,7 +265,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.LogoutUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.LogoutUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -289,7 +287,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.AddCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.AddCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -311,7 +309,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.RemoveCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.RemoveCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -333,7 +331,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.AddProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.AddProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -355,7 +353,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.RemoveProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.RemoveProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -377,51 +375,9 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetTokenAdapter(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.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();
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Users.Validator
|
||||
{
|
||||
public class ChangeUserStatusValidator : AbstractValidator<ChangeUserStatusRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Users.Validator
|
||||
{
|
||||
public class CreateUserValidator : AbstractValidator<CreateUserRequest>
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Users.Validator
|
||||
{
|
||||
public class UpdateUserValidator : AbstractValidator<UpdateUserRequest>
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.External.Clients;
|
||||
using Core.Cerberos.External.GatewayConfigurations;
|
||||
using Core.Cerberos.External.Helpers.Token;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.GatewayConfigurations;
|
||||
using Core.Thalos.External.Helpers.Token;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -8,7 +8,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Refit;
|
||||
|
||||
namespace Core.Cerberos.External.ClientConfiguration
|
||||
namespace Core.Thalos.External.ClientConfiguration
|
||||
{
|
||||
public static class RegisterClientConfiguration
|
||||
{
|
||||
@@ -37,18 +37,18 @@ namespace Core.Cerberos.External.ClientConfiguration
|
||||
return handler;
|
||||
});
|
||||
|
||||
var cerberosServiceApiUrl = GatewaySettingsConfigurations.GetCerberosServiceAPIEndpoint().Endpoint.Url;
|
||||
var thalosServiceApiUrl = GatewaySettingsConfigurations.GetThalosServiceAPIEndpoint().Endpoint.Url;
|
||||
|
||||
// Register ICerberosServiceClient with the manually created HttpClient
|
||||
services.AddScoped<ICerberosServiceClient>(provider =>
|
||||
// Register IThalosServiceClient with the manually created HttpClient
|
||||
services.AddScoped<IThalosServiceClient>(provider =>
|
||||
{
|
||||
var handler = provider.GetRequiredService<AuthenticatedHttpClientHandler>();
|
||||
var httpClient = new HttpClient(handler)
|
||||
{
|
||||
BaseAddress = new Uri(cerberosServiceApiUrl),
|
||||
BaseAddress = new Uri(thalosServiceApiUrl),
|
||||
Timeout = TimeSpan.FromMinutes(1)
|
||||
};
|
||||
return RestService.For<ICerberosServiceClient>(httpClient);
|
||||
return RestService.For<IThalosServiceClient>(httpClient);
|
||||
});
|
||||
|
||||
services.AddScoped<IAuthenticationService, AuthenticationService>();
|
||||
@@ -1,14 +1,14 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Refit;
|
||||
|
||||
namespace Core.Cerberos.External.Clients
|
||||
namespace Core.Thalos.External.Clients
|
||||
{
|
||||
public interface ICerberosServiceClient
|
||||
public interface IThalosServiceClient
|
||||
{
|
||||
[Get("/v1/User")]
|
||||
Task<IEnumerable<UserAdapter>> GetAllUsersAsync(CancellationToken cancellationToken = default);
|
||||
@@ -52,12 +52,6 @@ namespace Core.Cerberos.External.Clients
|
||||
[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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class ModuleRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class PermissionRequest
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class RoleRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class UserRequest
|
||||
{
|
||||
@@ -7,9 +7,9 @@
|
||||
</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="Core.Blueprint.Storage" Version="1.0.0" />
|
||||
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.2" />
|
||||
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" />
|
||||
<PackageReference Include="Refit" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using Core.Blueprint.External;
|
||||
|
||||
namespace Core.Cerberos.External.GatewayConfigurations
|
||||
namespace Core.Thalos.External.GatewayConfigurations
|
||||
{
|
||||
public record GatewayConfiguration
|
||||
{
|
||||
public GatewayConfiguration()
|
||||
{
|
||||
CerberosService = new CerberosServiceAPI();
|
||||
ThalosService = new ThalosServiceAPI();
|
||||
}
|
||||
|
||||
public CerberosServiceAPI CerberosService { get; set; }
|
||||
public ThalosServiceAPI ThalosService { get; set; }
|
||||
}
|
||||
public record CerberosServiceAPI
|
||||
public record ThalosServiceAPI
|
||||
{
|
||||
public string Channel { get; set; }
|
||||
public BaseEndpoint Endpoint { get; set; }
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Blueprint.External;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Core.Cerberos.External.GatewayConfigurations
|
||||
namespace Core.Thalos.External.GatewayConfigurations
|
||||
{
|
||||
public class GatewaySettingsConfigurations
|
||||
{
|
||||
@@ -11,13 +11,13 @@ namespace Core.Cerberos.External.GatewayConfigurations
|
||||
public GatewaySettingsConfigurations(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
this.SetCerberosServiceAPIEndpoint();
|
||||
this.SetThalosServiceAPIEndpoint();
|
||||
}
|
||||
public static CerberosServiceAPI GetCerberosServiceAPIEndpoint()
|
||||
public static ThalosServiceAPI GetThalosServiceAPIEndpoint()
|
||||
{
|
||||
return GatewayConfigurations.CerberosService;
|
||||
return GatewayConfigurations.ThalosService;
|
||||
}
|
||||
private GatewayConfiguration SetCerberosServiceAPIEndpoint()
|
||||
private GatewayConfiguration SetThalosServiceAPIEndpoint()
|
||||
{
|
||||
IConfigurationSection source;
|
||||
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
|
||||
@@ -27,18 +27,18 @@ namespace Core.Cerberos.External.GatewayConfigurations
|
||||
else
|
||||
source = _configuration.GetSection("Gateways");
|
||||
|
||||
var endpoint = source["CerberosDAL"] ?? string.Empty;
|
||||
var endpoint = source["ThalosDAL"] ?? string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Cerberos DAL endpoint is empty or null");
|
||||
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Thalos DAL endpoint is empty or null");
|
||||
|
||||
GatewayConfigurations.CerberosService = new CerberosServiceAPI()
|
||||
GatewayConfigurations.ThalosService = new ThalosServiceAPI()
|
||||
{
|
||||
Endpoint = new BaseEndpoint()
|
||||
{
|
||||
Uri = new Uri(endpoint),
|
||||
Url = endpoint,
|
||||
Token = string.Empty,
|
||||
APIName = "Cerberos Service"
|
||||
APIName = "Thalos Service"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="AuthenticatedHttpClientHandler.cs">
|
||||
// Heath
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
namespace Core.Cerberos.External.Helpers.Token
|
||||
namespace Core.Thalos.External.Helpers.Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to inject the token in all requests.
|
||||
@@ -1,12 +1,12 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="HttpContextTokenProvider.cs">
|
||||
// Heath
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Core.Cerberos.External.Helpers.Token
|
||||
namespace Core.Thalos.External.Helpers.Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to return the access token to controllers.
|
||||
@@ -1,10 +1,10 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="ITokenProvider.cs">
|
||||
// Heath
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
namespace Core.Cerberos.External.Helpers.Token
|
||||
namespace Core.Thalos.External.Helpers.Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for token provider.
|
||||
@@ -3,15 +3,15 @@ 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}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Thalos.Service.API", "Core.Thalos.Service.API\Core.Thalos.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}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Thalos.External", "Core.Thalos.External\Core.Thalos.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}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Thalos.Application", "Core.Thalos.Application\Core.Thalos.Application.csproj", "{F1980B4D-35C3-4495-84CF-09E1D3822CDA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -1,14 +1,14 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="ModuleController"/>.
|
||||
@@ -60,8 +60,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Read, RoleManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("ModuleManagement.Read, RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllModulesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getAllModulesHandler.ExecuteAsync(new GetAllModulesRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
@@ -91,8 +91,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("ModuleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -118,8 +118,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("ModuleManagement.Read")]
|
||||
public async Task<IActionResult> GetModuleById([FromBody] GetModuleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -144,8 +144,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> CreateModuleAsync([FromBody] CreateModuleRequest newModule, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await createModuleHandler.ExecuteAsync(newModule, cancellationToken).ConfigureAwait(false);
|
||||
@@ -164,8 +164,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> UpdateModuleAsync([FromBody] UpdateModuleRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await updateModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
@@ -185,8 +185,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> ChangeModuleStatusAsync([FromBody] ChangeModuleStatusRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -1,14 +1,14 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="PermissionController"/>.
|
||||
@@ -60,8 +60,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Read, RoleManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("PermissionManagement.Read, RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllPermissionsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getAllPermissionsHandler.ExecuteAsync(new GetAllPermissionsRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
@@ -91,8 +91,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("PermissionManagement.Read")]
|
||||
public async Task<IActionResult> GetAllPermissionsByListAsync([FromBody] GetAllPermissionsByListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -118,8 +118,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("PermissionManagement.Read")]
|
||||
public async Task<IActionResult> GetPermissionById([FromBody] GetPermissionRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -144,8 +144,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> CreatePermissionAsync([FromBody] CreatePermissionRequest newPermission, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await createPermissionHandler.ExecuteAsync(newPermission, cancellationToken).ConfigureAwait(false);
|
||||
@@ -164,8 +164,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> UpdatePermissionAsync([FromBody] UpdatePermissionRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await updatePermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
@@ -185,8 +185,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> ChangePermissionStatusAsync([FromBody] ChangePermissionStatusRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
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 Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for role authentication.
|
||||
@@ -16,7 +16,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class RoleController : ControllerBase
|
||||
{
|
||||
private readonly IComponentHandler<GetRoleRequest> getRoleHandler;
|
||||
@@ -63,8 +63,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllRolesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getAllRolesHandler.ExecuteAsync(new GetAllRolesRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
@@ -84,8 +84,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetRoleById([FromBody] GetRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
|
||||
@@ -106,8 +106,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> CreateRoleAsync([FromBody] CreateRoleRequest newRole, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await createRoleHandler.ExecuteAsync(newRole, cancellationToken).ConfigureAwait(false);
|
||||
@@ -126,8 +126,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> UpdateRoleAsync([FromBody] UpdateRoleRequest entity, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await updateRoleHandler.ExecuteAsync(entity, cancellationToken).ConfigureAwait(false);
|
||||
@@ -147,8 +147,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> ChageRoleStatusAsync(ChangeRoleStatusRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
|
||||
@@ -170,8 +170,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> AddApplicationToRoleAsync(AddApplicationToRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
|
||||
@@ -193,8 +193,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> RemoveApplicationToRoleAsync(RemoveApplicationFromRoleRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -1,14 +1,14 @@
|
||||
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 Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Ports;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for user.
|
||||
@@ -33,8 +33,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
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>
|
||||
@@ -55,8 +53,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
IComponentHandler<LogoutUserRequest> logoutUserHandler,
|
||||
IComponentHandler<ValidateUserExistenceRequest> validateUserHandler,
|
||||
IComponentHandler<GetTokenAdapterRequest> getTokenAdapterHandler,
|
||||
IComponentHandler<GetConsentFormPDFRequest> getConsentFormPDFHandler,
|
||||
IComponentHandler<AcceptUserConsentFormRequest> acceptUserConsentFormHandler,
|
||||
IUserPort port
|
||||
)
|
||||
{
|
||||
@@ -74,8 +70,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
this.logoutUserHandler = logoutUserHandler;
|
||||
this.validateUserHandler = validateUserHandler;
|
||||
this.getTokenAdapterHandler = getTokenAdapterHandler;
|
||||
this.getConsentFormPDFHandler = getConsentFormPDFHandler;
|
||||
this.acceptUserConsentFormHandler = acceptUserConsentFormHandler;
|
||||
this.port = port;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -90,8 +84,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetAllUsersAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getAllUsersHandler.ExecuteAsync(new GetAllUsersRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
@@ -111,8 +105,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetUserById([FromBody] GetUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); }
|
||||
@@ -134,7 +128,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
|
||||
public async Task<IActionResult> GetUserByEmail([FromBody] GetUserByEmailRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||
@@ -156,8 +150,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> CreateUserAsync([FromBody] CreateUserRequest newUser, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await createUserHandler.ExecuteAsync(newUser, cancellationToken).ConfigureAwait(false);
|
||||
@@ -176,8 +170,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> UpdateUserAsync([FromBody] UpdateUserRequest request,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
@@ -197,7 +191,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
|
||||
public async Task<IActionResult> LoginUserAsync([FromBody] LoginUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||
@@ -239,8 +233,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> ChangeUserStatusAsync([FromBody] ChangeUserStatusRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); }
|
||||
@@ -262,8 +256,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> AddCompanyToUserAsync([FromBody] AddCompanyToUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -287,8 +281,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> RemoveCompanyFromUserAsync([FromBody] RemoveCompanyFromUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -312,8 +306,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> AddProjectToUserAsync([FromBody] AddProjectToUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -337,8 +331,8 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> RemoveProjectFromUserAsync([FromBody] RemoveProjectFromUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -379,7 +373,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[HttpPost]
|
||||
[Route("GetTokenAdapter")]
|
||||
[ProducesResponseType(typeof(TokenAdapter), StatusCodes.Status200OK)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
|
||||
public async Task<IActionResult> GetTokenAdapter([FromBody] GetTokenAdapterRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||
@@ -388,45 +382,5 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@@ -8,12 +8,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||
<PackageReference Include="Blueprint.Logging" Version="0.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core.Cerberos.Application\Core.Cerberos.Application.csproj" />
|
||||
<ProjectReference Include="..\Core.Cerberos.External\Core.Cerberos.External.csproj" />
|
||||
<ProjectReference Include="..\Core.Thalos.Application\Core.Thalos.Application.csproj" />
|
||||
<ProjectReference Include="..\Core.Thalos.External\Core.Thalos.External.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
130
Core.Thalos.Service.API/Extensions/ServiceCollectionExtension.cs
Normal file
130
Core.Thalos.Service.API/Extensions/ServiceCollectionExtension.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using Core.Thalos.Application.UseCases.Modules;
|
||||
using Core.Thalos.Application.UseCases.Modules.Adapter;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.Application.UseCases.Modules.Validator;
|
||||
using Core.Thalos.Application.UseCases.Permissions;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Adapter;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Validator;
|
||||
using Core.Thalos.Application.UseCases.Role;
|
||||
using Core.Thalos.Application.UseCases.Roles.Adapter;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.Application.UseCases.Roles.Validator;
|
||||
using Core.Thalos.Application.UseCases.Users;
|
||||
using Core.Thalos.Application.UseCases.Users.Adapter;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.Application.UseCases.Users.Validator;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Service.API.Extensions
|
||||
{
|
||||
public static class ServiceCollectionExtension
|
||||
{
|
||||
public static IServiceCollection AddServiceConfigurationLayer(this IServiceCollection services)
|
||||
{
|
||||
#region User Services
|
||||
|
||||
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.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>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Role Services
|
||||
|
||||
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>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Permission Services
|
||||
|
||||
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>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Module Services
|
||||
|
||||
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>();
|
||||
|
||||
#endregion
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Extensions
|
||||
namespace Core.Thalos.Service.API.Extensions
|
||||
{
|
||||
public static class SwaggerExtensions
|
||||
{
|
||||
86
Core.Thalos.Service.API/Program.cs
Normal file
86
Core.Thalos.Service.API/Program.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using Core.Blueprint.Logging.Configuration;
|
||||
using Core.Thalos.Adapters.Extensions;
|
||||
using Core.Thalos.External.ClientConfiguration;
|
||||
using Core.Thalos.Service.API.Extensions;
|
||||
using Microsoft.AspNetCore.HttpLogging;
|
||||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
//var authSettings = AuthHelper.GetAuthSettings(builder, "thalos_service");
|
||||
|
||||
//builder.Services.ConfigureAuthentication(builder.Configuration, authSettings);
|
||||
|
||||
builder.Services.AddLogs(builder);
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Configuration
|
||||
.AddUserSecrets(Assembly.GetExecutingAssembly())
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
builder.Services.RegisterExternalLayer(builder.Configuration);
|
||||
builder.Services.AddServiceConfigurationLayer();
|
||||
builder.Services.AddResponseCompression();
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddMemoryCache();
|
||||
|
||||
builder.Host.ConfigureServices((context, services) =>
|
||||
{
|
||||
|
||||
services.AddLogging();
|
||||
services.AddControllers();
|
||||
services.AddProblemDetails();
|
||||
services.AddCors(options
|
||||
=> options.AddDefaultPolicy(policyBuilder
|
||||
=> policyBuilder
|
||||
.AllowAnyOrigin()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()));
|
||||
|
||||
builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options =>
|
||||
{
|
||||
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
});
|
||||
|
||||
services
|
||||
.AddEndpointsApiExplorer()
|
||||
.AddVersioning()
|
||||
.AddSwagger(builder.Configuration);
|
||||
|
||||
services.AddHealthChecks();
|
||||
services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All);
|
||||
|
||||
builder.Services.AddOutputCache(options =>
|
||||
{
|
||||
options.AddBasePolicy(builder =>
|
||||
builder.Expire(TimeSpan.FromSeconds(10)));
|
||||
options.AddPolicy("Expire20", builder =>
|
||||
builder.Expire(TimeSpan.FromSeconds(20)));
|
||||
options.AddPolicy("Expire30", builder =>
|
||||
builder.Expire(TimeSpan.FromSeconds(30)));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
app.UseCors();
|
||||
app.ConfigureSwagger();
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseResponseCompression();
|
||||
app.UseOutputCache();
|
||||
app.UseResponseCaching();
|
||||
app.UseLogging(builder.Configuration);
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
app.Run();
|
||||
|
||||
6
Core.Thalos.Service.API/Thalos.Service.API.http
Normal file
6
Core.Thalos.Service.API/Thalos.Service.API.http
Normal file
@@ -0,0 +1,6 @@
|
||||
@Core.Thalos.Service.API_HostAddress = http://localhost:5145
|
||||
|
||||
GET {{Core.Thalos.Service.API_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -7,6 +7,6 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"LocalGateways": {
|
||||
"CerberosDAL": "https://localhost:7031/api"
|
||||
"ThalosDAL": "https://localhost:7031/api"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"Gateways": {
|
||||
"CerberosDAL": "" // Data access layer endpoint
|
||||
"ThalosDAL": "" // Data access layer endpoint
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"KeyVault": "" //KeyVault Uri
|
||||
@@ -17,11 +17,11 @@
|
||||
"CallbackPath": "", // Path for redirect after authentication
|
||||
"Scopes": "" // Access scopes for user permissions
|
||||
},
|
||||
"HeathCerberosApp": {
|
||||
"ThalosApp": {
|
||||
"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)
|
||||
"ClientId": "" // Client ID for Thalos application (STORED IN KEY VAULT)
|
||||
},
|
||||
"MicrosoftGraph": {
|
||||
"Scopes": "", // Scopes for Microsoft Graph API access
|
||||
Reference in New Issue
Block a user