Adapt endpoints and configuration
This commit is contained in:
		| @@ -81,7 +81,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [HttpGet] | ||||
|         [Route(Routes.RefreshToken)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         public async Task<IActionResult> RefreshCustomTokenAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var tokenAdapter = new TokenAdapter(); | ||||
|   | ||||
| @@ -19,7 +19,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     [Consumes("application/json")] | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class ModuleController(IThalosServiceClient thalosServiceClient, ILogger<ModuleController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
| @@ -32,7 +32,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("ModuleManagement.Read, RoleManagement.Read")] | ||||
|         //[Permission("ModuleManagement.Read, RoleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllModulesService(CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
| @@ -65,7 +65,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("ModuleManagement.Read")] | ||||
|         //[Permission("ModuleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
| @@ -98,7 +98,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> CreateModuleService(CreateModuleRequest newModule, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
| @@ -132,7 +132,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("ModuleManagement.Read")] | ||||
|         //[Permission("ModuleManagement.Read")] | ||||
|         public async Task<IActionResult> GetModuleByIdService(GetModuleRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
| @@ -160,7 +160,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> UpdateModuleService(UpdateModuleRequest newModule, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
| @@ -196,7 +196,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         //[Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeModuleStatusService([FromBody] ChangeModuleStatusRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|   | ||||
| @@ -20,7 +20,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     [Consumes("application/json")] | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class PermissionController(IThalosServiceClient thalosServiceClient, ILogger<PermissionController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|   | ||||
| @@ -18,7 +18,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     [Consumes("application/json")] | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class RoleController(IThalosServiceClient thalosServiceClient, ILogger<RoleController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|   | ||||
| @@ -31,7 +31,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllUsersService(CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -58,7 +58,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> CreateUserService(CreateUserRequest newUser, CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -97,7 +97,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Read")] | ||||
|         public async Task<IActionResult> GetUserByIdService(GetUserRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -126,7 +126,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Read")] | ||||
|         public async Task<IActionResult> GetUserByEmailService(GetUserByEmailRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -155,7 +155,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> UpdateUserService(UpdateUserRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -252,7 +252,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeUserStatusService([FromBody] ChangeUserStatusRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -283,7 +283,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> AddCompanyToUserService([FromBody] AddCompanyToUserRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -315,7 +315,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> RemoveCompanyFromUserService([FromBody] RemoveCompanyFromUserRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
| @@ -347,7 +347,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|  | ||||
|         public async Task<IActionResult> AddProjectToUserService([FromBody] AddProjectToUserRequest request, CancellationToken cancellationToken) | ||||
| @@ -380,7 +380,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> RemoveProjectFromUserService([FromBody] RemoveProjectFromUserRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|   | ||||
| @@ -7,6 +7,11 @@ | ||||
|     <GenerateDocumentationFile>True</GenerateDocumentationFile> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" /> | ||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\Core.Thalos.External\Core.Thalos.External.csproj" /> | ||||
|   </ItemGroup> | ||||
|   | ||||
| @@ -1,18 +1,18 @@ | ||||
| using Asp.Versioning; | ||||
| using Azure.Identity; | ||||
| using Core.Blueprint.Logging.Configuration; | ||||
| using Core.Thalos.Adapters.Extensions; | ||||
| using Core.Thalos.Adapters.Helpers; | ||||
| using Core.Thalos.External.ClientConfiguration; | ||||
| using Microsoft.AspNetCore.ResponseCompression; | ||||
| using Microsoft.Extensions.Configuration.AzureAppConfiguration; | ||||
| using OpenTelemetry.Logs; | ||||
| using OpenTelemetry.Resources; | ||||
| using Swashbuckle.AspNetCore.SwaggerUI; | ||||
| using System.IO.Compression; | ||||
| using System.Reflection; | ||||
|  | ||||
| var builder = WebApplication.CreateBuilder(args); | ||||
|  | ||||
| var authSettings = AuthHelper.GetAuthSettings(builder, "thalos_bff"); | ||||
|  | ||||
| builder.Services.ConfigureAuthentication(builder.Configuration, authSettings); | ||||
|  | ||||
| builder.Services.AddEndpointsApiExplorer(); | ||||
| builder.Configuration | ||||
|     .AddUserSecrets(Assembly.GetExecutingAssembly()) | ||||
| @@ -20,6 +20,7 @@ builder.Configuration | ||||
|  | ||||
| builder.Services.AddResponseCompression(); | ||||
| builder.Services.AddProblemDetails(); | ||||
| builder.Services.AddLogs(builder); | ||||
| builder.Services.AddMemoryCache(); | ||||
| builder.Services.AddResponseCaching(configureOptions => { configureOptions.UseCaseSensitivePaths = true; }); | ||||
| builder.Logging.AddOpenTelemetry(options => | ||||
| @@ -80,14 +81,19 @@ builder.Host.ConfigureServices((context, services) => | ||||
|     services.AddResponseCaching(); | ||||
|     services.AddControllers(); | ||||
|     services.AddEndpointsApiExplorer(); | ||||
|     services.AddVersioning(builder.Configuration); | ||||
|     services.AddSwagger(builder.Configuration, "Core.Thalos.BFF.API.xml", authSettings); | ||||
|     services.AddSwaggerGen(); | ||||
|     services.AddLogging(); | ||||
|     services.AddProblemDetails(); | ||||
|     services.AddHttpContextAccessor(); | ||||
|     services.AddTransient<TrackingMechanismExtension>(); // Register the TrackingIdHandler | ||||
|     services.RegisterExternalLayer(builder.Configuration); | ||||
|     services.AddTelemetry(); | ||||
|  | ||||
|     services.AddApiVersioning(options => options.ReportApiVersions = true) | ||||
|                    .AddApiExplorer(options => | ||||
|                    { | ||||
|                        options.GroupNameFormat = "'v'VVV"; | ||||
|                        options.SubstituteApiVersionInUrl = true; | ||||
|                    }); | ||||
| }); | ||||
|  | ||||
| builder.Services.AddCors(options => | ||||
| @@ -107,8 +113,15 @@ var app = builder.Build(); | ||||
|  | ||||
| app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); | ||||
| app.UseSwagger(); | ||||
| app.UseSwaggerUI(builder.Configuration, authSettings); | ||||
| app.ConfigureSwagger(builder.Configuration); | ||||
| app.UseSwaggerUI(options => | ||||
| { | ||||
|     foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName)) | ||||
|         options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version); | ||||
|  | ||||
|     options.DisplayRequestDuration(); | ||||
|     options.EnableTryItOutByDefault(); | ||||
|     options.DocExpansion(DocExpansion.None); | ||||
| }); | ||||
| app.UseResponseCompression(); | ||||
| app.UseResponseCaching(); | ||||
| app.UseHttpsRedirection(); | ||||
| @@ -118,6 +131,6 @@ app.UseAuthorization(); | ||||
| app.MapControllers(); | ||||
| app.UseHsts(); | ||||
| app.UseAntiforgery(); | ||||
| app.UseHttpLogging(); | ||||
| app.UseLogging(builder.Configuration); | ||||
|  | ||||
| app.Run(); | ||||
| @@ -1,4 +1,4 @@ | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
|  | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|   | ||||
| @@ -1,4 +1,6 @@ | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | ||||
|  | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
|  | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| using Core.Thalos.Adapters.Common.Constants; | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | ||||
|  | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
|  | ||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | ||||
| { | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using System.Text.Json.Serialization; | ||||
| using StatusEnum = Core.Blueprint.Mongo.StatusEnum; | ||||
|  | ||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | ||||
| { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
|  | ||||
| namespace Core.Thalos.Application.UseCases.Users.Input | ||||
| { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
|  | ||||
| namespace Core.Thalos.Application.UseCases.Users.Input | ||||
| { | ||||
|   | ||||
| @@ -7,8 +7,8 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="BuildingBlocks.Library" Version="0.0.1" /> | ||||
|     <PackageReference Include="Thalos.Building.Blocks" Version="0.0.1" /> | ||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.2" /> | ||||
|     <PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" /> | ||||
|     <PackageReference Include="Refit" Version="8.0.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales