Compare commits
	
		
			15 Commits
		
	
	
		
			b3dec4a601
			...
			developmen
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a7aad12742 | |||
| 8c3f8f6402 | |||
| 739e9e9c85 | |||
| 927dedb357 | |||
| 8b2fa45fda | |||
| 9634b3f385 | |||
| f342ccdaff | |||
| 7769bf9e67 | |||
|   | 7e0fbc3b31 | ||
| 1c2272c6f3 | |||
| 2bab87fe8d | |||
| cd613cb5b8 | |||
| 39b415065a | |||
|   | 75962160af | ||
| 0f67d57bed | 
							
								
								
									
										17
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| **/bin/ | ||||
| **/obj/ | ||||
| **/.vs/ | ||||
| **/.idea/ | ||||
| **/.vscode/ | ||||
| **/*.user | ||||
| **/*.suo | ||||
| **/*.swp | ||||
| **/*.csproj.user | ||||
| **/*.log | ||||
| **/Properties/launchSettings.json | ||||
| **/appsettings.Local.json | ||||
| **/appsettings.*.Development.json | ||||
| .git/ | ||||
| .gitignore | ||||
| Dockerfile | ||||
| docker-compose*.yml | ||||
| @@ -7,6 +7,7 @@ | ||||
| using Asp.Versioning; | ||||
| using Core.Thalos.BuildingBlocks; | ||||
| using Core.Thalos.Provider.Contracts; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using ModuleRequest = Core.Thalos.Domain.Contexts.Onboarding.Request.ModuleRequest; | ||||
| using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | ||||
| @@ -21,7 +22,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|     [Produces(MimeTypes.ApplicationJson)] | ||||
|     [Consumes(MimeTypes.ApplicationJson)] | ||||
|     [ApiController] | ||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class ModuleController(IModuleProvider service) : ControllerBase | ||||
|     { | ||||
|         /// <summary> | ||||
| @@ -29,7 +30,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// </summary> | ||||
|         [HttpGet] | ||||
|         [ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)] | ||||
|         //[Permission("ModuleManagement.Read, RoleManagement.Read")] | ||||
|         [Permission("ModuleManagement.Read, RoleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllModulesAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetAllModules(cancellationToken); | ||||
| @@ -42,7 +43,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpPost] | ||||
|         [Route(Routes.GetModuleList)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)] | ||||
|         //[Permission("ModuleManagement.Read")] | ||||
|         [Permission("ModuleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllModulesByList([FromBody] string[] modules, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (modules == null || !modules.Any()) | ||||
| @@ -59,7 +60,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|         //[Permission("ModuleManagement.Read")] | ||||
|         [Permission("ModuleManagement.Read")] | ||||
|         public async Task<IActionResult> GetModuleByIdAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetModuleById(_id, cancellationToken); | ||||
| @@ -76,7 +77,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpPost] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status201Created)] | ||||
|         [ProducesResponseType(StatusCodes.Status422UnprocessableEntity)] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> CreateModuleAsync([FromBody] ModuleRequest newModule, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.CreateModule(newModule, cancellationToken); | ||||
| @@ -91,7 +92,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status422UnprocessableEntity)] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> UpdateModuleAsync([FromRoute] string _id, [FromBody] ModuleAdapter entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (_id != entity._Id) | ||||
| @@ -107,7 +108,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpPatch] | ||||
|         [Route(Routes.ChangeStatus)] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeModuleStatus([FromRoute] string _id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.ChangeModuleStatus(_id, newStatus, cancellationToken); | ||||
| @@ -131,7 +132,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteModuleAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.DeleteModule(_id, cancellationToken); | ||||
|   | ||||
| @@ -22,7 +22,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|     [Produces(MimeTypes.ApplicationJson)] | ||||
|     [Consumes(MimeTypes.ApplicationJson)] | ||||
|     [ApiController] | ||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class PermissionController(IPermissionProvider service) : ControllerBase | ||||
|     { | ||||
|         /// <summary> | ||||
| @@ -36,7 +36,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)] | ||||
|         //[Permission("PermissionManagement.Read, RoleManagement.Read")] | ||||
|         [Permission("PermissionManagement.Read, RoleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllPermissionsAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetAllPermissions(cancellationToken).ConfigureAwait(false); | ||||
| @@ -57,7 +57,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)] | ||||
|         //[Permission("PermissionManagement.Read")] | ||||
|         [Permission("PermissionManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllPermissionsByList([FromBody] string[] permissions, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (permissions == null || !permissions.Any()) | ||||
| @@ -83,7 +83,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("PermissionManagement.Read")] | ||||
|         [Permission("PermissionManagement.Read")] | ||||
|         public async Task<IActionResult> GetPermissionByIdAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetPermissionById(_id, cancellationToken).ConfigureAwait(false); | ||||
| @@ -107,7 +107,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <response code="500">Internal server error.</response> | ||||
|         [HttpPost] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status201Created)] | ||||
|         //[Permission("PermissionManagement.Write")] | ||||
|         [Permission("PermissionManagement.Write")] | ||||
|         public async Task<IActionResult> CreatePermissionAsync([FromBody] PermissionRequest newPermission, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.CreatePermission(newPermission, cancellationToken).ConfigureAwait(false); | ||||
| @@ -130,7 +130,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("PermissionManagement.Write")] | ||||
|         [Permission("PermissionManagement.Write")] | ||||
|         public async Task<IActionResult> UpdatePermissionAsync([FromRoute] string _id, [FromBody] PermissionAdapter entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (_id != entity._Id) | ||||
| @@ -157,7 +157,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("PermissionManagement.Write")] | ||||
|         [Permission("PermissionManagement.Write")] | ||||
|         public async Task<IActionResult> ChangePermissionStatus([FromRoute] string _id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.ChangePermissionStatus(_id, newStatus, cancellationToken).ConfigureAwait(false); | ||||
| @@ -180,7 +180,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpDelete] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("PermissionManagement.Write")] | ||||
|         [Permission("PermissionManagement.Write")] | ||||
|         public async Task<IActionResult> DeletePermissionAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.DeletePermission(_id, cancellationToken).ConfigureAwait(false); | ||||
|   | ||||
| @@ -22,7 +22,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|     [Produces(MimeTypes.ApplicationJson)] | ||||
|     [Consumes(MimeTypes.ApplicationJson)] | ||||
|     [ApiController] | ||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class RoleController(IRoleProvider service) : ControllerBase | ||||
|     { | ||||
|         /// <summary> | ||||
| @@ -34,7 +34,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <response code="500">The service internal error.</response> | ||||
|         [HttpGet] | ||||
|         [ProducesResponseType(typeof(IEnumerable<RoleAdapter>), StatusCodes.Status200OK)] | ||||
|         //[Permission("RoleManagement.Read")] | ||||
|         [Permission("RoleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllRolesAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetAllRoles(cancellationToken).ConfigureAwait(false); | ||||
| @@ -53,7 +53,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpGet] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("RoleManagement.Read")] | ||||
|         [Permission("RoleManagement.Read")] | ||||
|         public async Task<IActionResult> GetRoleByIdAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetRoleById(_id, cancellationToken).ConfigureAwait(false); | ||||
| @@ -77,7 +77,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <response code="500">The service internal error.</response> | ||||
|         [HttpPost] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status201Created)] | ||||
|         //[Permission("RoleManagement.Write")] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> CreateRoleAsync([FromBody] RoleRequest newRole, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.CreateRole(newRole, cancellationToken).ConfigureAwait(false); | ||||
| @@ -98,7 +98,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpPut] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("RoleManagement.Write")] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> UpdateRoleAsync([FromRoute] string _id, [FromBody] RoleAdapter entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (_id != entity._Id) | ||||
| @@ -122,7 +122,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpPatch] | ||||
|         [Route(Routes.ChangeStatus)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("RoleManagement.Write")] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeRoleStatus([FromRoute] string _id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.ChangeRoleStatus(_id, newStatus, cancellationToken).ConfigureAwait(false); | ||||
| @@ -144,7 +144,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <response code="500">The service internal error.</response> | ||||
|         [HttpPost(Routes.AddApplication)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("RoleManagement.Write")] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> AddApplicationToRoleAsync([FromRoute] string roleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.AddApplicationToRole(roleId, application, cancellationToken).ConfigureAwait(false); | ||||
| @@ -162,7 +162,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <response code="500">The service internal error.</response> | ||||
|         [HttpDelete(Routes.RemoveApplication)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("RoleManagement.Write")] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> RemoveApplicationFromRoleAsync([FromRoute] string roleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.RemoveApplicationFromRole(roleId, application, cancellationToken).ConfigureAwait(false); | ||||
| @@ -181,7 +181,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpDelete] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("RoleManagement.Write")] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteRoleAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.DeleteRole(_id, cancellationToken).ConfigureAwait(false); | ||||
|   | ||||
| @@ -22,7 +22,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|     [Produces(MimeTypes.ApplicationJson)] | ||||
|     [Consumes(MimeTypes.ApplicationJson)] | ||||
|     [ApiController] | ||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class TenantController(ITenantProvider service) : ControllerBase | ||||
|     { | ||||
|         /// <summary> | ||||
| @@ -36,7 +36,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<TenantAdapter>), StatusCodes.Status200OK)] | ||||
|         //[Permission("TenantManagement.Read, RoleManagement.Read")] | ||||
|         [Permission("TenantManagement.Read, RoleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllTenantsAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetAllTenants(cancellationToken).ConfigureAwait(false); | ||||
| @@ -57,7 +57,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("TenantManagement.Read")] | ||||
|         [Permission("TenantManagement.Read")] | ||||
|         public async Task<IActionResult> GetTenantByIdAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetTenantById(_id, cancellationToken).ConfigureAwait(false); | ||||
| @@ -81,7 +81,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <response code="500">The service internal error.</response> | ||||
|         [HttpPost] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status201Created)] | ||||
|         //[Permission("TenantManagement.Write")] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> CreateTenantAsync([FromBody] TenantRequest newTenant, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.CreateTenant(newTenant, cancellationToken).ConfigureAwait(false); | ||||
| @@ -104,7 +104,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("TenantManagement.Write")] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> UpdateTenantAsync([FromRoute] string _id, [FromBody] TenantAdapter entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (_id != entity._Id) | ||||
| @@ -132,7 +132,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [Consumes(MimeTypes.ApplicationJson)] | ||||
|         [Produces(MimeTypes.ApplicationJson)] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("TenantManagement.Write")] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeTenantStatus([FromRoute] string _id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.ChangeTenantStatus(_id, newStatus, cancellationToken).ConfigureAwait(false); | ||||
| @@ -155,7 +155,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpDelete] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         //[Permission("TenantManagement.Write")] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteTenantAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.DeleteTenant(_id, cancellationToken).ConfigureAwait(false); | ||||
|   | ||||
| @@ -31,8 +31,8 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <returns>The <see cref="IEnumerable{UserAdapter}"/> found entity.</returns> | ||||
|         [HttpGet] | ||||
|         [ProducesResponseType(typeof(IEnumerable<UserAdapter>), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("UserManagement.Read")] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllUsers(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetAllUsers(cancellationToken).ConfigureAwait(false); | ||||
| @@ -48,8 +48,8 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpGet] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("UserManagement.Read")] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Read")] | ||||
|         public async Task<IActionResult> GetUserById([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetUserById(_id, cancellationToken).ConfigureAwait(false); | ||||
| @@ -65,7 +65,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpGet] | ||||
|         [Route(Routes.Email)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         [Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         public async Task<IActionResult> GetUserByEmail([FromRoute] string email, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.GetUserByEmail(email, cancellationToken).ConfigureAwait(false); | ||||
| @@ -96,8 +96,8 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <returns>The <see cref="UserAdapter"/> created entity.</returns> | ||||
|         [HttpPost(Routes.Register)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status201Created)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("UserManagement.Write")] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> CreateUserAsync([FromBody] UserRequest newUser, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.CreateUser(newUser, cancellationToken).ConfigureAwait(false); | ||||
| @@ -114,8 +114,8 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpPut] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("UserManagement.Write")] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> UpdateUserAsync([FromRoute] string _id, [FromBody] UserAdapter entity, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (_id != entity._Id) | ||||
| @@ -133,7 +133,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <returns>The <see cref="UserAdapter"/> found entity.</returns> | ||||
|         [HttpPatch(Routes.LogIn)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         [Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         public async Task<IActionResult> LoginUserAsync([FromRoute] string email, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.LogInUser(email, cancellationToken).ConfigureAwait(false); | ||||
| @@ -148,7 +148,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         /// <returns>The <see cref="UserAdapter"/> updated entity.</returns> | ||||
|         [HttpPatch(Routes.LogOut)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         [Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         public async Task<IActionResult> LogOutUserSessionAsync([FromRoute] string email, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.LogOutUserSession(email, cancellationToken).ConfigureAwait(false); | ||||
| @@ -165,8 +165,8 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpPatch] | ||||
|         [Route(Routes.ChangeStatus)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("UserManagement.Write")] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeUserStatus([FromRoute] string _id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.ChangeUserStatus(_id, newStatus, cancellationToken).ConfigureAwait(false); | ||||
| @@ -186,7 +186,7 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpGet] | ||||
|         [Route("{email}/GetTokenAdapter")] | ||||
|         [ProducesResponseType(typeof(TokenAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         [Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")] | ||||
|         public async Task<IActionResult> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var tokenAdapter = await service.GetToken(email, cancellationToken).ConfigureAwait(false); | ||||
| @@ -204,8 +204,8 @@ namespace LSA.Core.Thalos.API.Controllers | ||||
|         [HttpDelete] | ||||
|         [Route(Routes.Id)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Permission("UserManagement.Write")] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteUserAsync([FromRoute] string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var result = await service.DeleteUser(_id, cancellationToken).ConfigureAwait(false); | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.1" /> | ||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|   | ||||
| @@ -0,0 +1,31 @@ | ||||
| using Microsoft.Extensions.Diagnostics.HealthChecks; | ||||
| using MongoDB.Bson; | ||||
| using MongoDB.Driver; | ||||
|  | ||||
| namespace Core.Thalos.DAL.API.HealthCheck | ||||
| { | ||||
|     public class MongoConnectionHealthCheck(string connectionString, string databaseName) : IHealthCheck | ||||
|     { | ||||
|  | ||||
|         public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) | ||||
|         { | ||||
|             var settings = MongoClientSettings.FromConnectionString(connectionString); | ||||
|  | ||||
|             try | ||||
|             { | ||||
|                 var mongoClient = new MongoClient(settings); | ||||
|  | ||||
|                 var database = mongoClient.GetDatabase(databaseName); | ||||
|                 var command = new BsonDocument("ping", 1); | ||||
|  | ||||
|                 await database.RunCommandAsync<BsonDocument>(command); | ||||
|  | ||||
|                 return HealthCheckResult.Healthy($"MongoDB is healthy, {databaseName} database from {settings.Server} is reachable."); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 return HealthCheckResult.Degraded($"MongoDB is Degraded, {databaseName} database from {settings?.Server?.Host} is unreachable.", ex); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,30 @@ | ||||
| using Microsoft.Extensions.Diagnostics.HealthChecks; | ||||
| using StackExchange.Redis; | ||||
|  | ||||
| public sealed class RedisConnectionHealthCheck : IHealthCheck | ||||
| { | ||||
|     private readonly string _connectionString; | ||||
|     public RedisConnectionHealthCheck(string connectionString) => _connectionString = connectionString; | ||||
|  | ||||
|     public async Task<HealthCheckResult> CheckHealthAsync( | ||||
|         HealthCheckContext context, | ||||
|         CancellationToken cancellationToken = default) | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             var options = ConfigurationOptions.Parse(_connectionString); | ||||
|             options.AbortOnConnectFail = false; | ||||
|             options.ConnectTimeout = 2000;   // optional, be snappy | ||||
|  | ||||
|             using var mux = await ConnectionMultiplexer.ConnectAsync(options); | ||||
|             if (!mux.IsConnected) return HealthCheckResult.Unhealthy("Redis not connected."); | ||||
|  | ||||
|             var ping = await mux.GetDatabase().PingAsync(); | ||||
|             return HealthCheckResult.Healthy($"Redis OK (ping {ping.TotalMilliseconds:N0} ms)"); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             return HealthCheckResult.Unhealthy("Redis check failed.", ex); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,50 @@ | ||||
| using Microsoft.Extensions.Diagnostics.HealthChecks; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Core.Thalos.DAL.API.HealthCheck.Writer | ||||
| { | ||||
|     public static class HealthCheckResponseWriter | ||||
|     { | ||||
|         public static Task WriteResponse(HttpContext context, HealthReport result) | ||||
|         { | ||||
|             context.Response.ContentType = "application/json"; | ||||
|  | ||||
|             context.Response.StatusCode = result.Status switch | ||||
|             { | ||||
|                 HealthStatus.Healthy => StatusCodes.Status200OK, | ||||
|                 HealthStatus.Degraded => StatusCodes.Status500InternalServerError, | ||||
|                 HealthStatus.Unhealthy => StatusCodes.Status503ServiceUnavailable, | ||||
|                 _ => StatusCodes.Status500InternalServerError | ||||
|             }; | ||||
|  | ||||
|             var options = new JsonSerializerOptions | ||||
|             { | ||||
|                 WriteIndented = true, | ||||
|                 PropertyNamingPolicy = JsonNamingPolicy.CamelCase | ||||
|             }; | ||||
|  | ||||
|             var json = new | ||||
|             { | ||||
|                 status = result.Status.ToString(), | ||||
|                 services = result.Entries.Select(e => new | ||||
|                 { | ||||
|                     key = e.Key, | ||||
|                     status = e.Value.Status.ToString(), | ||||
|                     description = e.Value.Description ?? string.Empty, | ||||
|                     exception = e.Value.Exception?.Message, | ||||
|                     duration = e.Value.Duration.ToString(), | ||||
|  | ||||
|                     statusCode = e.Value.Status switch | ||||
|                     { | ||||
|                         HealthStatus.Healthy => StatusCodes.Status200OK, | ||||
|                         HealthStatus.Degraded => StatusCodes.Status500InternalServerError, | ||||
|                         HealthStatus.Unhealthy => StatusCodes.Status503ServiceUnavailable, | ||||
|                         _ => StatusCodes.Status500InternalServerError | ||||
|                     } | ||||
|                 }) | ||||
|             }; | ||||
|  | ||||
|             return context.Response.WriteAsync(JsonSerializer.Serialize(json, options)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -4,8 +4,12 @@ using Core.Blueprint.Logging.Configuration; | ||||
| using Core.Blueprint.Redis.Configuration; | ||||
| using Core.Thalos.BuildingBlocks; | ||||
| using Core.Thalos.BuildingBlocks.Configuration; | ||||
| using Core.Thalos.DAL.API.HealthCheck; | ||||
| using Core.Thalos.DAL.API.HealthCheck.Writer; | ||||
| using Core.Thalos.Provider; | ||||
| using Microsoft.AspNetCore.Diagnostics.HealthChecks; | ||||
| using Microsoft.AspNetCore.HttpLogging; | ||||
| using Microsoft.Extensions.Diagnostics.HealthChecks; | ||||
| using System.Reflection; | ||||
| using System.Text.Json.Serialization; | ||||
|  | ||||
| @@ -64,6 +68,21 @@ builder.Host.ConfigureServices((context, services) => | ||||
|     }); | ||||
| }); | ||||
|  | ||||
| // Add health checks | ||||
| builder.Services.AddHealthChecks() | ||||
|     .AddCheck( | ||||
|         "mongodb", | ||||
|         new MongoConnectionHealthCheck( | ||||
|             connectionString: builder.Configuration.GetConnectionString("MongoDB")!, | ||||
|             databaseName: builder.Configuration.GetSection("MongoDb:DatabaseName").Value!), | ||||
|         failureStatus: HealthStatus.Unhealthy, | ||||
|         tags: new[] { "db", "mongo" }) | ||||
|     .AddCheck( | ||||
|         "redis", | ||||
|         new RedisConnectionHealthCheck(builder.Configuration.GetConnectionString("Redis")!), | ||||
|         failureStatus: HealthStatus.Unhealthy, | ||||
|         tags: new[] { "db", "redis" }); | ||||
|  | ||||
| var app = builder.Build(); | ||||
|  | ||||
| app.UseLogging(builder.Configuration); | ||||
| @@ -82,6 +101,10 @@ app.UseAuthentication(); | ||||
| app.UseAuthorization(); | ||||
|  | ||||
| app.MapControllers(); | ||||
| app.MapHealthChecks("/health"); | ||||
| app.MapHealthChecks("/health", new HealthCheckOptions | ||||
| { | ||||
|     ResponseWriter = HealthCheckResponseWriter.WriteResponse, | ||||
|     AllowCachingResponses = false | ||||
| }); | ||||
|  | ||||
| app.Run(); | ||||
| @@ -24,7 +24,7 @@ | ||||
|       "dotnetRunMessages": true, | ||||
|       "launchBrowser": true, | ||||
|       "launchUrl": "swagger", | ||||
|       "applicationUrl": "https://localhost:7031;http://localhost:5211", | ||||
|       "applicationUrl": "https://localhost:44359;http://localhost:5211", | ||||
|       "environmentVariables": { | ||||
|         "ASPNETCORE_ENVIRONMENT": "Local" | ||||
|       } | ||||
|   | ||||
| @@ -7,15 +7,16 @@ | ||||
|   }, | ||||
|   "AllowedHosts": "*", | ||||
|   "ConnectionStrings": { | ||||
|     "MongoDB": "mongodb://admin_agile:Admin%40agileWebs@portainer.white-enciso.pro:27017/?authMechanism=SCRAM-SHA-256", | ||||
|     "Redis": "100.123.31.103:6379" | ||||
|     "MongoDB": "mongodb://admin_agile:AdminAgileWebs@portainer.dream-views.com:27017/?authMechanism=SCRAM-SHA-256", | ||||
|     //"MongoDB": "mongodb://admin_agile:Admin%40agileWebs@portainer.white-enciso.pro:27017/?authMechanism=SCRAM-SHA-256", | ||||
|     "Redis": "172.22.0.2:6379" | ||||
|   }, | ||||
|   "MongoDb": { | ||||
|     "DatabaseName": "Thalos", | ||||
|     "LocalAudience": "" | ||||
|   }, | ||||
|   "DetailedErrors": true, | ||||
|   "UseRedisCache": true, | ||||
|   "UseRedisCache": false, | ||||
|   "CacheSettings": { | ||||
|     "DefaultCacheDurationInMinutes": 3 | ||||
|   }, | ||||
| @@ -24,12 +25,12 @@ | ||||
|     "LayerName": "dal" | ||||
|   }, | ||||
|   "Vault": { | ||||
|     "Address": "http://100.123.31.103:8200", | ||||
|     "Token": "hvs.e37LQvLuPhTd5ALS5QQ03Cwm", | ||||
|     "SecretMount": "secret" | ||||
|     "Address": "https://vault.dream-views.com/", | ||||
|     "Token": "hvs.TGz6P3AsKpYuODMrs11Msiza", | ||||
|     "SecretMount": "thalos" | ||||
|   }, | ||||
|   "IdentityProviders": { | ||||
|     "Google": true, | ||||
|     "Azure":  true | ||||
|     "Azure": false | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -54,5 +54,13 @@ namespace Core.Thalos.Domain.Contexts.Onboarding.Request | ||||
|         [BsonRepresentation(BsonType.ObjectId)] | ||||
|         [JsonPropertyName("roleId")] | ||||
|         public string RoleId { get; set; } = null!; | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets or sets the tenant ID of the user. | ||||
|         /// </summary> | ||||
|         [BsonElement("tenantId")] | ||||
|         [BsonRepresentation(BsonType.ObjectId)] | ||||
|         [JsonPropertyName("tenantId")] | ||||
|         public string TenantId { get; set; } = null!; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -7,8 +7,8 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Core.Blueprint.KeyVault" Version="1.0.3" /> | ||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.1.7" /> | ||||
|     <PackageReference Include="Core.Blueprint.KeyVault" Version="1.0.0" /> | ||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.5" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
| </Project> | ||||
|   | ||||
| @@ -11,8 +11,8 @@ | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Core.Blueprint.Mongo" Version="1.0.1" /> | ||||
|     <PackageReference Include="Core.Blueprint.Redis" Version="1.0.2" /> | ||||
|     <PackageReference Include="Core.Blueprint.Mongo" Version="1.0.0" /> | ||||
|     <PackageReference Include="Core.Blueprint.Redis" Version="1.0.0" /> | ||||
|     <PackageReference Include="Mapster" Version="7.4.2-pre02" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   | ||||
| @@ -82,7 +82,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllUsers"); | ||||
|             var cachedData = await cacheProvider.GetAsync<IEnumerable<UserAdapter>>(cacheKey) ?? []; | ||||
|  | ||||
|             //if (cachedData.Any()) return cachedData; | ||||
|             if (cachedData.Any()) return cachedData; | ||||
|  | ||||
|             var users = await repository.AsQueryable(); | ||||
|  | ||||
| @@ -231,7 +231,6 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                 }, | ||||
|                 { "status", Core.Blueprint.Mongo.StatusEnum.Active.ToString() } | ||||
|             }), | ||||
|  | ||||
|             new BsonDocument("$lookup", new BsonDocument | ||||
|             { | ||||
|                 { "from", "Roles" }, | ||||
| @@ -239,11 +238,8 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                 { "foreignField", "_id" }, | ||||
|                 { "as", "role" } | ||||
|             }), | ||||
|  | ||||
|             new BsonDocument("$unwind", "$role"), | ||||
|             new BsonDocument("$match", new BsonDocument("role.status", Core.Blueprint.Mongo.StatusEnum.Active.ToString())), | ||||
|  | ||||
|                     // Tenant lookup | ||||
|             new BsonDocument("$lookup", new BsonDocument | ||||
|             { | ||||
|                 { "from", "Tenants" }, | ||||
| @@ -252,7 +248,6 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                 { "as", "tenant" } | ||||
|             }), | ||||
|             new BsonDocument("$unwind", "$tenant"), | ||||
|  | ||||
|             new BsonDocument("$addFields", new BsonDocument | ||||
|             { | ||||
|                 { "role.permissions", new BsonDocument("$map", new BsonDocument | ||||
| @@ -270,7 +265,6 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                     }) | ||||
|                 } | ||||
|             }), | ||||
|  | ||||
|             new BsonDocument("$lookup", new BsonDocument | ||||
|             { | ||||
|                 { "from", "Permissions" }, | ||||
| @@ -343,6 +337,12 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|  | ||||
|                 if (result is null) return null; | ||||
|  | ||||
|                 DateTime SafeToUtc(BsonValue value) | ||||
|                 { | ||||
|                     if (value == null || value.IsBsonNull) return DateTime.MinValue; | ||||
|                     return value.IsBsonDateTime ? value.ToUniversalTime() : DateTime.MinValue; | ||||
|                 } | ||||
|  | ||||
|                 var tokenAdapter = new TokenAdapter | ||||
|                 { | ||||
|                     User = new UserAdapter | ||||
| @@ -354,11 +354,11 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                         LastName = result.Contains("lastName") && !result["lastName"].IsBsonNull ? result["lastName"].AsString : string.Empty, | ||||
|                         DisplayName = result.Contains("displayName") && !result["displayName"].IsBsonNull ? result["displayName"].AsString : string.Empty, | ||||
|                         RoleId = result.Contains("roleId") && !result["roleId"].IsBsonNull ? result["roleId"].ToString() : string.Empty, | ||||
|                         LastLogIn = result.Contains("lastLogIn") && !result["lastLogIn"].IsBsonNull ? result["lastLogIn"].ToUniversalTime() : DateTime.MinValue, | ||||
|                         LastLogOut = result.Contains("lastLogOut") && !result["lastLogOut"].IsBsonNull ? result["lastLogOut"].ToUniversalTime() : DateTime.MinValue, | ||||
|                         CreatedAt = result.Contains("createdAt") && !result["createdAt"].IsBsonNull ? result["createdAt"].ToUniversalTime() : DateTime.MinValue, | ||||
|                         LastLogIn = SafeToUtc(result.Contains("lastLogIn") ? result["lastLogIn"] : null), | ||||
|                         LastLogOut = SafeToUtc(result.Contains("lastLogOut") ? result["lastLogOut"] : null), | ||||
|                         CreatedAt = SafeToUtc(result.Contains("createdAt") ? result["createdAt"] : null), | ||||
|                         UpdatedAt = SafeToUtc(result.Contains("updatedAt") ? result["updatedAt"] : null), | ||||
|                         CreatedBy = result.Contains("createdBy") && !result["createdBy"].IsBsonNull ? result["createdBy"].AsString : string.Empty, | ||||
|                         UpdatedAt = result.Contains("updatedAt") && !result["updatedAt"].IsBsonNull ? result["updatedAt"].ToUniversalTime() : DateTime.MinValue, | ||||
|                         UpdatedBy = result.Contains("updatedBy") && !result["updatedBy"].IsBsonNull ? result["updatedBy"].AsString : string.Empty, | ||||
|                         Status = result.Contains("status") && !result["status"].IsBsonNull | ||||
|                             ? (Core.Blueprint.Mongo.StatusEnum)Enum.Parse(typeof(Core.Blueprint.Mongo.StatusEnum), result["status"].AsString) | ||||
| @@ -404,24 +404,18 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                              !result["role"]["status"].IsBsonNull | ||||
|                             ? (Core.Blueprint.Mongo.StatusEnum)Enum.Parse(typeof(Core.Blueprint.Mongo.StatusEnum), result["role"]["status"].AsString) | ||||
|                             : Core.Blueprint.Mongo.StatusEnum.Inactive, | ||||
|                         CreatedAt = result.Contains("role") && result["role"].IsBsonDocument && | ||||
|                             result["role"].AsBsonDocument.Contains("createdAt") && | ||||
|                             !result["role"]["createdAt"].IsBsonNull | ||||
|                             ? result["role"]["createdAt"].ToUniversalTime() | ||||
|                             : DateTime.MinValue, | ||||
|                         UpdatedAt = result.Contains("role") && result["role"].IsBsonDocument && | ||||
|                             result["role"].AsBsonDocument.Contains("updatedAt") && | ||||
|                             !result["role"]["updatedAt"].IsBsonNull | ||||
|                             ? result["role"]["updatedAt"].ToUniversalTime() | ||||
|                             : DateTime.MinValue, | ||||
|                         CreatedAt = SafeToUtc(result.Contains("role") && result["role"].IsBsonDocument && result["role"].AsBsonDocument.Contains("createdAt") | ||||
|                             ? result["role"]["createdAt"] | ||||
|                             : null), | ||||
|                         UpdatedAt = SafeToUtc(result.Contains("role") && result["role"].IsBsonDocument && result["role"].AsBsonDocument.Contains("updatedAt") | ||||
|                             ? result["role"]["updatedAt"] | ||||
|                             : null), | ||||
|                         CreatedBy = result.Contains("role") && result["role"].IsBsonDocument && | ||||
|                             result["role"].AsBsonDocument.Contains("createdBy") && | ||||
|                             !result["role"]["createdBy"].IsBsonNull | ||||
|                             result["role"].AsBsonDocument.Contains("createdBy") && !result["role"]["createdBy"].IsBsonNull | ||||
|                             ? result["role"]["createdBy"].AsString | ||||
|                             : string.Empty, | ||||
|                         UpdatedBy = result.Contains("role") && result["role"].IsBsonDocument && | ||||
|                             result["role"].AsBsonDocument.Contains("updatedBy") && | ||||
|                             !result["role"]["updatedBy"].IsBsonNull | ||||
|                             result["role"].AsBsonDocument.Contains("updatedBy") && !result["role"]["updatedBy"].IsBsonNull | ||||
|                             ? result["role"]["updatedBy"].AsString | ||||
|                             : string.Empty | ||||
|                     }, | ||||
| @@ -470,12 +464,12 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                         Isolated = result["tenant"].AsBsonDocument.Contains("isolated") && !result["tenant"]["isolated"].IsBsonNull | ||||
|                             ? result["tenant"]["isolated"].ToBoolean() | ||||
|                             : false, | ||||
|                         CreatedAt = result["tenant"].AsBsonDocument.Contains("createdAt") && !result["tenant"]["createdAt"].IsBsonNull | ||||
|                             ? result["tenant"]["createdAt"].ToUniversalTime() | ||||
|                             : DateTime.MinValue, | ||||
|                         UpdatedAt = result["tenant"].AsBsonDocument.Contains("updatedAt") && !result["tenant"]["updatedAt"].IsBsonNull | ||||
|                             ? result["tenant"]["updatedAt"].ToUniversalTime() | ||||
|                             : DateTime.MinValue, | ||||
|                         CreatedAt = SafeToUtc(result.Contains("tenant") && result["tenant"].IsBsonDocument && result["tenant"].AsBsonDocument.Contains("createdAt") | ||||
|                             ? result["tenant"]["createdAt"] | ||||
|                             : null), | ||||
|                         UpdatedAt = SafeToUtc(result.Contains("tenant") && result["tenant"].IsBsonDocument && result["tenant"].AsBsonDocument.Contains("updatedAt") | ||||
|                             ? result["tenant"]["updatedAt"] | ||||
|                             : null), | ||||
|                         CreatedBy = result["tenant"].AsBsonDocument.Contains("createdBy") && !result["tenant"]["createdBy"].IsBsonNull | ||||
|                             ? result["tenant"]["createdBy"].AsString | ||||
|                             : string.Empty, | ||||
| @@ -503,9 +497,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                     : new List<ModuleAdapter>() | ||||
|                 }; | ||||
|  | ||||
|  | ||||
|                 return tokenAdapter; | ||||
|  | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
| @@ -513,6 +505,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes an User by _id. | ||||
|         /// </summary> | ||||
|   | ||||
							
								
								
									
										40
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| # ============ Build ============ | ||||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||||
| WORKDIR /src | ||||
|  | ||||
| # Copia opcional del nuget.config si existe en el root | ||||
| COPY nuget.config* ./ | ||||
|  | ||||
| # Copiamos csprojs primero para aprovechar caché de restore | ||||
| COPY Core.Thalos.Domain/Core.Thalos.Domain.csproj Core.Thalos.Domain/ | ||||
| COPY Core.Thalos.Provider/Core.Thalos.Provider.csproj Core.Thalos.Provider/ | ||||
| COPY Core.Thalos.Infraestructure/Core.Thalos.Infrastructure.csproj Core.Thalos.Infraestructure/ | ||||
| COPY Core.Thalos.DAL.API/Core.Thalos.DAL.API.csproj Core.Thalos.DAL.API/ | ||||
|  | ||||
| RUN dotnet restore Core.Thalos.DAL.API/Core.Thalos.DAL.API.csproj | ||||
|  | ||||
| # Copiamos el resto y compilamos | ||||
| COPY . . | ||||
| RUN dotnet build Core.Thalos.DAL.API/Core.Thalos.DAL.API.csproj -c Release -o /app/build | ||||
|  | ||||
| # ============ Publish ============ | ||||
| FROM build AS publish | ||||
| RUN dotnet publish Core.Thalos.DAL.API/Core.Thalos.DAL.API.csproj -c Release -o /app/publish \ | ||||
|     --no-restore | ||||
|  | ||||
| # ============ Runtime ============ | ||||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final | ||||
| # (Opcional) instalar curl para healthcheck HTTP | ||||
| RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/* | ||||
|  | ||||
| WORKDIR /app | ||||
| EXPOSE 8080 | ||||
| # Usuario no-root | ||||
| RUN useradd -m appuser | ||||
| USER appuser | ||||
|  | ||||
| ENV ASPNETCORE_URLS=http://+:8080 | ||||
| # Usa env vars y/o UserSecrets; no guardes tokens en la imagen.  :contentReference[oaicite:4]{index=4} | ||||
|  | ||||
| COPY --from=publish /app/publish ./ | ||||
| ENTRYPOINT ["dotnet", "Core.Thalos.DAL.API.dll"] | ||||
							
								
								
									
										9
									
								
								nuget.config
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								nuget.config
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <configuration> | ||||
|   <packageSources> | ||||
|     <!-- Tu BaGet primero --> | ||||
|     <add key="BaGet" value="https://nuget.dream-views.com/v3/index.json" protocolVersion="3" /> | ||||
|     <!-- NuGet oficial como fallback (si quieres) --> | ||||
|     <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | ||||
|   </packageSources> | ||||
| </configuration> | ||||
		Reference in New Issue
	
	Block a user