10 Commits

Author SHA1 Message Date
Sergio Matias Urquin
f3d63ca0e3 Merge branch 'feature/configure-authentication' into development 2025-07-27 19:33:30 -06:00
Sergio Matias Urquin
abcddaba9d Revise authentication and remove unnecessary code 2025-07-27 19:33:19 -06:00
c1637b9e20 Merge pull request 'Configure authentication in program and endpoints' (#2) from feature/configure-authentication into development
Reviewed-on: #2
Reviewed-by: efrain_marin <efrain.marin@agilewebs.com>
Reviewed-by: Sergio Matías <sergio.matias@agilewebs.com>
2025-07-18 00:59:03 +00:00
Sergio Matias Urquin
598081acea Merge branch 'development' into feature/configure-authentication 2025-07-17 18:57:33 -06:00
Oscar Morales
6d884d0d8b Remove commented code 2025-07-15 17:03:07 -06:00
Oscar Morales
4d43ac70cd Configure authentication in program and endpoints 2025-07-15 16:57:25 -06:00
3b42b60757 Fix merge 2025-06-23 00:36:05 -06:00
4cea65632b fix 2025-06-23 00:32:55 -06:00
a9981b6eb3 fix: updated BluePrint package
fixed package name and source
2025-06-20 22:00:37 -06:00
a09540f20a Merge pull request #1 from SergioMatias94/feature/fix-the-issues-with-endpoints
Feature/fix the issues with endpoints
2025-06-17 14:59:42 -06:00
46 changed files with 120 additions and 542 deletions

View File

@@ -1,5 +1,5 @@
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Modules.Ports;
using Core.Thalos.Application.UseCases.Modules.Ports;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Blueprint.Mongo;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Modules.Input

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Modules.Input

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Modules.Input

View File

@@ -1,6 +1,6 @@
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Modules.Input;
using Core.Thalos.Application.UseCases.Modules.Input;
using Core.Thalos.Application.UseCases.Modules.Ports;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.External.Clients;
using Core.Thalos.External.Clients.Requests;
using FluentValidation;

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Modules.Ports

View File

@@ -1,5 +1,5 @@
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Permissions.Ports;
using Core.Thalos.Application.UseCases.Permissions.Ports;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Blueprint.Mongo;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Permissions.Input

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Constants;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Permissions.Input

View File

@@ -1,5 +1,4 @@
using Core.Thalos.Adapters.Common.Constants;
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Permissions.Input
@@ -10,7 +9,7 @@ namespace Core.Thalos.Application.UseCases.Permissions.Input
public string Name { get; set; } = null!;
public string? Description { get; set; }
public AccessLevelEnum? AccessLevel { get; set; } = null!;
public StatusEnum Status { get; set; }
public Blueprint.Mongo.StatusEnum Status { get; set; }
public bool Validate()
{
return Id != null;

View File

@@ -1,6 +1,6 @@
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Permissions.Input;
using Core.Thalos.Application.UseCases.Permissions.Input;
using Core.Thalos.Application.UseCases.Permissions.Ports;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.External.Clients;
using Core.Thalos.External.Clients.Requests;
using FluentValidation;

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Permissions.Ports

View File

@@ -1,5 +1,5 @@
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Roles.Ports;
using Core.Thalos.Application.UseCases.Roles.Ports;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Roles.Input

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Blueprint.Mongo;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Roles.Input

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using System.Text.Json.Serialization;

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Roles.Input

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using System.Text.Json.Serialization;
@@ -14,7 +14,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input
public ApplicationsEnum[]? Applications { get; set; }
public string[] Modules { get; set; } = null!;
public string[] Permissions { get; set; } = null!;
public StatusEnum Status { get; set; }
public Blueprint.Mongo.StatusEnum Status { get; set; }
public bool Validate()
{

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Roles.Ports

View File

@@ -1,6 +1,6 @@
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Roles.Input;
using Core.Thalos.Application.UseCases.Roles.Input;
using Core.Thalos.Application.UseCases.Roles.Ports;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.External.Clients;
using Core.Thalos.External.Clients.Requests;
using FluentValidation;

View File

@@ -1,6 +1,6 @@
using Core.Blueprint.Storage.Adapters;
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Users.Ports;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,12 +0,0 @@
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Input
{
public class AcceptUserConsentFormRequest : ICommand
{
public bool Validate()
{
return true;
}
}
}

View File

@@ -1,14 +0,0 @@
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Input
{
public class AddCompanyToUserRequest : Notificator, ICommand
{
public string UserId { get; set; }
public string CompanyId { get; set; }
public bool Validate()
{
return true;
}
}
}

View File

@@ -1,14 +0,0 @@
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Input
{
public class AddProjectToUserRequest : Notificator, ICommand
{
public string UserId { get; set; }
public string ProjectId { get; set; }
public bool Validate()
{
return true;
}
}
}

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Blueprint.Mongo;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Input

View File

@@ -1,12 +0,0 @@
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Input
{
public class GetConsentFormPDFRequest : ICommand
{
public bool Validate()
{
return true;
}
}
}

View File

@@ -1,14 +0,0 @@
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Input
{
public class RemoveCompanyFromUserRequest : Notificator, ICommand
{
public string UserId { get; set; }
public string CompanyId { get; set; }
public bool Validate()
{
return true;
}
}
}

View File

@@ -1,14 +0,0 @@
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Input
{
public class RemoveProjectFromUserRequest : Notificator, ICommand
{
public string UserId { get; set; }
public string ProjectId { get; set; }
public bool Validate()
{
return true;
}
}
}

View File

@@ -1,5 +1,5 @@
using Core.Blueprint.Storage.Adapters;
using Core.Thalos.Adapters;
using Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
namespace Core.Thalos.Application.UseCases.Users.Ports

View File

@@ -1,6 +1,6 @@
using Core.Thalos.Adapters;
using Core.Thalos.Application.UseCases.Users.Input;
using Core.Thalos.Application.UseCases.Users.Input;
using Core.Thalos.Application.UseCases.Users.Ports;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.External.Clients;
using Core.Thalos.External.Clients.Requests;
using FluentValidation;
@@ -15,10 +15,6 @@ namespace Core.Thalos.Application.UseCases.Users
IComponentHandler<GetUserRequest>,
IComponentHandler<GetUserByEmailRequest>,
IComponentHandler<CreateUserRequest>,
IComponentHandler<AddProjectToUserRequest>,
IComponentHandler<RemoveProjectFromUserRequest>,
IComponentHandler<AddCompanyToUserRequest>,
IComponentHandler<RemoveCompanyFromUserRequest>,
IComponentHandler<LoginUserRequest>,
IComponentHandler<LogoutUserRequest>,
IComponentHandler<ValidateUserExistenceRequest>,
@@ -177,8 +173,6 @@ namespace Core.Thalos.Application.UseCases.Users
MiddleName = command.MiddleName,
LastName = command.LastName,
RoleId = command.RoleId,
Companies = command.Companies,
Projects = command.Projects,
};
var result = await _thalosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false);
@@ -217,8 +211,6 @@ namespace Core.Thalos.Application.UseCases.Users
MiddleName = command.MiddleName,
LastName = command.LastName,
RoleId = command.RoleId,
Companies = command.Companies,
Projects = command.Projects
};
var result = await _thalosDALService.UpdateUserAsync(request, request.Id, cancellationToken).ConfigureAwait(false);
@@ -281,94 +273,6 @@ namespace Core.Thalos.Application.UseCases.Users
}
}
public async ValueTask ExecuteAsync(AddCompanyToUserRequest command, CancellationToken cancellationToken = default)
{
try
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.AddCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
if (result == null)
{
_port.NoContentSuccess();
return;
}
_port.Success(result);
}
catch (Exception ex)
{
ApiResponseHelper.EvaluatePort(ex, _port);
}
}
public async ValueTask ExecuteAsync(RemoveCompanyFromUserRequest command, CancellationToken cancellationToken = default)
{
try
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.RemoveCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
if (result == null)
{
_port.NoContentSuccess();
return;
}
_port.Success(result);
}
catch (Exception ex)
{
ApiResponseHelper.EvaluatePort(ex, _port);
}
}
public async ValueTask ExecuteAsync(AddProjectToUserRequest command, CancellationToken cancellationToken = default)
{
try
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.AddProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
if (result == null)
{
_port.NoContentSuccess();
return;
}
_port.Success(result);
}
catch (Exception ex)
{
ApiResponseHelper.EvaluatePort(ex, _port);
}
}
public async ValueTask ExecuteAsync(RemoveProjectFromUserRequest command, CancellationToken cancellationToken = default)
{
try
{
ArgumentNullException.ThrowIfNull(command);
var result = await _thalosDALService.RemoveProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
if (result == null)
{
_port.NoContentSuccess();
return;
}
_port.Success(result);
}
catch (Exception ex)
{
ApiResponseHelper.EvaluatePort(ex, _port);
}
}
public async ValueTask ExecuteAsync(GetTokenAdapterRequest command, CancellationToken cancellationToken = default)
{
try

View File

@@ -1,7 +1,4 @@
using Core.Blueprint.Storage.Adapters;
using Core.Thalos.Adapters;
using Core.Thalos.Adapters.Common.Constants;
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.External.Clients.Requests;
using Microsoft.AspNetCore.Mvc;
using Refit;
@@ -35,23 +32,11 @@ namespace Core.Thalos.External.Clients
Task<UserAdapter> LogoutUserAsync([FromRoute] string email, CancellationToken cancellationToken = default);
[Patch("/v1/User/" + Routes.ChangeStatus)]
Task<UserAdapter> ChangeUserStatusAsync([FromRoute] string id, StatusEnum newStatus, CancellationToken cancellationToken = default);
Task<UserAdapter> ChangeUserStatusAsync([FromRoute] string id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
[Get("/v1/User/{email}/GetTokenAdapter")]
Task<TokenAdapter> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken = default);
[Post("/v1/User/" + Routes.AddCompany)]
Task<UserAdapter> AddCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken = default);
[Delete("/v1/User/" + Routes.RemoveCompany)]
Task<UserAdapter> RemoveCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken = default);
[Post("/v1/User/" + Routes.AddProject)]
Task<UserAdapter> AddProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken = default);
[Delete("/v1/User/" + Routes.RemoveProject)]
Task<UserAdapter> RemoveProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken = default);
[Get("/v1/Role")]
Task<IEnumerable<RoleAdapter>> GetAllRolesAsync(CancellationToken cancellationToken = default);
@@ -65,7 +50,7 @@ namespace Core.Thalos.External.Clients
Task<RoleAdapter> UpdateRoleAsync([FromBody] RoleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
[Patch("/v1/Role/" + Routes.ChangeStatus)]
Task<RoleAdapter> ChangeRoleStatusAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
Task<RoleAdapter> ChangeRoleStatusAsync([FromRoute] string id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
[Post("/v1/Role/" + Routes.AddApplication)]
Task<RoleAdapter> AddApplicationToRoleAsync([FromRoute] string RoleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken = default);
@@ -89,7 +74,7 @@ namespace Core.Thalos.External.Clients
Task<PermissionAdapter> UpdatePermissionAsync([FromBody] PermissionAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
[Patch("/v1/Permission/" + Routes.ChangeStatus)]
Task<PermissionAdapter> ChangeStatusPermissionAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
Task<PermissionAdapter> ChangeStatusPermissionAsync([FromRoute] string id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
[Get("/v1/Module")]
Task<IEnumerable<ModuleAdapter>> GetAllModulesAsync(CancellationToken cancellationToken = default);
@@ -107,6 +92,6 @@ namespace Core.Thalos.External.Clients
Task<ModuleAdapter> UpdateModuleAsync([FromBody] ModuleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
[Patch("/v1/Module/" + Routes.ChangeStatus)]
Task<ModuleAdapter> ChangeStatusModuleAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
Task<ModuleAdapter> ChangeStatusModuleAsync([FromRoute] string id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
}
}

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using System.Text.Json.Serialization;
namespace Core.Thalos.External.Clients.Requests

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Constants;
using Core.Thalos.BuildingBlocks;
namespace Core.Thalos.External.Clients.Requests
{

View File

@@ -1,4 +1,4 @@
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using System.Text.Json.Serialization;
namespace Core.Thalos.External.Clients.Requests

View File

@@ -7,7 +7,5 @@
public string? MiddleName { get; set; }
public string LastName { get; set; } = null!;
public string RoleId { get; set; } = null!;
public string[] Companies { get; set; } = null!;
public string[]? Projects { get; set; }
}
}

View File

@@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Core.Blueprint.Storage" Version="1.0.0" />
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.2" />
<PackageReference Include="Core.Blueprint.Storage" Version="1.0.1" />
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.8" />
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" />
<PackageReference Include="Refit" Version="8.0.0" />
</ItemGroup>

View File

@@ -1,9 +1,7 @@
using Asp.Versioning;
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 Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -17,6 +15,7 @@ namespace Core.Thalos.Service.API.Controllers
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class ModuleController : ControllerBase
{
private readonly IComponentHandler<GetModuleRequest> getModuleHandler;
@@ -60,8 +59,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read, RoleManagement.Read")]
[Permission("ModuleManagement.Read, RoleManagement.Read")]
public async Task<IActionResult> GetAllModulesAsync(CancellationToken cancellationToken)
{
await getAllModulesHandler.ExecuteAsync(new GetAllModulesRequest { }, cancellationToken).ConfigureAwait(false);
@@ -91,8 +89,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read")]
[Permission("ModuleManagement.Read")]
public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken)
{
@@ -118,8 +115,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read")]
[Permission("ModuleManagement.Read")]
public async Task<IActionResult> GetModuleById([FromBody] GetModuleRequest request, CancellationToken cancellationToken)
{
@@ -144,8 +140,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> CreateModuleAsync([FromBody] CreateModuleRequest newModule, CancellationToken cancellationToken = default)
{
await createModuleHandler.ExecuteAsync(newModule, cancellationToken).ConfigureAwait(false);
@@ -164,8 +159,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> UpdateModuleAsync([FromBody] UpdateModuleRequest request, CancellationToken cancellationToken = default)
{
await updateModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
@@ -185,8 +179,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> ChangeModuleStatusAsync([FromBody] ChangeModuleStatusRequest request,
CancellationToken cancellationToken)
{

View File

@@ -1,9 +1,7 @@
using Asp.Versioning;
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 Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -17,6 +15,7 @@ namespace Core.Thalos.Service.API.Controllers
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class PermissionController : ControllerBase
{
private readonly IComponentHandler<GetPermissionRequest> getPermissionHandler;
@@ -60,8 +59,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Read, RoleManagement.Read")]
[Permission("PermissionManagement.Read, RoleManagement.Read")]
public async Task<IActionResult> GetAllPermissionsAsync(CancellationToken cancellationToken)
{
await getAllPermissionsHandler.ExecuteAsync(new GetAllPermissionsRequest { }, cancellationToken).ConfigureAwait(false);
@@ -91,8 +89,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Read")]
[Permission("PermissionManagement.Read")]
public async Task<IActionResult> GetAllPermissionsByListAsync([FromBody] GetAllPermissionsByListRequest request, CancellationToken cancellationToken)
{
@@ -118,8 +115,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Read")]
[Permission("PermissionManagement.Read")]
public async Task<IActionResult> GetPermissionById([FromBody] GetPermissionRequest request, CancellationToken cancellationToken)
{
@@ -144,8 +140,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Write")]
[Permission("PermissionManagement.Write")]
public async Task<IActionResult> CreatePermissionAsync([FromBody] CreatePermissionRequest newPermission, CancellationToken cancellationToken = default)
{
await createPermissionHandler.ExecuteAsync(newPermission, cancellationToken).ConfigureAwait(false);
@@ -164,8 +159,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Write")]
[Permission("PermissionManagement.Write")]
public async Task<IActionResult> UpdatePermissionAsync([FromBody] UpdatePermissionRequest request, CancellationToken cancellationToken = default)
{
await updatePermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
@@ -185,8 +179,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Write")]
[Permission("PermissionManagement.Write")]
public async Task<IActionResult> ChangePermissionStatusAsync([FromBody] ChangePermissionStatusRequest request,
CancellationToken cancellationToken)
{

View File

@@ -1,8 +1,7 @@
using Asp.Versioning;
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 Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -16,7 +15,7 @@ namespace Core.Thalos.Service.API.Controllers
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class RoleController : ControllerBase
{
private readonly IComponentHandler<GetRoleRequest> getRoleHandler;
@@ -63,8 +62,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Read")]
[Permission("RoleManagement.Read")]
public async Task<IActionResult> GetAllRolesAsync(CancellationToken cancellationToken)
{
await getAllRolesHandler.ExecuteAsync(new GetAllRolesRequest { }, cancellationToken).ConfigureAwait(false);
@@ -84,8 +82,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Read")]
[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 +103,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> CreateRoleAsync([FromBody] CreateRoleRequest newRole, CancellationToken cancellationToken = default)
{
await createRoleHandler.ExecuteAsync(newRole, cancellationToken).ConfigureAwait(false);
@@ -126,8 +122,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> UpdateRoleAsync([FromBody] UpdateRoleRequest entity, CancellationToken cancellationToken = default)
{
await updateRoleHandler.ExecuteAsync(entity, cancellationToken).ConfigureAwait(false);
@@ -147,8 +142,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> ChageRoleStatusAsync(ChangeRoleStatusRequest request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
@@ -170,8 +164,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> AddApplicationToRoleAsync(AddApplicationToRoleRequest request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
@@ -193,8 +186,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> RemoveApplicationToRoleAsync(RemoveApplicationFromRoleRequest request,
CancellationToken cancellationToken)
{

View File

@@ -1,9 +1,7 @@
using Asp.Versioning;
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 Core.Thalos.BuildingBlocks;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -25,10 +23,6 @@ namespace Core.Thalos.Service.API.Controllers
private readonly IComponentHandler<CreateUserRequest> createUserHandler;
private readonly IComponentHandler<UpdateUserRequest> updateUserHandler;
private readonly IComponentHandler<ChangeUserStatusRequest> ChangeUserStatusHandler;
private readonly IComponentHandler<AddCompanyToUserRequest> addCompanyToUserHandler;
private readonly IComponentHandler<RemoveCompanyFromUserRequest> removeCompanyFromUserHandler;
private readonly IComponentHandler<AddProjectToUserRequest> addProjectToUserHandler;
private readonly IComponentHandler<RemoveProjectFromUserRequest> removeProjectFromUserHandler;
private readonly IComponentHandler<LoginUserRequest> loginUserHandler;
private readonly IComponentHandler<LogoutUserRequest> logoutUserHandler;
private readonly IComponentHandler<ValidateUserExistenceRequest> validateUserHandler;
@@ -45,10 +39,6 @@ namespace Core.Thalos.Service.API.Controllers
IComponentHandler<CreateUserRequest> createUserHandler,
IComponentHandler<UpdateUserRequest> updateUserHandler,
IComponentHandler<ChangeUserStatusRequest> changeUserStatusHandler,
IComponentHandler<AddCompanyToUserRequest> addCompanyToUserHandler,
IComponentHandler<RemoveCompanyFromUserRequest> removeCompanyFromUserHandler,
IComponentHandler<AddProjectToUserRequest> addProjectToUserHandler,
IComponentHandler<RemoveProjectFromUserRequest> removeProjectFromUserHandler,
IComponentHandler<LoginUserRequest> loginUserHandler,
IComponentHandler<LogoutUserRequest> logoutUserHandler,
IComponentHandler<ValidateUserExistenceRequest> validateUserHandler,
@@ -62,10 +52,6 @@ namespace Core.Thalos.Service.API.Controllers
this.getAllUsersHandler = getAllUsersHandler;
this.getUserHandler = getUserHandler;
this.getUserByEmailHandler = getUserByEmailHandler;
this.addCompanyToUserHandler = addCompanyToUserHandler;
this.removeCompanyFromUserHandler = removeCompanyFromUserHandler;
this.addProjectToUserHandler = addProjectToUserHandler;
this.removeProjectFromUserHandler = removeProjectFromUserHandler;
this.loginUserHandler = loginUserHandler;
this.logoutUserHandler = logoutUserHandler;
this.validateUserHandler = validateUserHandler;
@@ -84,8 +70,8 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -105,8 +91,8 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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"); }
@@ -128,7 +114,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
public async Task<IActionResult> GetUserByEmail([FromBody] GetUserByEmailRequest request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
@@ -150,8 +136,8 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -170,8 +156,8 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> UpdateUserAsync([FromBody] UpdateUserRequest request,
CancellationToken cancellationToken = default)
{
@@ -191,7 +177,7 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
public async Task<IActionResult> LoginUserAsync([FromBody] LoginUserRequest request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
@@ -233,8 +219,8 @@ namespace Core.Thalos.Service.API.Controllers
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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"); }
@@ -244,107 +230,6 @@ namespace Core.Thalos.Service.API.Controllers
return port.ViewModel;
}
/// <summary>
/// Adds a company to the user's list of companies.
/// </summary>
[HttpPost]
[Route("AddCompany")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> AddCompanyToUserAsync([FromBody] AddCompanyToUserRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
await addCompanyToUserHandler.ExecuteAsync(request, cancellationToken);
return port.ViewModel;
}
/// <summary>
/// Removes a company from the user's list of companies.
/// </summary>
[HttpDelete]
[Route("RemoveCompany")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> RemoveCompanyFromUserAsync([FromBody] RemoveCompanyFromUserRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
await removeCompanyFromUserHandler.ExecuteAsync(request, cancellationToken);
return port.ViewModel;
}
/// <summary>
/// Adds a project to the user's list of projects.
/// </summary>
[HttpPost]
[Route("AddProject")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> AddProjectToUserAsync([FromBody] AddProjectToUserRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
await addProjectToUserHandler.ExecuteAsync(request, cancellationToken);
return port.ViewModel;
}
/// <summary>
/// Removes a project from the user's list of projects.
/// </summary>
[HttpDelete]
[Route("RemoveProject")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> RemoveProjectFromUserAsync([FromBody] RemoveProjectFromUserRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
await removeProjectFromUserHandler.ExecuteAsync(request, cancellationToken);
return port.ViewModel;
}
/// <summary>
/// Validates if a user exists on the database.
/// </summary>
@@ -373,7 +258,7 @@ namespace Core.Thalos.Service.API.Controllers
[HttpPost]
[Route("GetTokenAdapter")]
[ProducesResponseType(typeof(TokenAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
public async Task<IActionResult> GetTokenAdapter([FromBody] GetTokenAdapterRequest request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }

View File

@@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blueprint.Logging" Version="0.0.2" />
<PackageReference Include="Core.Blueprint.Logging" Version="1.0.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -35,10 +35,6 @@ namespace Core.Thalos.Service.API.Extensions
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>();

View File

@@ -1,99 +0,0 @@
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using Swashbuckle.AspNetCore.SwaggerUI;
namespace Core.Thalos.Service.API.Extensions
{
public static class SwaggerExtensions
{
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
{
services.AddEndpointsApiExplorer();
AddSwaggerGen(services, configuration);
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
}
/// <summary>
/// Configures Swagger generation with OAuth2 security and XML comments.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
/// <param name="configuration">The <see cref="IConfiguration"/> containing Swagger and OAuth2 configuration settings.</param>
public static void AddSwaggerGen(this IServiceCollection services, IConfiguration configuration)
{
services.AddSwaggerGen(c =>
{
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT"
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
Array.Empty<string>()
}
});
});
}
public static void ConfigureSwagger(this WebApplication app)
{
//Swagger Stuff Goes Here
app.UseSwagger();
app.UseSwaggerUI(options =>
{
foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName))
options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version);
options.DisplayRequestDuration();
options.EnableTryItOutByDefault();
options.DocExpansion(DocExpansion.None);
});
// app.MapGet("/", () => Results.Redirect("/swagger/index.html")).WithTags(string.Empty);
}
public static IServiceCollection AddVersioning(this IServiceCollection services)
{
services.AddApiVersioning(options => options.ReportApiVersions = true)
.AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
});
return services;
}
}
public class ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) : IConfigureOptions<SwaggerGenOptions>
{
private readonly IApiVersionDescriptionProvider _provider = provider;
public void Configure(SwaggerGenOptions options)
{
foreach (var description in _provider.ApiVersionDescriptions)
options.SwaggerDoc(description.GroupName, new()
{
Title = AppDomain.CurrentDomain.FriendlyName,
Version = description.ApiVersion.ToString()
});
options.CustomSchemaIds(type => type.ToString().Replace("+", "."));
}
}
}

View File

@@ -1,5 +1,7 @@
using Core.Blueprint.KeyVault.Configuration;
using Core.Blueprint.Logging.Configuration;
using Core.Thalos.Adapters.Extensions;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.BuildingBlocks.Configuration;
using Core.Thalos.External.ClientConfiguration;
using Core.Thalos.Service.API.Extensions;
using Microsoft.AspNetCore.HttpLogging;
@@ -8,18 +10,21 @@ 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();
var services = builder.Services.AddKeyVault(builder.Configuration);
var authSettings = await AuthHelper.GetAuthSettings(builder.Services, builder, "thalos_common");
builder.Services.ConfigureAuthentication(builder.Configuration, authSettings);
builder.Services.AddLogs(builder);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(builder.Configuration, "Core.Thalos.Service.API.xml", authSettings);
builder.Services.AddVersioning(builder.Configuration);
builder.Services.RegisterExternalLayer(builder.Configuration);
builder.Services.AddServiceConfigurationLayer();
builder.Services.AddResponseCompression();
@@ -44,11 +49,6 @@ builder.Host.ConfigureServices((context, services) =>
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
services
.AddEndpointsApiExplorer()
.AddVersioning()
.AddSwagger(builder.Configuration);
services.AddHealthChecks();
services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All);
@@ -66,20 +66,22 @@ builder.Host.ConfigureServices((context, services) =>
var app = builder.Build();
app.UseLogging(builder.Configuration);
app.UseSwaggerUI(builder.Configuration, authSettings);
app.ConfigureSwagger(builder.Configuration);
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.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.MapHealthChecks("/health");
app.Run();

View File

@@ -8,5 +8,18 @@
"AllowedHosts": "*",
"LocalGateways": {
"ThalosDAL": "https://localhost:7031/api"
},
"ServiceSettings": {
"ApplicationName": "thalos",
"LayerName": "service"
},
"Vault": {
"Address": "http://100.123.31.103:8200",
"Token": "hvs.e37LQvLuPhTd5ALS5QQ03Cwm",
"SecretMount": "secret"
},
"IdentityProviders": {
"Google": true,
"Azure": true
}
}

View File

@@ -5,8 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Endpoints": {
"AppConfigurationURI": "https://sandbox-hci-usc-appcg.azconfig.io"
}
"AllowedHosts": "*"
}