Feature/fix the issues with endpoints #1
| @@ -12,7 +12,6 @@ namespace Core.Thalos.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; | ||||
|   | ||||
| @@ -194,8 +194,7 @@ namespace Core.Thalos.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; | ||||
|   | ||||
| @@ -179,8 +179,7 @@ namespace Core.Thalos.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; | ||||
|   | ||||
| @@ -166,8 +166,7 @@ namespace Core.Thalos.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; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Blueprint.Storage" Version="0.0.1" /> | ||||
|     <PackageReference Include="BuildingBlocks.Library" Version="0.0.1" /> | ||||
|     <PackageReference Include="Thalos.Building.Blocks" Version="0.0.1" /> | ||||
|     <PackageReference Include="Thalos.Building.Blocks" Version="0.0.5" /> | ||||
|     <PackageReference Include="Refit" Version="8.0.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   | ||||
| @@ -60,8 +60,8 @@ 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")] | ||||
|         //[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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeModuleStatusAsync([FromBody] ChangeModuleStatusRequest request, | ||||
|                                                                      CancellationToken cancellationToken) | ||||
|         { | ||||
|   | ||||
| @@ -60,8 +60,8 @@ 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")] | ||||
|         //[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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("PermissionManagement.Write")] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("PermissionManagement.Write")] | ||||
|         public async Task<IActionResult> ChangePermissionStatusAsync([FromBody] ChangePermissionStatusRequest request, | ||||
|                                                                      CancellationToken cancellationToken) | ||||
|         { | ||||
|   | ||||
| @@ -16,7 +16,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 +63,8 @@ namespace Core.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [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.Thalos.Service.API.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> RemoveApplicationToRoleAsync(RemoveApplicationFromRoleRequest request, | ||||
|                                                                    CancellationToken cancellationToken) | ||||
|         { | ||||
|   | ||||
| @@ -33,8 +33,6 @@ namespace Core.Thalos.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.Thalos.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.Thalos.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.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); | ||||
| @@ -111,8 +105,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"); } | ||||
| @@ -134,7 +128,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.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.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); | ||||
| @@ -176,8 +170,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) | ||||
|         { | ||||
| @@ -197,7 +191,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.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.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"); } | ||||
| @@ -262,8 +256,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> AddCompanyToUserAsync([FromBody] AddCompanyToUserRequest request, | ||||
|                                                                CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -287,8 +281,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> RemoveCompanyFromUserAsync([FromBody] RemoveCompanyFromUserRequest request, | ||||
|                                                                    CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -312,8 +306,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> AddProjectToUserAsync([FromBody] AddProjectToUserRequest request, | ||||
|                                                               CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -337,8 +331,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> RemoveProjectFromUserAsync([FromBody] RemoveProjectFromUserRequest request, | ||||
|                                                                    CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -379,7 +373,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.AzureScheme}")] | ||||
|         public async Task<IActionResult> GetTokenAdapter([FromBody] GetTokenAdapterRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); } | ||||
|   | ||||
| @@ -7,6 +7,10 @@ | ||||
|     <GenerateDocumentationFile>True</GenerateDocumentationFile> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Blueprint.Logging" Version="0.0.2" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\Core.Thalos.Application\Core.Thalos.Application.csproj" /> | ||||
|     <ProjectReference Include="..\Core.Thalos.External\Core.Thalos.External.csproj" /> | ||||
|   | ||||
							
								
								
									
										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; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,168 +1,86 @@ | ||||
| using Core.Blueprint.Logging.Configuration; | ||||
| using Core.Thalos.Adapters.Extensions; | ||||
| using Core.Thalos.Adapters.Helpers; | ||||
| 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 Core.Thalos.External.ClientConfiguration; | ||||
| using Core.Thalos.Service.API.Extensions; | ||||
| using FluentValidation; | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
| using Microsoft.AspNetCore.ResponseCompression; | ||||
| using System.IO.Compression; | ||||
| using Microsoft.AspNetCore.HttpLogging; | ||||
| using System.Reflection; | ||||
| using System.Text.Json.Serialization; | ||||
|  | ||||
| var builder = WebApplication.CreateBuilder(args); | ||||
|  | ||||
| var authSettings = AuthHelper.GetAuthSettings(builder, "thalos_service"); | ||||
| //var authSettings = AuthHelper.GetAuthSettings(builder, "thalos_service"); | ||||
|  | ||||
| builder.Services.ConfigureAuthentication(builder.Configuration, authSettings); | ||||
| //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.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.Thalos.Service.API.xml", authSettings); | ||||
|     builder.Services.AddVersioning(builder.Configuration); | ||||
|     services.AddLogging(); | ||||
|     services.AddControllers(); | ||||
|     services.AddProblemDetails(); | ||||
|     services.AddCors(options | ||||
|         => options.AddDefaultPolicy(policyBuilder | ||||
|             => policyBuilder | ||||
|                 .AllowAnyOrigin() | ||||
|                 .AllowAnyHeader() | ||||
|                 .AllowAnyMethod())); | ||||
|  | ||||
|     //Register Stuff | ||||
|     services.RegisterExternalLayer(builder.Configuration); | ||||
|     builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options => | ||||
|     { | ||||
|         options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); | ||||
|     }); | ||||
|  | ||||
|     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 | ||||
|         .AddEndpointsApiExplorer() | ||||
|         .AddVersioning() | ||||
|         .AddSwagger(builder.Configuration); | ||||
|  | ||||
|     services.AddHealthChecks(); | ||||
|     services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All); | ||||
|  | ||||
|     services.AddValidatorsFromAssemblyContaining<CreateUserValidator>(); | ||||
|     services.AddScoped<IValidator<CreateUserRequest>, CreateUserValidator>(); | ||||
|     services.AddScoped<IComponentHandler<CreateUserRequest>, UserHandler>(); | ||||
|     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))); | ||||
|     }); | ||||
|  | ||||
|     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.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(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user