Compare commits
	
		
			1 Commits
		
	
	
		
			263bcc7649
			...
			feature/go
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | e7a3ee2389 | 
| @@ -1,9 +1,18 @@ | |||||||
| using Asp.Versioning; | using Asp.Versioning; | ||||||
|  | using Core.Thalos.Adapters; | ||||||
|  | using Core.Thalos.Adapters.Common.Constants; | ||||||
|  | using Core.Thalos.Adapters.Contracts; | ||||||
| using Core.Thalos.Application.UseCases.Users.Input; | using Core.Thalos.Application.UseCases.Users.Input; | ||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.BFF.Api.Services; | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Users; | using Core.Thalos.External.Clients.Thalos.Requests.Users; | ||||||
|  | using Google.Apis.Auth.OAuth2; | ||||||
| using LSA.Dashboard.External.Clients.Dashboard; | using LSA.Dashboard.External.Clients.Dashboard; | ||||||
|  | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using Microsoft.Graph; | ||||||
|  | using Newtonsoft.Json.Linq; | ||||||
|  | using System.Reflection; | ||||||
|  | using System.Text.Json; | ||||||
|  |  | ||||||
| namespace Core.Thalos.BFF.Api.Controllers | namespace Core.Thalos.BFF.Api.Controllers | ||||||
| { | { | ||||||
| @@ -29,8 +38,9 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         { |         { | ||||||
|             var userCredential = await googleAuthorization.ExchangeCodeForToken(code); |             var userCredential = await googleAuthorization.ExchangeCodeForToken(code); | ||||||
|  |  | ||||||
|             return Ok(new { Token = userCredential!.Token.IdToken }); |             return Ok(new Token(userCredential!.Token.IdToken)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Get token for user. |         /// Get token for user. | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @@ -41,7 +51,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [HttpGet] |         [HttpGet] | ||||||
|         [Route(Routes.GenerateToken)] |         [Route(Routes.GenerateToken)] | ||||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] |         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||||
|         //[Authorize(AuthenticationSchemes = Schemes.GoogleScheme)] |         [Authorize] | ||||||
|         public async Task<IActionResult> GenerateTokenService(CancellationToken cancellationToken) |         public async Task<IActionResult> GenerateTokenService(CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|   | |||||||
| @@ -1,8 +1,12 @@ | |||||||
| using Asp.Versioning; | using Asp.Versioning; | ||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters; | ||||||
|  | using Core.Thalos.Adapters.Attributes; | ||||||
|  | using Core.Thalos.Adapters.Common.Constants; | ||||||
|  | using Core.Thalos.BFF.Api.Services; | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Permissions; | using Core.Thalos.External.Clients.Thalos.Requests.Permissions; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using LSA.Dashboard.External.Clients.Dashboard; | using LSA.Dashboard.External.Clients.Dashboard; | ||||||
|  | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
|  |  | ||||||
| @@ -20,7 +24,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|     public class ModuleController(IThalosServiceClient thalosServiceClient, ILogger<ModuleController> logger) : BaseController(logger) |     public class ModuleController(IThalosServiceClient thalosServiceClient, ILogger<ModuleController> logger) : BaseController(logger) | ||||||
|     { |     { | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets all modules. |         /// Gets all the modules. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpGet("GetAll")] |         [HttpGet("GetAll")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -29,6 +33,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [Authorize(AuthenticationSchemes = Constant.Scheme)] | ||||||
|         //[Permission("ModuleManagement.Read, RoleManagement.Read")] |         //[Permission("ModuleManagement.Read, RoleManagement.Read")] | ||||||
|         public async Task<IActionResult> GetAllModulesService(CancellationToken cancellationToken) |         public async Task<IActionResult> GetAllModulesService(CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
| @@ -46,7 +51,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets all modules by module identifiers. |         /// Gets all the modules by module identifiers. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="request">The request containing the list of module identifiers.</param> |         /// <param name="request">The request containing the list of module identifiers.</param> | ||||||
|         /// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param> |         /// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param> | ||||||
| @@ -62,6 +67,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] |         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] |         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [AllowAnonymous] | ||||||
|         //[Permission("ModuleManagement.Read")] |         //[Permission("ModuleManagement.Read")] | ||||||
|         public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
| @@ -95,6 +101,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|  |         [AllowAnonymous] | ||||||
|         //[Permission("ModuleManagement.Write")] |         //[Permission("ModuleManagement.Write")] | ||||||
|         public async Task<IActionResult> CreateModuleService(CreateModuleRequest newModule, CancellationToken cancellationToken) |         public async Task<IActionResult> CreateModuleService(CreateModuleRequest newModule, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
| @@ -136,7 +143,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(GetModuleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(GetModuleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid module identifier"); |                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid module identifier"); | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.GetModuleByIdService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.GetModuleByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
| @@ -200,7 +207,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(ChangeModuleStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(ChangeModuleStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid module identifier"); } |                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid module identifier"); } | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.ChangeModuleStatusService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.ChangeModuleStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -1,10 +1,13 @@ | |||||||
| using Asp.Versioning; | using Asp.Versioning; | ||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters; | ||||||
|  | using Core.Thalos.Adapters.Attributes; | ||||||
|  | using Core.Thalos.Adapters.Common.Constants; | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Permissions; | using Core.Thalos.External.Clients.Thalos.Requests.Permissions; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using LSA.Dashboard.External.Clients.Dashboard; | using LSA.Dashboard.External.Clients.Dashboard; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using Microsoft.Graph; | ||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
|  |  | ||||||
| namespace Core.Thalos.BFF.Api.Controllers | namespace Core.Thalos.BFF.Api.Controllers | ||||||
| @@ -21,7 +24,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|     public class PermissionController(IThalosServiceClient thalosServiceClient, ILogger<PermissionController> logger) : BaseController(logger) |     public class PermissionController(IThalosServiceClient thalosServiceClient, ILogger<PermissionController> logger) : BaseController(logger) | ||||||
|     { |     { | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets all permissions. |         /// Gets all the permissions. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpGet("GetAll")] |         [HttpGet("GetAll")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -30,7 +33,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("PermissionManagement.Read, RoleManagement.Read")] |         ////[Permission("PermissionManagement.Read, RoleManagement.Read")] | ||||||
|         public async Task<IActionResult> GetAllPermissionsService(CancellationToken cancellationToken) |         public async Task<IActionResult> GetAllPermissionsService(CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -47,7 +50,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets all permissions by permission identifiers. |         /// Gets all the permissions by permission identifiers. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="request">The request containing the list of permission identifiers.</param> |         /// <param name="request">The request containing the list of permission identifiers.</param> | ||||||
|         /// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param> |         /// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param> | ||||||
| @@ -135,7 +138,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(GetPermissionByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(GetPermissionByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid permission identifier"); |                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid permission identifier"); | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.GetPermissionByIdService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.GetPermissionByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
| @@ -197,7 +200,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(ChangePermissionStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(ChangePermissionStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid permission identifier"); } |                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid permission identifier"); } | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.ChangePermissionStatusService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.ChangePermissionStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -1,6 +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.BuildingBlocks; |  | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using LSA.Dashboard.External.Clients.Dashboard; | using LSA.Dashboard.External.Clients.Dashboard; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| @@ -21,7 +22,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|     public class RoleController(IThalosServiceClient thalosServiceClient, ILogger<RoleController> logger) : BaseController(logger) |     public class RoleController(IThalosServiceClient thalosServiceClient, ILogger<RoleController> logger) : BaseController(logger) | ||||||
|     { |     { | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets all roles. |         /// Gets all the roles. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpGet("GetAll")] |         [HttpGet("GetAll")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -30,7 +31,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("RoleManagement.Read")] |         [Permission("RoleManagement.Read")] | ||||||
|         public async Task<IActionResult> GetAllRolesService(CancellationToken cancellationToken) |         public async Task<IActionResult> GetAllRolesService(CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -56,7 +57,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("RoleManagement.Write")] |         [Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> CreateRoleService(CreateRoleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> CreateRoleService(CreateRoleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -94,14 +95,14 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("RoleManagement.Read")] |         [Permission("RoleManagement.Read")] | ||||||
|         public async Task<IActionResult> GetRoleByIdService(GetRoleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> GetRoleByIdService(GetRoleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(GetRoleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(GetRoleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid role identifier"); |                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid role identifier"); | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.GetRoleByIdService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.GetRoleByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
| @@ -122,7 +123,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("RoleManagement.Write")] |         [Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> UpdateRoleService(UpdateRoleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> UpdateRoleService(UpdateRoleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -133,7 +134,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request.Name)) return BadRequest("Invalid role name"); |                 if (string.IsNullOrEmpty(request.Name)) return BadRequest("Invalid role name"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid role identifier"); |                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid role identifier"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request.Description)) return BadRequest("Invalid role description"); |                 if (string.IsNullOrEmpty(request.Description)) return BadRequest("Invalid role description"); | ||||||
|  |  | ||||||
| @@ -165,14 +166,14 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("RoleManagement.Write")] |         [Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> ChangeRoleStatusService([FromBody] ChangeRoleStatusRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> ChangeRoleStatusService([FromBody] ChangeRoleStatusRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(ChangeRoleStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(ChangeRoleStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid role identifier"); } |                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); } | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.ChangeRoleStatusService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.ChangeRoleStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
| @@ -195,7 +196,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("RoleManagement.Write")] |         [Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> AddApplicationToRoleService([FromBody] AddApplicationToRoleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> AddApplicationToRoleService([FromBody] AddApplicationToRoleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -225,7 +226,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Permission("RoleManagement.Write")] |         [Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> RemoveApplicationFromRoleService([FromBody] RemoveApplicationFromRoleRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> RemoveApplicationFromRoleService([FromBody] RemoveApplicationFromRoleRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
|   | |||||||
| @@ -1,196 +0,0 @@ | |||||||
| using Asp.Versioning; |  | ||||||
| using Core.Thalos.BuildingBlocks; |  | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Tenants; |  | ||||||
| using Lib.Architecture.BuildingBlocks; |  | ||||||
| using LSA.Dashboard.External.Clients.Dashboard; |  | ||||||
| using Microsoft.AspNetCore.Authorization; |  | ||||||
| using Microsoft.AspNetCore.Mvc; |  | ||||||
| using System.Text.Json; |  | ||||||
|  |  | ||||||
| namespace Core.Thalos.BFF.Api.Controllers |  | ||||||
| { |  | ||||||
|     /// <summary> |  | ||||||
|     /// Handles all requests for Tenant authentication. |  | ||||||
|     /// </summary> |  | ||||||
|     [ApiVersion("1.0")] |  | ||||||
|     [Route("api/v{version:apiVersion}/[controller]")] |  | ||||||
|     [Consumes("application/json")] |  | ||||||
|     [Produces("application/json")] |  | ||||||
|     [ApiController] |  | ||||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] |  | ||||||
|     public class TenantController(IThalosServiceClient thalosServiceClient, ILogger<TenantController> logger) : BaseController(logger) |  | ||||||
|     { |  | ||||||
|         /// <summary> |  | ||||||
|         /// Gets all Tenants. |  | ||||||
|         /// </summary> |  | ||||||
|         [HttpGet("GetAll")] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |  | ||||||
|         //[Permission("TenantManagement.Read, RoleManagement.Read")] |  | ||||||
|         public async Task<IActionResult> GetAllTenantsService(CancellationToken cancellationToken) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 logger.LogInformation($"{nameof(GetAllTenantsService)} - Request received - Payload: "); |  | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.GetAllTenantsService(new GetAllTenantsRequest { }, cancellationToken)).ConfigureAwait(false); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 logger.LogError($"{nameof(GetAllTenantsService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload"); |  | ||||||
|                 throw; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// Creates a new Tenant. |  | ||||||
|         /// </summary> |  | ||||||
|         [HttpPost("Create")] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |  | ||||||
|         //[Permission("TenantManagement.Write")] |  | ||||||
|         public async Task<IActionResult> CreateTenantService(CreateTenantRequest newTenant, CancellationToken cancellationToken) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 logger.LogInformation($"{nameof(CreateTenantService)} - Request received - Payload: {JsonSerializer.Serialize(newTenant)}"); |  | ||||||
|  |  | ||||||
|                 if (newTenant == null) return BadRequest("Invalid Tenant object"); |  | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(newTenant.Name)) return BadRequest("Invalid Tenant name"); |  | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.CreateTenantService(newTenant, cancellationToken)).ConfigureAwait(false); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 logger.LogError($"{nameof(CreateTenantService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newTenant)}"); |  | ||||||
|                 throw; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// Gets the Tenant by identifier. |  | ||||||
|         /// </summary> |  | ||||||
|         [HttpPost("GetById")] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |  | ||||||
|         //[Permission("TenantManagement.Read")] |  | ||||||
|         public async Task<IActionResult> GetTenantByIdService(GetTenantRequest request, CancellationToken cancellationToken) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 logger.LogInformation($"{nameof(GetTenantByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |  | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid Tenant identifier"); |  | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.GetTenantByIdService(request, cancellationToken)).ConfigureAwait(false); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 logger.LogError($"{nameof(GetTenantByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); |  | ||||||
|                 throw; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// Updates a full Tenant by identifier. |  | ||||||
|         /// </summary> |  | ||||||
|         [HttpPut("Update")] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |  | ||||||
|         //[Permission("TenantManagement.Write")] |  | ||||||
|         public async Task<IActionResult> UpdateTenantService(UpdateTenantRequest newTenant, CancellationToken cancellationToken) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 logger.LogInformation($"{nameof(UpdateTenantService)} - Request received - Payload: {JsonSerializer.Serialize(newTenant)}"); |  | ||||||
|  |  | ||||||
|                 if (newTenant == null) return BadRequest("Invalid Tenant object"); |  | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(newTenant.Name)) return BadRequest("Invalid Tenant name"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.UpdateTenantService(newTenant, cancellationToken)).ConfigureAwait(false); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 logger.LogError($"{nameof(UpdateTenantService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newTenant)}"); |  | ||||||
|                 throw; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// Changes the status of the Tenant. |  | ||||||
|         /// </summary> |  | ||||||
|         [HttpPatch] |  | ||||||
|         [Route("ChangeStatus")] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |  | ||||||
|         //[Permission("TenantManagement.Write")] |  | ||||||
|         public async Task<IActionResult> ChangeTenantStatusService([FromBody] ChangeTenantStatusRequest request, CancellationToken cancellationToken) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 logger.LogInformation($"{nameof(ChangeTenantStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |  | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid Tenant identifier"); } |  | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.ChangeTenantStatusService(request, cancellationToken)).ConfigureAwait(false); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 logger.LogError($"{nameof(ChangeTenantStatusService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); |  | ||||||
|                 throw; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// Deletes the Tenant by identifier. |  | ||||||
|         /// </summary> |  | ||||||
|         [HttpDelete("Delete")] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |  | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |  | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |  | ||||||
|         //[Permission("TenantManagement.Write")] |  | ||||||
|         public async Task<IActionResult> DeleteTenantByIdService(DeleteTenantRequest request, CancellationToken cancellationToken) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 logger.LogInformation($"{nameof(DeleteTenantByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |  | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid Tenant identifier"); |  | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.DeleteTenantByIdService(request, cancellationToken)).ConfigureAwait(false); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 logger.LogError($"{nameof(DeleteTenantByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); |  | ||||||
|                 throw; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,6 +1,7 @@ | |||||||
| using Asp.Versioning; | using Asp.Versioning; | ||||||
|  | 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.BuildingBlocks; |  | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Users; | using Core.Thalos.External.Clients.Thalos.Requests.Users; | ||||||
| using Lib.Architecture.BuildingBlocks; | using Lib.Architecture.BuildingBlocks; | ||||||
| using LSA.Dashboard.External.Clients.Dashboard; | using LSA.Dashboard.External.Clients.Dashboard; | ||||||
| @@ -21,7 +22,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|     public class UserController(IThalosServiceClient thalosServiceClient, ILogger<UserController> logger) : BaseController(logger) |     public class UserController(IThalosServiceClient thalosServiceClient, ILogger<UserController> logger) : BaseController(logger) | ||||||
|     { |     { | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets all users. |         /// Gets all the users. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         [HttpGet("GetAll")] |         [HttpGet("GetAll")] | ||||||
|         [ProducesResponseType(StatusCodes.Status200OK)] |         [ProducesResponseType(StatusCodes.Status200OK)] | ||||||
| @@ -75,6 +76,8 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(newUser.RoleId)) return BadRequest("Invalid role id"); |                 if (string.IsNullOrEmpty(newUser.RoleId)) return BadRequest("Invalid role id"); | ||||||
|  |  | ||||||
|  |                 if (!newUser.Companies.Any()) return BadRequest("The user must contain at least one company"); | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.CreateUserService(newUser, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.CreateUserService(newUser, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
| @@ -102,7 +105,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(GetUserByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(GetUserByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid user identifier"); |                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid user identifier"); | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.GetUserByIdService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.GetUserByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
| @@ -191,7 +194,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Authorize(AuthenticationSchemes = $"{Schemes.GoogleScheme}, {Schemes.DefaultScheme}")] |         //[Authorize(AuthenticationSchemes = $"{Schemes.AzureScheme}, {Schemes.DefaultScheme}")] | ||||||
|         public async Task<IActionResult> LoginUserService([FromBody] LoginUserRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> LoginUserService([FromBody] LoginUserRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -219,7 +222,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] |         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] |         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||||
|         //[Authorize(AuthenticationSchemes = $"{Schemes.GoogleScheme}, {Schemes.DefaultScheme}")] |         //[Authorize(AuthenticationSchemes = $"{Schemes.AzureScheme}, {Schemes.DefaultScheme}")] | ||||||
|         public async Task<IActionResult> LogoutUserService([FromBody] LogoutUserRequest request, CancellationToken cancellationToken) |         public async Task<IActionResult> LogoutUserService([FromBody] LogoutUserRequest request, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             try |             try | ||||||
| @@ -257,7 +260,7 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|             { |             { | ||||||
|                 logger.LogInformation($"{nameof(ChangeUserStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); |                 logger.LogInformation($"{nameof(ChangeUserStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid user identifier"); } |                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); } | ||||||
|  |  | ||||||
|                 return await Handle(() => thalosServiceClient.ChangeUserStatusService(request, cancellationToken)).ConfigureAwait(false); |                 return await Handle(() => thalosServiceClient.ChangeUserStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|             } |             } | ||||||
| @@ -268,6 +271,135 @@ namespace Core.Thalos.BFF.Api.Controllers | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <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> AddCompanyToUserService([FromBody] AddCompanyToUserRequest request, CancellationToken cancellationToken) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 logger.LogInformation($"{nameof(AddCompanyToUserService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|  |                 if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); } | ||||||
|  |                 if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); } | ||||||
|  |  | ||||||
|  |                 return await Handle(() => thalosServiceClient.AddCompanyToUserService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 logger.LogError($"{nameof(AddCompanyToUserService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||||
|  |                 throw; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <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> RemoveCompanyFromUserService([FromBody] RemoveCompanyFromUserRequest request, CancellationToken cancellationToken) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 logger.LogInformation($"{nameof(RemoveCompanyFromUserService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|  |                 if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); } | ||||||
|  |                 if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); } | ||||||
|  |  | ||||||
|  |                 return await Handle(() => thalosServiceClient.RemoveCompanyFromUserService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 logger.LogError($"{nameof(RemoveCompanyFromUserService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||||
|  |                 throw; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Adds a project to the user's list of companies. | ||||||
|  |         /// </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> AddProjectToUserService([FromBody] AddProjectToUserRequest request, CancellationToken cancellationToken) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 logger.LogInformation($"{nameof(AddProjectToUserService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|  |                 if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); } | ||||||
|  |                 if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); } | ||||||
|  |  | ||||||
|  |                 return await Handle(() => thalosServiceClient.AddProjectToUserService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 logger.LogError($"{nameof(AddProjectToUserService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||||
|  |                 throw; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Removes a project from the user's list of companies. | ||||||
|  |         /// </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> RemoveProjectFromUserService([FromBody] RemoveProjectFromUserRequest request, CancellationToken cancellationToken) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 logger.LogInformation($"{nameof(RemoveProjectFromUserService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||||
|  |  | ||||||
|  |                 if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); } | ||||||
|  |                 if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); } | ||||||
|  |  | ||||||
|  |                 return await Handle(() => thalosServiceClient.RemoveProjectFromUserService(request, cancellationToken)).ConfigureAwait(false); | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) | ||||||
|  |             { | ||||||
|  |                 logger.LogError($"{nameof(RemoveProjectFromUserService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||||
|  |                 throw; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Gets the user by email. |         /// Gets the user by email. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|   | |||||||
| @@ -9,7 +9,13 @@ | |||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" /> |     <PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" /> | ||||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.1" /> |     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" /> | ||||||
|  |     <PackageReference Include="Google.Apis.Auth" Version="1.70.0" /> | ||||||
|  |     <PackageReference Include="Google.Apis.Oauth2.v2" Version="1.68.0.1869" /> | ||||||
|  |     <PackageReference Include="Google.Protobuf" Version="3.31.1" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.17" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.17" /> | ||||||
|  |     <PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.4" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|   | |||||||
| @@ -1,14 +1,28 @@ | |||||||
| using Core.Blueprint.KeyVault.Configuration; | using Asp.Versioning; | ||||||
|  | using Azure.Identity; | ||||||
| using Core.Blueprint.Logging.Configuration; | using Core.Blueprint.Logging.Configuration; | ||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Contracts; | ||||||
| using Core.Thalos.BuildingBlocks.Configuration; | using Core.Thalos.Adapters.Extensions; | ||||||
| using Core.Thalos.BuildingBlocks.Extensions; | using Core.Thalos.Adapters.Services; | ||||||
|  | using Core.Thalos.BFF.Api.Services; | ||||||
| using Core.Thalos.External.ClientConfiguration; | using Core.Thalos.External.ClientConfiguration; | ||||||
|  | using Google.Protobuf.WellKnownTypes; | ||||||
|  | using Microsoft.AspNetCore.Authentication; | ||||||
|  | using Microsoft.AspNetCore.Authentication.Cookies; | ||||||
|  | using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||||
|  | using Microsoft.AspNetCore.Authentication.OpenIdConnect; | ||||||
| using Microsoft.AspNetCore.ResponseCompression; | using Microsoft.AspNetCore.ResponseCompression; | ||||||
|  | using Microsoft.Extensions.Configuration.AzureAppConfiguration; | ||||||
|  | using Microsoft.IdentityModel.Tokens; | ||||||
|  | using Microsoft.OpenApi.Any; | ||||||
|  | using Microsoft.OpenApi.Interfaces; | ||||||
|  | using Microsoft.OpenApi.Models; | ||||||
| using OpenTelemetry.Logs; | using OpenTelemetry.Logs; | ||||||
| using OpenTelemetry.Resources; | using OpenTelemetry.Resources; | ||||||
|  | using Swashbuckle.AspNetCore.SwaggerUI; | ||||||
| using System.IO.Compression; | using System.IO.Compression; | ||||||
| using System.Reflection; | using System.Reflection; | ||||||
|  | using System.Security.Claims; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  |  | ||||||
| @@ -16,128 +30,171 @@ builder.Configuration | |||||||
|     .AddUserSecrets(Assembly.GetExecutingAssembly()) |     .AddUserSecrets(Assembly.GetExecutingAssembly()) | ||||||
|     .AddEnvironmentVariables(); |     .AddEnvironmentVariables(); | ||||||
|  |  | ||||||
| var services = builder.Services.AddKeyVault(builder.Configuration); | // 🔑 Google Auth config | ||||||
|  | var googleClientId = builder.Configuration["Authentication:Google:ClientId"]; | ||||||
|  | var googleClientSecret = builder.Configuration["Authentication:Google:ClientSecret"]; | ||||||
|  | var redirectUri = builder.Configuration["Authentication:Google:RedirectUri"]; | ||||||
|  |  | ||||||
| var authSettings = await AuthHelper.GetAuthSettings(builder.Services, builder, "thalos_common"); | // 🧩 Authentication | ||||||
|  | builder.Services.AddAuthentication(options => | ||||||
| builder.Services.ConfigureAuthentication(builder.Configuration, authSettings); | { | ||||||
|  |     options.DefaultAuthenticateScheme = Constant.Scheme; | ||||||
|  |     options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; | ||||||
|  | }) | ||||||
|  | .AddScheme<AuthenticationSchemeOptions, | ||||||
|  | GoogleAccessTokenAuthenticationHandler>(Constant.Scheme, null) | ||||||
|  | .AddGoogle(options => | ||||||
|  | { | ||||||
|  |     options.ClientId = googleClientId!; | ||||||
|  |     options.ClientSecret = googleClientSecret!; | ||||||
|  |     //options.SaveTokens = true; | ||||||
|  |     options.CallbackPath = $"/{redirectUri}"; | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | builder.Services.AddAuthorization(); | ||||||
|  | builder.Services.AddScoped<IGoogleAuthHelper, GoogleAuthHelperService>(); | ||||||
|  | builder.Services.AddScoped<IGoogleAuthorization, GoogleAuthorizationService>(); | ||||||
| builder.Services.AddEndpointsApiExplorer(); | builder.Services.AddEndpointsApiExplorer(); | ||||||
|  |  | ||||||
|  | // 🧩 Swagger + OAuth2 | ||||||
|  | builder.Services.AddSwaggerGen(opts => | ||||||
|  | { | ||||||
|  |     const string schemeName = "oauth2"; | ||||||
|  |  | ||||||
|  |     opts.SwaggerDoc("v1", | ||||||
|  |         new OpenApiInfo { Title = "Core.Thalos.BFF", Version = "v1" }); | ||||||
|  |  | ||||||
|  |     opts.AddSecurityDefinition(schemeName, new OpenApiSecurityScheme | ||||||
|  |     { | ||||||
|  |         Type = SecuritySchemeType.OAuth2, | ||||||
|  |         Scheme = "bearer",              // tells Swagger-UI to build an Authorization header | ||||||
|  |         BearerFormat = "JWT", | ||||||
|  |         Name = "Authorization", | ||||||
|  |         In = ParameterLocation.Header, | ||||||
|  |  | ||||||
|  |         /* ⚠️  The key line – tell Swagger-UI to pick id_token instead of access_token */ | ||||||
|  |         Extensions = new Dictionary<string, IOpenApiExtension> | ||||||
|  |         { | ||||||
|  |             ["x-tokenName"] = new OpenApiString("id_token") | ||||||
|  |         }, | ||||||
|  |  | ||||||
|  |         Flows = new OpenApiOAuthFlows | ||||||
|  |         { | ||||||
|  |             AuthorizationCode = new OpenApiOAuthFlow | ||||||
|  |             { | ||||||
|  |                 AuthorizationUrl = new Uri("https://accounts.google.com/o/oauth2/v2/auth"), | ||||||
|  |                 TokenUrl = new Uri("https://oauth2.googleapis.com/token"), | ||||||
|  |                 Scopes = new Dictionary<string, string> | ||||||
|  |                 { | ||||||
|  |                     { "openid",  "OpenID Connect" }, | ||||||
|  |                     { "email",   "Access email"   }, | ||||||
|  |                     { "profile", "Access profile" } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     // every operation requires the scheme | ||||||
|  |     opts.AddSecurityRequirement(new OpenApiSecurityRequirement | ||||||
|  |     { | ||||||
|  |         [new OpenApiSecurityScheme | ||||||
|  |         { | ||||||
|  |             Reference = new OpenApiReference | ||||||
|  |             { Type = ReferenceType.SecurityScheme, Id = schemeName } | ||||||
|  |         } | ||||||
|  |         ] = new[] { "openid", "email", "profile" } | ||||||
|  |     }); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | // 🎯 Existing configs (unchanged) | ||||||
| builder.Services.AddResponseCompression(); | builder.Services.AddResponseCompression(); | ||||||
| builder.Services.AddProblemDetails(); | builder.Services.AddProblemDetails(); | ||||||
| builder.Services.AddLogs(builder); | builder.Services.AddLogs(builder); | ||||||
| builder.Services.AddMemoryCache(); | builder.Services.AddMemoryCache(); | ||||||
| builder.Services.AddResponseCaching(configureOptions => { configureOptions.UseCaseSensitivePaths = true; }); | builder.Services.AddResponseCaching(options => { options.UseCaseSensitivePaths = true; }); | ||||||
| builder.Logging.AddOpenTelemetry(options => |  | ||||||
|  | builder.Logging.AddOpenTelemetry(logging => | ||||||
| { | { | ||||||
|     options.IncludeScopes = true; |     logging.IncludeScopes = true; | ||||||
|     options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("core.thalos.bff.api")).AddConsoleExporter(); |     logging.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("core.thalos.bff.api")) | ||||||
|  |            .AddConsoleExporter(); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| builder.Host.ConfigureServices((context, services) => | builder.Host.ConfigureServices((context, services) => | ||||||
| { | { | ||||||
|     builder.Services.AddHsts(options => |     services.AddHsts(options => | ||||||
|     { |     { | ||||||
|         options.Preload = true; |         options.Preload = true; | ||||||
|         options.IncludeSubDomains = true; |         options.IncludeSubDomains = true; | ||||||
|         options.MaxAge = TimeSpan.FromDays(60); |         options.MaxAge = TimeSpan.FromDays(60); | ||||||
|     }); |     }); | ||||||
|     builder.Services.AddResponseCaching(configureOptions => |  | ||||||
|     { |  | ||||||
|         configureOptions.UseCaseSensitivePaths = true; |  | ||||||
|         configureOptions.MaximumBodySize = 2048; |  | ||||||
|     }); |  | ||||||
|     builder.Services.AddHttpsRedirection(options => |  | ||||||
|     { |  | ||||||
|         options.RedirectStatusCode = 308; |  | ||||||
|     }); |  | ||||||
|  |  | ||||||
|     services.AddHttpLogging(http => |     services.AddHttpsRedirection(options => { options.RedirectStatusCode = 308; }); | ||||||
|     { |  | ||||||
|         http.CombineLogs = true; |  | ||||||
|     }); |  | ||||||
|     services.AddAntiforgery(); |     services.AddAntiforgery(); | ||||||
|  |     services.AddHttpLogging(http => http.CombineLogs = true); | ||||||
|  |     services.AddCors(options => options.AddPolicy("AllowAll", policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod())); | ||||||
|  |  | ||||||
|     services.AddCors(options => |     services.AddMvc().AddJsonOptions(opt => | ||||||
|     { |     { | ||||||
|         options.AddPolicy("AllowAll", policyBuilder => |         opt.JsonSerializerOptions.WriteIndented = true; | ||||||
|             policyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); |         opt.JsonSerializerOptions.MaxDepth = 20; | ||||||
|  |         opt.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals; | ||||||
|     }); |     }); | ||||||
|     services.AddMvc().AddJsonOptions(options => |  | ||||||
|  |     services.Configure<BrotliCompressionProviderOptions>(opt => opt.Level = CompressionLevel.SmallestSize); | ||||||
|  |     services.Configure<GzipCompressionProviderOptions>(opt => opt.Level = CompressionLevel.SmallestSize); | ||||||
|  |     services.AddResponseCompression(opt => | ||||||
|     { |     { | ||||||
|         options.JsonSerializerOptions.WriteIndented = true; |         opt.EnableForHttps = true; | ||||||
|         options.JsonSerializerOptions.MaxDepth = 20; |         opt.Providers.Add<BrotliCompressionProvider>(); | ||||||
|         options.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals; |         opt.Providers.Add<GzipCompressionProvider>(); | ||||||
|     }); |     }); | ||||||
|     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.AddControllers(); | ||||||
|     services.AddSwaggerGen(builder.Configuration, "Core.Thalos.BFF.Api.xml", authSettings); |  | ||||||
|     services.AddVersioning(builder.Configuration); |  | ||||||
|     services.AddLogging(); |  | ||||||
|     services.AddProblemDetails(); |  | ||||||
|     services.AddHttpContextAccessor(); |     services.AddHttpContextAccessor(); | ||||||
|     services.AddTransient<TrackingMechanismExtension>(); // Register the TrackingIdHandler |     services.AddTransient<TrackingMechanismExtension>(); | ||||||
|     services.RegisterExternalLayer(builder.Configuration); |     services.RegisterExternalLayer(builder.Configuration); | ||||||
| }); |  | ||||||
|  |  | ||||||
| builder.Services.AddCors(options => |     services.AddApiVersioning(options => options.ReportApiVersions = true) | ||||||
| { |            .AddApiExplorer(opt => | ||||||
|     options.AddDefaultPolicy( |  | ||||||
|         builder => |  | ||||||
|            { |            { | ||||||
|             builder.AllowAnyOrigin() |                opt.GroupNameFormat = "'v'VVV"; | ||||||
|                                 .AllowAnyHeader() |                opt.SubstituteApiVersionInUrl = true; | ||||||
|                                 .AllowAnyMethod(); |  | ||||||
|            }); |            }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| builder.Services.AddScoped<ITokenService, TokenService>(); | builder.Services.AddScoped<ITokenService, TokenService>(); | ||||||
|  |  | ||||||
| builder.Services.AddOutputCache(options => | var app = builder.Build(); | ||||||
|  |  | ||||||
|  | app.UseDeveloperExceptionPage(); | ||||||
|  |  | ||||||
|  | app.UseSwagger(); | ||||||
|  |  | ||||||
|  | app.UseCors(options => options.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().WithOrigins("https://localhost:7239")); | ||||||
|  | app.UseSwaggerUI(options => | ||||||
| { | { | ||||||
|     options.AddBasePolicy(builder => |     foreach (var version in app.DescribeApiVersions().Select(v => v.GroupName)) | ||||||
|         builder.Expire(TimeSpan.FromSeconds(10))); |         options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version); | ||||||
|     options.AddPolicy("Expire20", builder => |  | ||||||
|         builder.Expire(TimeSpan.FromSeconds(20))); |     options.DisplayRequestDuration(); | ||||||
|     options.AddPolicy("Expire30", builder => |     options.EnableTryItOutByDefault(); | ||||||
|         builder.Expire(TimeSpan.FromSeconds(30))); |     options.DocExpansion(DocExpansion.None); | ||||||
|  |  | ||||||
|  |     options.OAuthClientId(googleClientId); | ||||||
|  |     options.OAuthClientSecret(googleClientSecret); | ||||||
|  |     options.OAuthUsePkce(); | ||||||
|  |     options.OAuthScopes("openid", "email", "profile"); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| //*************************************************************************// |  | ||||||
| var app = builder.Build(); |  | ||||||
| app.UseLogging(builder.Configuration); |  | ||||||
| app.UseSwaggerUI(builder.Configuration, authSettings); |  | ||||||
| app.ConfigureSwagger(builder.Configuration); |  | ||||||
|  |  | ||||||
|  |  | ||||||
| app.UseRouting(); |  | ||||||
| app.UseCors(); |  | ||||||
| app.UseHttpsRedirection(); |  | ||||||
| app.UseStaticFiles(); |  | ||||||
| app.UseResponseCompression(); | app.UseResponseCompression(); | ||||||
| app.UseOutputCache(); |  | ||||||
| app.UseResponseCaching(); | app.UseResponseCaching(); | ||||||
|  | app.UseHttpsRedirection(); | ||||||
|  |  | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
| app.MapControllers(); | app.MapControllers(); | ||||||
| //app.MapHealthChecks("/health"); | app.UseHsts(); | ||||||
|  | app.UseAntiforgery(); | ||||||
|  | app.UseLogging(builder.Configuration); | ||||||
| app.Run(); | app.Run(); | ||||||
							
								
								
									
										7
									
								
								Core.Thalos.BFF.Api/Services/Constant.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Core.Thalos.BFF.Api/Services/Constant.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | namespace Core.Thalos.BFF.Api.Services | ||||||
|  | { | ||||||
|  |     public static class Constant | ||||||
|  |     { | ||||||
|  |         public const string Scheme = "GoogleAccessToken"; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,61 @@ | |||||||
|  | using Google.Apis.Auth; | ||||||
|  | using Google.Apis.Auth.OAuth2.Flows; | ||||||
|  | using Microsoft.AspNetCore.Authentication; | ||||||
|  | using Microsoft.Extensions.Options; | ||||||
|  | using System.Security.Claims; | ||||||
|  | using System.Text.Encodings.Web; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.BFF.Api.Services | ||||||
|  | { | ||||||
|  |     public class GoogleAccessTokenAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, | ||||||
|  |          ILoggerFactory logger, | ||||||
|  |          UrlEncoder encoder, | ||||||
|  |          IConfiguration config) : AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder) | ||||||
|  |     { | ||||||
|  |         protected override async Task<AuthenticateResult> HandleAuthenticateAsync() | ||||||
|  |         { | ||||||
|  |             if (!Request.Headers.ContainsKey("Authorization")) | ||||||
|  |                 return AuthenticateResult.Fail("Missing Authorization header"); | ||||||
|  |  | ||||||
|  |             var authHeader = Request.Headers.Authorization.ToString(); | ||||||
|  |             if (!authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) | ||||||
|  |                 return AuthenticateResult.Fail("Invalid Authorization header"); | ||||||
|  |  | ||||||
|  |             var idToken = authHeader["Bearer ".Length..].Trim(); | ||||||
|  |  | ||||||
|  |             GoogleJsonWebSignature.Payload payload; | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 payload = await GoogleJsonWebSignature.ValidateAsync( | ||||||
|  |                     idToken, | ||||||
|  |                     new GoogleJsonWebSignature.ValidationSettings | ||||||
|  |                     { | ||||||
|  |                         Audience = new[] { config["Authentication:Google:ClientId"]! } | ||||||
|  |                     }); | ||||||
|  |             } | ||||||
|  |             catch (InvalidJwtException) | ||||||
|  |             { | ||||||
|  |                 return AuthenticateResult.Fail("Invalid Google token"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             var claims = new List<Claim> | ||||||
|  |             { | ||||||
|  |                 new Claim(ClaimTypes.NameIdentifier, payload.Subject), | ||||||
|  |                 new Claim(ClaimTypes.Email,          payload.Email), | ||||||
|  |                 new Claim(ClaimTypes.Name,           payload.Name ?? "") | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             var identity = new ClaimsIdentity(claims, Constant.Scheme); | ||||||
|  |             var principal = new ClaimsPrincipal(identity); | ||||||
|  |  | ||||||
|  |             var userEmail = principal.FindFirst(ClaimTypes.Email)?.Value; | ||||||
|  |  | ||||||
|  |             if (string.IsNullOrEmpty(userEmail) ||  | ||||||
|  |                 !userEmail.EndsWith("@agilewebs.com", StringComparison.OrdinalIgnoreCase)) | ||||||
|  |                 return AuthenticateResult.Fail("Unauthorized Access"); | ||||||
|  |  | ||||||
|  |             var ticket = new AuthenticationTicket(principal, Constant.Scheme); | ||||||
|  |             return AuthenticateResult.Success(ticket); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										37
									
								
								Core.Thalos.BFF.Api/Services/IGoogleAuthHelper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Core.Thalos.BFF.Api/Services/IGoogleAuthHelper.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | using Google.Apis.Auth.OAuth2; | ||||||
|  | using Google.Apis.Oauth2.v2; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.BFF.Api.Services | ||||||
|  | { | ||||||
|  |     public interface IGoogleAuthHelper | ||||||
|  |     { | ||||||
|  |         string[] GetScopes(); | ||||||
|  |         string ScopeToString(); | ||||||
|  |         ClientSecrets GetClientSecrets(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public class GoogleAuthHelperService(IConfiguration config) : IGoogleAuthHelper | ||||||
|  |     { | ||||||
|  |         public ClientSecrets GetClientSecrets() | ||||||
|  |         { | ||||||
|  |             string clientId = config["Authentication:Google:ClientId"]!; | ||||||
|  |             string clientSecret = config["Authentication:Google:ClientSecret"]!; | ||||||
|  |  | ||||||
|  |             return new() { ClientId = clientId, ClientSecret = clientSecret }; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public string[] GetScopes() | ||||||
|  |         { | ||||||
|  |             var scopes = new[] | ||||||
|  |             { | ||||||
|  |                 Oauth2Service.Scope.Openid, | ||||||
|  |                 Oauth2Service.Scope.UserinfoEmail, | ||||||
|  |                 Oauth2Service.Scope.UserinfoProfile | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             return scopes; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public string ScopeToString() => string.Join(", ", GetScopes()); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										42
									
								
								Core.Thalos.BFF.Api/Services/IGoogleAuthorization.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Core.Thalos.BFF.Api/Services/IGoogleAuthorization.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | using Google.Apis.Auth.OAuth2; | ||||||
|  | using Google.Apis.Auth.OAuth2.Flows; | ||||||
|  |  | ||||||
|  | namespace Core.Thalos.BFF.Api.Services | ||||||
|  | { | ||||||
|  |     public interface IGoogleAuthorization | ||||||
|  |     { | ||||||
|  |         string GetAuthorizationUrl(); | ||||||
|  |         Task<UserCredential> ExchangeCodeForToken(string code); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public class GoogleAuthorizationService( | ||||||
|  |         IGoogleAuthHelper googleHelper, IConfiguration config) : IGoogleAuthorization | ||||||
|  |     { | ||||||
|  |         private string RedirectUrl = config["Authentication:Google:RedirectUri"]!; | ||||||
|  |  | ||||||
|  |         public async Task<UserCredential> ExchangeCodeForToken(string code) | ||||||
|  |         { | ||||||
|  |             var flow = new GoogleAuthorizationCodeFlow( | ||||||
|  |                 new GoogleAuthorizationCodeFlow.Initializer | ||||||
|  |                 { | ||||||
|  |                     ClientSecrets = googleHelper.GetClientSecrets(), | ||||||
|  |                     Scopes = googleHelper.GetScopes() | ||||||
|  |                 }); | ||||||
|  |  | ||||||
|  |             var token = await flow.ExchangeCodeForTokenAsync( | ||||||
|  |                 "user", code, RedirectUrl, CancellationToken.None); | ||||||
|  |  | ||||||
|  |             return new UserCredential(flow, "user", token); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public string GetAuthorizationUrl() => | ||||||
|  |             new GoogleAuthorizationCodeFlow( | ||||||
|  |                 new GoogleAuthorizationCodeFlow.Initializer | ||||||
|  |                 { | ||||||
|  |  | ||||||
|  |                     ClientSecrets = googleHelper.GetClientSecrets(), | ||||||
|  |                     Scopes = googleHelper.GetScopes(), | ||||||
|  |                     Prompt = "consent" | ||||||
|  |                 }).CreateAuthorizationCodeRequest(RedirectUrl).Build().ToString(); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										4
									
								
								Core.Thalos.BFF.Api/Services/Token.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								Core.Thalos.BFF.Api/Services/Token.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | namespace Core.Thalos.BFF.Api.Services | ||||||
|  | { | ||||||
|  |     public record Token(string IdToken); | ||||||
|  | } | ||||||
| @@ -8,18 +8,13 @@ | |||||||
|   "LocalGateways": { |   "LocalGateways": { | ||||||
|     "ThalosService": "https://localhost:7253/api" |     "ThalosService": "https://localhost:7253/api" | ||||||
|   }, |   }, | ||||||
|   "ServiceSettings": { |   "Authentication": { | ||||||
|     "ApplicationName": "thalos", |     "Google": { | ||||||
|     "LayerName": "bff" |       "ClientId": "128345072002-mtfdgpcur44o9tbd7q6e0bb9qnp2crfp.apps.googleusercontent.com", | ||||||
|   }, |       "ClientSecret": "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", | ||||||
|   "Vault": { |       "ApplicationName": "Thalos", | ||||||
|     "Address": "http://100.123.31.103:8200", |       "RedirectUri": "https://localhost:7239/api/v1/Authentication/callback" | ||||||
|     "Token": "hvs.e37LQvLuPhTd5ALS5QQ03Cwm", |     } | ||||||
|     "SecretMount": "secret" |  | ||||||
|   }, |  | ||||||
|   "IdentityProviders": { |  | ||||||
|     "Google": true, |  | ||||||
|     "Azure": true |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,6 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Contracts; | ||||||
|  | using Core.Thalos.Adapters.Handlers; | ||||||
|  | using Core.Thalos.Adapters.TokenProvider; | ||||||
| using Core.Thalos.External.GatewayConfigurations; | using Core.Thalos.External.GatewayConfigurations; | ||||||
| using LSA.Dashboard.External.Clients.Dashboard; | using LSA.Dashboard.External.Clients.Dashboard; | ||||||
| using Microsoft.AspNetCore.Http; | using Microsoft.AspNetCore.Http; | ||||||
|   | |||||||
| @@ -1,8 +1,7 @@ | |||||||
| using Core.Thalos.Application.UseCases.Roles.Input; | using Core.Thalos.Adapters; | ||||||
|  | using Core.Thalos.Application.UseCases.Roles.Input; | ||||||
| using Core.Thalos.Application.UseCases.Users.Input; | using Core.Thalos.Application.UseCases.Users.Input; | ||||||
| using Core.Thalos.BuildingBlocks; |  | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Permissions; | using Core.Thalos.External.Clients.Thalos.Requests.Permissions; | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Tenants; |  | ||||||
| using Core.Thalos.External.Clients.Thalos.Requests.Users; | using Core.Thalos.External.Clients.Thalos.Requests.Users; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
| using Refit; | using Refit; | ||||||
| @@ -32,9 +31,6 @@ namespace LSA.Dashboard.External.Clients.Dashboard | |||||||
|         [Put("/v1/User/Update")] |         [Put("/v1/User/Update")] | ||||||
|         Task<ApiResponse<UserAdapter>> UpdateUserService([Header("TrackingId")][Body] UpdateUserRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<UserAdapter>> UpdateUserService([Header("TrackingId")][Body] UpdateUserRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Delete("/v1/User/Delete")] |  | ||||||
|         Task<ApiResponse<UserAdapter>> DeleteUserByIdService([Header("TrackingId")][Body] DeleteUserRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Patch("/v1/User/LoginUser")] |         [Patch("/v1/User/LoginUser")] | ||||||
|         Task<ApiResponse<UserAdapter>> LoginUserService([Header("TrackingId")][Body] LoginUserRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<UserAdapter>> LoginUserService([Header("TrackingId")][Body] LoginUserRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
| @@ -44,6 +40,18 @@ namespace LSA.Dashboard.External.Clients.Dashboard | |||||||
|         [Patch("/v1/User/ChangeStatus")] |         [Patch("/v1/User/ChangeStatus")] | ||||||
|         Task<ApiResponse<UserAdapter>> ChangeUserStatusService([Header("TrackingId")][Body] ChangeUserStatusRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<UserAdapter>> ChangeUserStatusService([Header("TrackingId")][Body] ChangeUserStatusRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Post("/v1/User/AddCompany")] | ||||||
|  |         Task<ApiResponse<UserAdapter>> AddCompanyToUserService([Header("TrackingId")][Body] AddCompanyToUserRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Delete("/v1/User/RemoveCompany")] | ||||||
|  |         Task<ApiResponse<UserAdapter>> RemoveCompanyFromUserService([Header("TrackingId")][Body] RemoveCompanyFromUserRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Post("/v1/User/AddProject")] | ||||||
|  |         Task<ApiResponse<UserAdapter>> AddProjectToUserService([Header("TrackingId")][Body] AddProjectToUserRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|  |         [Delete("/v1/User/RemoveProject")] | ||||||
|  |         Task<ApiResponse<UserAdapter>> RemoveProjectFromUserService([Header("TrackingId")][Body] RemoveProjectFromUserRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Post("/v1/User/GetTokenAdapter")] |         [Post("/v1/User/GetTokenAdapter")] | ||||||
|         Task<ApiResponse<TokenAdapter>> GetTokenAdapterService([Header("TrackingId")][Body] GetTokenAdapterRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<TokenAdapter>> GetTokenAdapterService([Header("TrackingId")][Body] GetTokenAdapterRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
| @@ -65,9 +73,6 @@ namespace LSA.Dashboard.External.Clients.Dashboard | |||||||
|         [Patch("/v1/Role/ChangeStatus")] |         [Patch("/v1/Role/ChangeStatus")] | ||||||
|         Task<ApiResponse<RoleAdapter>> ChangeRoleStatusService([Header("TrackingId")][Body] ChangeRoleStatusRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<RoleAdapter>> ChangeRoleStatusService([Header("TrackingId")][Body] ChangeRoleStatusRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Delete("/v1/Role/Delete")] |  | ||||||
|         Task<ApiResponse<RoleAdapter>> DeleteRoleByIdService([Header("TrackingId")][Body] DeleteRoleRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Post("/v1/Role/AddApplication")] |         [Post("/v1/Role/AddApplication")] | ||||||
|         Task<ApiResponse<RoleAdapter>> AddApplicationToRoleService([Header("TrackingId")][Body] AddApplicationToRoleRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<RoleAdapter>> AddApplicationToRoleService([Header("TrackingId")][Body] AddApplicationToRoleRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
| @@ -92,9 +97,6 @@ namespace LSA.Dashboard.External.Clients.Dashboard | |||||||
|         [Patch("/v1/Permission/ChangeStatus")] |         [Patch("/v1/Permission/ChangeStatus")] | ||||||
|         Task<ApiResponse<PermissionAdapter>> ChangePermissionStatusService([Header("TrackingId")][Body] ChangePermissionStatusRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<PermissionAdapter>> ChangePermissionStatusService([Header("TrackingId")][Body] ChangePermissionStatusRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Delete("/v1/Permission/Delete")] |  | ||||||
|         Task<ApiResponse<PermissionAdapter>> DeletePermissionByIdService([Header("TrackingId")][Body] DeletePermissionRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Post("/v1/Module/Create")] |         [Post("/v1/Module/Create")] | ||||||
|         Task<ApiResponse<ModuleAdapter>> CreateModuleService([Header("TrackingId")][Body] CreateModuleRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<ModuleAdapter>> CreateModuleService([Header("TrackingId")][Body] CreateModuleRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
| @@ -112,27 +114,5 @@ namespace LSA.Dashboard.External.Clients.Dashboard | |||||||
|  |  | ||||||
|         [Patch("/v1/Module/ChangeStatus")] |         [Patch("/v1/Module/ChangeStatus")] | ||||||
|         Task<ApiResponse<ModuleAdapter>> ChangeModuleStatusService([Header("TrackingId")][Body] ChangeModuleStatusRequest request, CancellationToken cancellationToken = default); |         Task<ApiResponse<ModuleAdapter>> ChangeModuleStatusService([Header("TrackingId")][Body] ChangeModuleStatusRequest request, CancellationToken cancellationToken = default); | ||||||
|  |  | ||||||
|         [Delete("/v1/Module/Delete")] |  | ||||||
|         Task<ApiResponse<ModuleAdapter>> DeleteModuleByIdService([Header("TrackingId")][Body] DeleteModuleRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         [Post("/v1/Tenant/Create")] |  | ||||||
|         Task<ApiResponse<TenantAdapter>> CreateTenantService([Header("TrackingId")][Body] CreateTenantRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Post("/v1/Tenant/GetById")] |  | ||||||
|         Task<ApiResponse<TenantAdapter>> GetTenantByIdService([Header("TrackingId")][Body] GetTenantRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Get("/v1/Tenant/GetAll")] |  | ||||||
|         Task<ApiResponse<IEnumerable<TenantAdapter>>> GetAllTenantsService([Header("TrackingId")][Body] GetAllTenantsRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Put("/v1/Tenant/Update")] |  | ||||||
|         Task<ApiResponse<TenantAdapter>> UpdateTenantService([Header("TrackingId")][Body] UpdateTenantRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Patch("/v1/Tenant/ChangeStatus")] |  | ||||||
|         Task<ApiResponse<TenantAdapter>> ChangeTenantStatusService([Header("TrackingId")][Body] ChangeTenantStatusRequest request, CancellationToken cancellationToken = default); |  | ||||||
|  |  | ||||||
|         [Delete("/v1/Tenant/Delete")] |  | ||||||
|         Task<ApiResponse<UserAdapter>> DeleteTenantByIdService([Header("TrackingId")][Body] DeleteTenantRequest request, CancellationToken cancellationToken = default); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | |||||||
| { | { | ||||||
|     public class ChangeModuleStatusRequest |     public class ChangeModuleStatusRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Common.Enums; | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,7 +0,0 @@ | |||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions |  | ||||||
| { |  | ||||||
|     public class DeleteModuleRequest |  | ||||||
|     { |  | ||||||
|         public string _Id { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -2,6 +2,6 @@ | |||||||
| { | { | ||||||
|     public class GetModuleRequest |     public class GetModuleRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,11 +1,12 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Blueprint.Mongo; | ||||||
|  | using Core.Thalos.Adapters.Common.Enums; | ||||||
| using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||||
| { | { | ||||||
|     public class UpdateModuleRequest |     public class UpdateModuleRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } = null!; |         public string Id { get; set; } = null!; | ||||||
|         public string Name { get; set; } = null!; |         public string Name { get; set; } = null!; | ||||||
|         public string? Description { get; set; } |         public string? Description { get; set; } | ||||||
|         public string? Icon { get; set; } |         public string? Icon { get; set; } | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | |||||||
| { | { | ||||||
|     public class ChangePermissionStatusRequest |     public class ChangePermissionStatusRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Common.Constants; | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,7 +0,0 @@ | |||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions |  | ||||||
| { |  | ||||||
|     public class DeletePermissionRequest |  | ||||||
|     { |  | ||||||
|         public string _Id { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -2,6 +2,6 @@ | |||||||
| { | { | ||||||
|     public class GetPermissionRequest |     public class GetPermissionRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Common.Constants; | ||||||
| using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||||
| { | { | ||||||
|     public class UpdatePermissionRequest |     public class UpdatePermissionRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } = null!; |         public string Id { get; set; } = null!; | ||||||
|         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!; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Common.Enums; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | namespace Core.Thalos.Application.UseCases.Roles.Input | ||||||
| { | { | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | |||||||
| { | { | ||||||
|     public class ChangeRoleStatusRequest |     public class ChangeRoleStatusRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|  |  | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Common.Enums; | ||||||
| using System.Text.Json.Serialization; | using System.Text.Json.Serialization; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | namespace Core.Thalos.Application.UseCases.Roles.Input | ||||||
|   | |||||||
| @@ -1,7 +0,0 @@ | |||||||
| namespace Core.Thalos.Application.UseCases.Roles.Input |  | ||||||
| { |  | ||||||
|     public class DeleteRoleRequest |  | ||||||
|     { |  | ||||||
|         public string _Id { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -2,6 +2,6 @@ | |||||||
| { | { | ||||||
|     public class GetRoleRequest |     public class GetRoleRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Common.Enums; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | namespace Core.Thalos.Application.UseCases.Roles.Input | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| using Core.Thalos.BuildingBlocks; | using Core.Thalos.Adapters.Common.Enums; | ||||||
| using System.Text.Json.Serialization; | using System.Text.Json.Serialization; | ||||||
| using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | ||||||
|  |  | ||||||
| @@ -6,7 +6,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | |||||||
| { | { | ||||||
|     public class UpdateRoleRequest |     public class UpdateRoleRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } = null!; |         public string Id { get; set; } = null!; | ||||||
|         public string Name { get; set; } = null!; |         public string Name { get; set; } = null!; | ||||||
|         public string? Description { get; set; } |         public string? Description { get; set; } | ||||||
|         [JsonConverter(typeof(EnumArrayJsonConverter<ApplicationsEnum>))] |         [JsonConverter(typeof(EnumArrayJsonConverter<ApplicationsEnum>))] | ||||||
|   | |||||||
| @@ -1,10 +0,0 @@ | |||||||
| using Core.Blueprint.Mongo; |  | ||||||
|  |  | ||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants |  | ||||||
| { |  | ||||||
|     public class ChangeTenantStatusRequest |  | ||||||
|     { |  | ||||||
|         public string _Id { get; set; } |  | ||||||
|         public StatusEnum Status { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,31 +0,0 @@ | |||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants |  | ||||||
| { |  | ||||||
|     public class CreateTenantRequest |  | ||||||
|     { |  | ||||||
|         public string Name { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string TaxIdentifier { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string AddressLine1 { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string? AddressLine2 { get; set; } |  | ||||||
|  |  | ||||||
|         public string City { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string State { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string Country { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string PostalCode { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string ContactEmail { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string ContactPhone { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string? Website { get; set; } |  | ||||||
|  |  | ||||||
|         public string? ConnectionString { get; set; } |  | ||||||
|  |  | ||||||
|         public bool Isolated { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,7 +0,0 @@ | |||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants |  | ||||||
| { |  | ||||||
|     public class DeleteTenantRequest |  | ||||||
|     { |  | ||||||
|         public string _Id { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,6 +0,0 @@ | |||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants |  | ||||||
| { |  | ||||||
|     public class GetAllTenantsRequest |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,7 +0,0 @@ | |||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants |  | ||||||
| { |  | ||||||
|     public class GetTenantRequest |  | ||||||
|     { |  | ||||||
|         public string _Id { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,39 +0,0 @@ | |||||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants |  | ||||||
| { |  | ||||||
|     public class UpdateTenantRequest |  | ||||||
|     { |  | ||||||
|         public string Name { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string TaxIdentifier { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string AddressLine1 { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string? AddressLine2 { get; set; } |  | ||||||
|  |  | ||||||
|         public string City { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string State { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string Country { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string PostalCode { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string ContactEmail { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string ContactPhone { get; set; } = null!; |  | ||||||
|  |  | ||||||
|         public string? Website { get; set; } |  | ||||||
|  |  | ||||||
|         public string? ConnectionString { get; set; } |  | ||||||
|  |  | ||||||
|         public bool Isolated { get; set; } |  | ||||||
|         public string _Id { get; set; } = null!; |  | ||||||
|         public string Id { get; init; } = null!; |  | ||||||
|         public DateTime CreatedAt { get; set; } |  | ||||||
|         public string? CreatedBy { get; set; } |  | ||||||
|         public DateTime? UpdatedAt { get; set; } |  | ||||||
|         public string? UpdatedBy { get; set; } |  | ||||||
|  |  | ||||||
|         public Blueprint.Mongo.StatusEnum Status { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -0,0 +1,8 @@ | |||||||
|  | namespace Core.Thalos.Application.UseCases.Users.Input | ||||||
|  | { | ||||||
|  |     public class AddCompanyToUserRequest | ||||||
|  |     { | ||||||
|  |         public string UserId { get; set; } | ||||||
|  |         public string CompanyId { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,8 @@ | |||||||
|  | namespace Core.Thalos.Application.UseCases.Users.Input | ||||||
|  | { | ||||||
|  |     public class AddProjectToUserRequest | ||||||
|  |     { | ||||||
|  |         public string UserId { get; set; } | ||||||
|  |         public string ProjectId { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.Application.UseCases.Users.Input | |||||||
| { | { | ||||||
|     public class ChangeUserStatusRequest |     public class ChangeUserStatusRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|         public StatusEnum Status { get; set; } |         public StatusEnum Status { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,6 +7,8 @@ | |||||||
|         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; } | ||||||
|         public bool SendInvitation { get; set; } |         public bool SendInvitation { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,7 +0,0 @@ | |||||||
| namespace Core.Thalos.Application.UseCases.Users.Input |  | ||||||
| { |  | ||||||
|     public class DeleteUserRequest |  | ||||||
|     { |  | ||||||
|         public string _Id { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -2,6 +2,6 @@ | |||||||
| { | { | ||||||
|     public class GetUserRequest |     public class GetUserRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } |         public string Id { get; set; } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,8 @@ | |||||||
|  | namespace Core.Thalos.Application.UseCases.Users.Input | ||||||
|  | { | ||||||
|  |     public class RemoveCompanyFromUserRequest | ||||||
|  |     { | ||||||
|  |         public string UserId { get; set; } | ||||||
|  |         public string CompanyId { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,8 @@ | |||||||
|  | namespace Core.Thalos.Application.UseCases.Users.Input | ||||||
|  | { | ||||||
|  |     public class RemoveProjectFromUserRequest | ||||||
|  |     { | ||||||
|  |         public string UserId { get; set; } | ||||||
|  |         public string ProjectId { get; set; } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.Application.UseCases.Users.Input | |||||||
| { | { | ||||||
|     public class UpdateUserRequest |     public class UpdateUserRequest | ||||||
|     { |     { | ||||||
|         public string _Id { get; set; } = null!; |         public string Id { get; set; } = null!; | ||||||
|         public string Email { get; set; } = null!; |         public string Email { get; set; } = null!; | ||||||
|         public string Name { get; set; } = null!; |         public string Name { get; set; } = null!; | ||||||
|         public string? MiddleName { get; set; } |         public string? MiddleName { get; set; } | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.1.7" /> |     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.2" /> | ||||||
|     <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> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user