Merge branch 'feature/configure-authentication' into development
This commit is contained in:
		| @@ -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 Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Blueprint.Mongo; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Modules.Input | namespace Core.Thalos.Application.UseCases.Modules.Input | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Modules.Input | namespace Core.Thalos.Application.UseCases.Modules.Input | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Modules.Input | namespace Core.Thalos.Application.UseCases.Modules.Input | ||||||
|   | |||||||
| @@ -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.Application.UseCases.Modules.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Core.Thalos.External.Clients; | using Core.Thalos.External.Clients; | ||||||
| using Core.Thalos.External.Clients.Requests; | using Core.Thalos.External.Clients.Requests; | ||||||
| using FluentValidation; | using FluentValidation; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Modules.Ports | namespace Core.Thalos.Application.UseCases.Modules.Ports | ||||||
|   | |||||||
| @@ -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 Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Blueprint.Mongo; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Permissions.Input | namespace Core.Thalos.Application.UseCases.Permissions.Input | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Constants; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Permissions.Input | namespace Core.Thalos.Application.UseCases.Permissions.Input | ||||||
|   | |||||||
| @@ -1,5 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Constants; | using Core.Thalos.BuildingBlocks; | ||||||
| using Core.Thalos.Adapters.Common.Enums; |  | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Permissions.Input | 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 Name { get; set; } = null!; | ||||||
|         public string? Description { get; set; } |         public string? Description { get; set; } | ||||||
|         public AccessLevelEnum? AccessLevel { get; set; } = null!; |         public AccessLevelEnum? AccessLevel { get; set; } = null!; | ||||||
|         public StatusEnum Status { get; set; } |         public Blueprint.Mongo.StatusEnum Status { get; set; } | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|             return Id != null; |             return Id != null; | ||||||
|   | |||||||
| @@ -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.Application.UseCases.Permissions.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Core.Thalos.External.Clients; | using Core.Thalos.External.Clients; | ||||||
| using Core.Thalos.External.Clients.Requests; | using Core.Thalos.External.Clients.Requests; | ||||||
| using FluentValidation; | using FluentValidation; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Permissions.Ports | namespace Core.Thalos.Application.UseCases.Permissions.Ports | ||||||
|   | |||||||
| @@ -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 Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | namespace Core.Thalos.Application.UseCases.Roles.Input | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Blueprint.Mongo; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | namespace Core.Thalos.Application.UseCases.Roles.Input | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using System.Text.Json.Serialization; | using System.Text.Json.Serialization; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | namespace Core.Thalos.Application.UseCases.Roles.Input | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using System.Text.Json.Serialization; | using System.Text.Json.Serialization; | ||||||
|  |  | ||||||
| @@ -14,7 +14,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | |||||||
|         public ApplicationsEnum[]? Applications { get; set; } |         public ApplicationsEnum[]? Applications { get; set; } | ||||||
|         public string[] Modules { get; set; } = null!; |         public string[] Modules { get; set; } = null!; | ||||||
|         public string[] Permissions { get; set; } = null!; |         public string[] Permissions { get; set; } = null!; | ||||||
|         public StatusEnum Status { get; set; } |         public Blueprint.Mongo.StatusEnum Status { get; set; } | ||||||
|  |  | ||||||
|         public bool Validate() |         public bool Validate() | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Roles.Ports | namespace Core.Thalos.Application.UseCases.Roles.Ports | ||||||
|   | |||||||
| @@ -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.Application.UseCases.Roles.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Core.Thalos.External.Clients; | using Core.Thalos.External.Clients; | ||||||
| using Core.Thalos.External.Clients.Requests; | using Core.Thalos.External.Clients.Requests; | ||||||
| using FluentValidation; | using FluentValidation; | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| using Core.Blueprint.Storage.Adapters; | using Core.Blueprint.Storage.Adapters; | ||||||
| using Core.Thalos.Adapters; |  | ||||||
| using Core.Thalos.Application.UseCases.Users.Ports; | using Core.Thalos.Application.UseCases.Users.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,12 +0,0 @@ | |||||||
| using Lib.Architecture.BuildingBlocks; |  | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Users.Input |  | ||||||
| { |  | ||||||
|     public class AcceptUserConsentFormRequest : ICommand |  | ||||||
|     { |  | ||||||
|         public bool Validate() |  | ||||||
|         { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -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; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -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; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Blueprint.Mongo; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Users.Input | namespace Core.Thalos.Application.UseCases.Users.Input | ||||||
|   | |||||||
| @@ -1,12 +0,0 @@ | |||||||
| using Lib.Architecture.BuildingBlocks; |  | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Users.Input |  | ||||||
| { |  | ||||||
|     public class GetConsentFormPDFRequest : ICommand |  | ||||||
|     { |  | ||||||
|         public bool Validate() |  | ||||||
|         { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -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; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -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; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| using Core.Blueprint.Storage.Adapters; | using Core.Blueprint.Storage.Adapters; | ||||||
| using Core.Thalos.Adapters; | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Users.Ports | namespace Core.Thalos.Application.UseCases.Users.Ports | ||||||
|   | |||||||
| @@ -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.Application.UseCases.Users.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Core.Thalos.External.Clients; | using Core.Thalos.External.Clients; | ||||||
| using Core.Thalos.External.Clients.Requests; | using Core.Thalos.External.Clients.Requests; | ||||||
| using FluentValidation; | using FluentValidation; | ||||||
| @@ -15,10 +15,6 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|         IComponentHandler<GetUserRequest>, |         IComponentHandler<GetUserRequest>, | ||||||
|         IComponentHandler<GetUserByEmailRequest>, |         IComponentHandler<GetUserByEmailRequest>, | ||||||
|         IComponentHandler<CreateUserRequest>, |         IComponentHandler<CreateUserRequest>, | ||||||
|         IComponentHandler<AddProjectToUserRequest>, |  | ||||||
|         IComponentHandler<RemoveProjectFromUserRequest>, |  | ||||||
|         IComponentHandler<AddCompanyToUserRequest>, |  | ||||||
|         IComponentHandler<RemoveCompanyFromUserRequest>, |  | ||||||
|         IComponentHandler<LoginUserRequest>, |         IComponentHandler<LoginUserRequest>, | ||||||
|         IComponentHandler<LogoutUserRequest>, |         IComponentHandler<LogoutUserRequest>, | ||||||
|         IComponentHandler<ValidateUserExistenceRequest>, |         IComponentHandler<ValidateUserExistenceRequest>, | ||||||
| @@ -177,8 +173,6 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|                     MiddleName = command.MiddleName, |                     MiddleName = command.MiddleName, | ||||||
|                     LastName = command.LastName, |                     LastName = command.LastName, | ||||||
|                     RoleId = command.RoleId, |                     RoleId = command.RoleId, | ||||||
|                     Companies = command.Companies, |  | ||||||
|                     Projects = command.Projects, |  | ||||||
|                 }; |                 }; | ||||||
|  |  | ||||||
|                 var result = await _thalosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false); |                 var result = await _thalosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false); | ||||||
| @@ -217,8 +211,6 @@ namespace Core.Thalos.Application.UseCases.Users | |||||||
|                     MiddleName = command.MiddleName, |                     MiddleName = command.MiddleName, | ||||||
|                     LastName = command.LastName, |                     LastName = command.LastName, | ||||||
|                     RoleId = command.RoleId, |                     RoleId = command.RoleId, | ||||||
|                     Companies = command.Companies, |  | ||||||
|                     Projects = command.Projects |  | ||||||
|                 }; |                 }; | ||||||
|  |  | ||||||
|                 var result = await _thalosDALService.UpdateUserAsync(request, request.Id, cancellationToken).ConfigureAwait(false); |                 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) |         public async ValueTask ExecuteAsync(GetTokenAdapterRequest command, CancellationToken cancellationToken = default) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|   | |||||||
| @@ -1,7 +1,4 @@ | |||||||
| using Core.Blueprint.Storage.Adapters; | using Core.Thalos.BuildingBlocks; | ||||||
| using Core.Thalos.Adapters; |  | ||||||
| using Core.Thalos.Adapters.Common.Constants; |  | ||||||
| using Core.Thalos.Adapters.Common.Enums; |  | ||||||
| using Core.Thalos.External.Clients.Requests; | using Core.Thalos.External.Clients.Requests; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Refit; | using Refit; | ||||||
| @@ -35,23 +32,11 @@ namespace Core.Thalos.External.Clients | |||||||
|         Task<UserAdapter> LogoutUserAsync([FromRoute] string email, CancellationToken cancellationToken = default); |         Task<UserAdapter> LogoutUserAsync([FromRoute] string email, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/User/" + Routes.ChangeStatus)] |         [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")] |         [Get("/v1/User/{email}/GetTokenAdapter")] | ||||||
|         Task<TokenAdapter> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken = default); |         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")] |         [Get("/v1/Role")] | ||||||
|         Task<IEnumerable<RoleAdapter>> GetAllRolesAsync(CancellationToken cancellationToken = default); |         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); |         Task<RoleAdapter> UpdateRoleAsync([FromBody] RoleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/Role/" + Routes.ChangeStatus)] |         [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)] |         [Post("/v1/Role/" + Routes.AddApplication)] | ||||||
|         Task<RoleAdapter> AddApplicationToRoleAsync([FromRoute] string RoleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken = default); |         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); |         Task<PermissionAdapter> UpdatePermissionAsync([FromBody] PermissionAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/Permission/" + Routes.ChangeStatus)] |         [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")] |         [Get("/v1/Module")] | ||||||
|         Task<IEnumerable<ModuleAdapter>> GetAllModulesAsync(CancellationToken cancellationToken = default); |         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); |         Task<ModuleAdapter> UpdateModuleAsync([FromBody] ModuleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Patch("/v1/Module/" + Routes.ChangeStatus)] |         [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); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using System.Text.Json.Serialization; | using System.Text.Json.Serialization; | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Requests | namespace Core.Thalos.External.Clients.Requests | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Constants; | using Core.Thalos.BuildingBlocks; | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Requests | namespace Core.Thalos.External.Clients.Requests | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.BuildingBlocks; | ||||||
| using System.Text.Json.Serialization; | using System.Text.Json.Serialization; | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Requests | namespace Core.Thalos.External.Clients.Requests | ||||||
|   | |||||||
| @@ -7,7 +7,5 @@ | |||||||
|         public string? MiddleName { get; set; } |         public string? MiddleName { get; set; } | ||||||
|         public string LastName { get; set; } = null!; |         public string LastName { get; set; } = null!; | ||||||
|         public string RoleId { get; set; } = null!; |         public string RoleId { get; set; } = null!; | ||||||
|         public string[] Companies { get; set; } = null!; |  | ||||||
|         public string[]? Projects { get; set; } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,8 +7,8 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Blueprint.Storage" Version="1.0.0" /> |     <PackageReference Include="Core.Blueprint.Storage" Version="1.0.1" /> | ||||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.5" /> |     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.8" /> | ||||||
|     <PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" /> |     <PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" /> | ||||||
|     <PackageReference Include="Refit" Version="8.0.0" /> |     <PackageReference Include="Refit" Version="8.0.0" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   | |||||||
| @@ -1,9 +1,7 @@ | |||||||
| using Asp.Versioning; | 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.Input; | ||||||
| using Core.Thalos.Application.UseCases.Modules.Ports; | using Core.Thalos.Application.UseCases.Modules.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|   | |||||||
| @@ -1,9 +1,7 @@ | |||||||
| using Asp.Versioning; | 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.Input; | ||||||
| using Core.Thalos.Application.UseCases.Permissions.Ports; | using Core.Thalos.Application.UseCases.Permissions.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|   | |||||||
| @@ -1,8 +1,7 @@ | |||||||
| using Asp.Versioning; | 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.Input; | ||||||
| using Core.Thalos.Application.UseCases.Roles.Ports; | using Core.Thalos.Application.UseCases.Roles.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|   | |||||||
| @@ -1,9 +1,7 @@ | |||||||
| using Asp.Versioning; | 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.Input; | ||||||
| using Core.Thalos.Application.UseCases.Users.Ports; | using Core.Thalos.Application.UseCases.Users.Ports; | ||||||
|  | using Core.Thalos.BuildingBlocks; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| @@ -25,10 +23,6 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|         private readonly IComponentHandler<CreateUserRequest> createUserHandler; |         private readonly IComponentHandler<CreateUserRequest> createUserHandler; | ||||||
|         private readonly IComponentHandler<UpdateUserRequest> updateUserHandler; |         private readonly IComponentHandler<UpdateUserRequest> updateUserHandler; | ||||||
|         private readonly IComponentHandler<ChangeUserStatusRequest> ChangeUserStatusHandler; |         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<LoginUserRequest> loginUserHandler; | ||||||
|         private readonly IComponentHandler<LogoutUserRequest> logoutUserHandler; |         private readonly IComponentHandler<LogoutUserRequest> logoutUserHandler; | ||||||
|         private readonly IComponentHandler<ValidateUserExistenceRequest> validateUserHandler; |         private readonly IComponentHandler<ValidateUserExistenceRequest> validateUserHandler; | ||||||
| @@ -45,10 +39,6 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             IComponentHandler<CreateUserRequest> createUserHandler, |             IComponentHandler<CreateUserRequest> createUserHandler, | ||||||
|             IComponentHandler<UpdateUserRequest> updateUserHandler, |             IComponentHandler<UpdateUserRequest> updateUserHandler, | ||||||
|             IComponentHandler<ChangeUserStatusRequest> changeUserStatusHandler, |             IComponentHandler<ChangeUserStatusRequest> changeUserStatusHandler, | ||||||
|             IComponentHandler<AddCompanyToUserRequest> addCompanyToUserHandler, |  | ||||||
|             IComponentHandler<RemoveCompanyFromUserRequest> removeCompanyFromUserHandler, |  | ||||||
|             IComponentHandler<AddProjectToUserRequest> addProjectToUserHandler, |  | ||||||
|             IComponentHandler<RemoveProjectFromUserRequest> removeProjectFromUserHandler, |  | ||||||
|             IComponentHandler<LoginUserRequest> loginUserHandler, |             IComponentHandler<LoginUserRequest> loginUserHandler, | ||||||
|             IComponentHandler<LogoutUserRequest> logoutUserHandler, |             IComponentHandler<LogoutUserRequest> logoutUserHandler, | ||||||
|             IComponentHandler<ValidateUserExistenceRequest> validateUserHandler, |             IComponentHandler<ValidateUserExistenceRequest> validateUserHandler, | ||||||
| @@ -62,10 +52,6 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             this.getAllUsersHandler = getAllUsersHandler; |             this.getAllUsersHandler = getAllUsersHandler; | ||||||
|             this.getUserHandler = getUserHandler; |             this.getUserHandler = getUserHandler; | ||||||
|             this.getUserByEmailHandler = getUserByEmailHandler; |             this.getUserByEmailHandler = getUserByEmailHandler; | ||||||
|             this.addCompanyToUserHandler = addCompanyToUserHandler; |  | ||||||
|             this.removeCompanyFromUserHandler = removeCompanyFromUserHandler; |  | ||||||
|             this.addProjectToUserHandler = addProjectToUserHandler; |  | ||||||
|             this.removeProjectFromUserHandler = removeProjectFromUserHandler; |  | ||||||
|             this.loginUserHandler = loginUserHandler; |             this.loginUserHandler = loginUserHandler; | ||||||
|             this.logoutUserHandler = logoutUserHandler; |             this.logoutUserHandler = logoutUserHandler; | ||||||
|             this.validateUserHandler = validateUserHandler; |             this.validateUserHandler = validateUserHandler; | ||||||
| @@ -244,107 +230,6 @@ namespace Core.Thalos.Service.API.Controllers | |||||||
|             return port.ViewModel; |             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> |         /// <summary> | ||||||
|         /// Validates if a user exists on the database. |         /// Validates if a user exists on the database. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|   | |||||||
| @@ -35,10 +35,6 @@ namespace Core.Thalos.Service.API.Extensions | |||||||
|             services.AddScoped<IComponentHandler<LoginUserRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<LoginUserRequest>, UserHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<LogoutUserRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<LogoutUserRequest>, UserHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetUserByEmailRequest>, 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<ValidateUserExistenceRequest>, UserHandler>(); | ||||||
|             services.AddScoped<IComponentHandler<GetTokenAdapterRequest>, UserHandler>(); |             services.AddScoped<IComponentHandler<GetTokenAdapterRequest>, UserHandler>(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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("+", ".")); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,6 +1,7 @@ | |||||||
|  | using Core.Blueprint.KeyVault.Configuration; | ||||||
| using Core.Blueprint.Logging.Configuration; | using Core.Blueprint.Logging.Configuration; | ||||||
| using Core.Thalos.Adapters.Extensions; | using Core.Thalos.BuildingBlocks; | ||||||
| using Core.Thalos.BuildingBlocks.Authentication.Extensions; | using Core.Thalos.BuildingBlocks.Configuration; | ||||||
| using Core.Thalos.External.ClientConfiguration; | using Core.Thalos.External.ClientConfiguration; | ||||||
| using Core.Thalos.Service.API.Extensions; | using Core.Thalos.Service.API.Extensions; | ||||||
| using Microsoft.AspNetCore.HttpLogging; | using Microsoft.AspNetCore.HttpLogging; | ||||||
| @@ -9,16 +10,21 @@ using System.Text.Json.Serialization; | |||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  |  | ||||||
| builder.Services.ConfigureAuthentication(builder.Configuration); |  | ||||||
|  |  | ||||||
| builder.Services.AddLogs(builder); |  | ||||||
|  |  | ||||||
| builder.Services.AddEndpointsApiExplorer(); |  | ||||||
| builder.Services.AddSwaggerGen(); |  | ||||||
| builder.Configuration | builder.Configuration | ||||||
|     .AddUserSecrets(Assembly.GetExecutingAssembly()) |     .AddUserSecrets(Assembly.GetExecutingAssembly()) | ||||||
|     .AddEnvironmentVariables(); |     .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.RegisterExternalLayer(builder.Configuration); | ||||||
| builder.Services.AddServiceConfigurationLayer(); | builder.Services.AddServiceConfigurationLayer(); | ||||||
| builder.Services.AddResponseCompression(); | builder.Services.AddResponseCompression(); | ||||||
| @@ -43,11 +49,6 @@ builder.Host.ConfigureServices((context, services) => | |||||||
|         options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); |         options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     services |  | ||||||
|         .AddEndpointsApiExplorer() |  | ||||||
|         .AddVersioning() |  | ||||||
|         .AddSwagger(builder.Configuration); |  | ||||||
|  |  | ||||||
|     services.AddHealthChecks(); |     services.AddHealthChecks(); | ||||||
|     services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All); |     services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All); | ||||||
|  |  | ||||||
| @@ -65,20 +66,22 @@ builder.Host.ConfigureServices((context, services) => | |||||||
|  |  | ||||||
| var app = builder.Build(); | var app = builder.Build(); | ||||||
|  |  | ||||||
|  | app.UseLogging(builder.Configuration); | ||||||
|  | app.UseSwaggerUI(builder.Configuration, authSettings); | ||||||
|  | app.ConfigureSwagger(builder.Configuration); | ||||||
|  |  | ||||||
| app.UseRouting(); | app.UseRouting(); | ||||||
| app.UseSwagger(); |  | ||||||
| app.UseSwaggerUI(); |  | ||||||
| app.UseAuthentication(); |  | ||||||
| app.UseAuthorization(); |  | ||||||
| app.MapControllers(); |  | ||||||
| app.UseCors(); | app.UseCors(); | ||||||
| app.ConfigureSwagger(); |  | ||||||
| app.UseHttpsRedirection(); | app.UseHttpsRedirection(); | ||||||
| app.UseStaticFiles(); | app.UseStaticFiles(); | ||||||
| app.UseResponseCompression(); | app.UseResponseCompression(); | ||||||
| app.UseOutputCache(); | app.UseOutputCache(); | ||||||
| app.UseResponseCaching(); | app.UseResponseCaching(); | ||||||
| app.UseLogging(builder.Configuration); |  | ||||||
|  | app.UseAuthentication(); | ||||||
|  | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | app.MapControllers(); | ||||||
| app.MapHealthChecks("/health"); | app.MapHealthChecks("/health"); | ||||||
|  |  | ||||||
| app.Run(); | app.Run(); | ||||||
|   | |||||||
| @@ -9,17 +9,17 @@ | |||||||
|   "LocalGateways": { |   "LocalGateways": { | ||||||
|     "ThalosDAL": "https://localhost:7031/api" |     "ThalosDAL": "https://localhost:7031/api" | ||||||
|   }, |   }, | ||||||
|   "Authentication": { |   "ServiceSettings": { | ||||||
|     "Google": { |     "ApplicationName": "thalos", | ||||||
|       "ClientId": "128345072002-mtfdgpcur44o9tbd7q6e0bb9qnp2crfp.apps.googleusercontent.com", |     "LayerName": "service" | ||||||
|       "ClientSecret": "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", |  | ||||||
|       "ApplicationName": "Thalos", |  | ||||||
|       "RedirectUri": "https://localhost:7239/api/v1/Authentication/callback" |  | ||||||
|     } |  | ||||||
|   }, |   }, | ||||||
|   "JwtIssuerOptions": { |   "Vault": { | ||||||
|     "Audience": "https://localhost:7239/", |     "Address": "http://100.123.31.103:8200", | ||||||
|     "Issuer": "webApi" |     "Token": "hvs.e37LQvLuPhTd5ALS5QQ03Cwm", | ||||||
|  |     "SecretMount": "secret" | ||||||
|   }, |   }, | ||||||
|   "SecretKey": "iNivDmHLpUA223sqsfhqGbMRdRj1PVkH1" |   "IdentityProviders": { | ||||||
|  |     "Google": true, | ||||||
|  |     "Azure": true | ||||||
|  |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin