2 Commits

Author SHA1 Message Date
Oscar Morales
82166f5042 fix conflicts 2025-07-15 17:42:55 -06:00
Oscar Morales
a14cec8fb1 Configure authentication in program.cs and endpoints 2025-07-15 17:21:08 -06:00
8 changed files with 100 additions and 68 deletions

View File

@@ -25,7 +25,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Produces(MimeTypes.ApplicationJson)]
[Consumes(MimeTypes.ApplicationJson)]
[ApiController]
[AllowAnonymous]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class ModuleController(IModuleProvider service) : ControllerBase
{
/// <summary>
@@ -39,8 +39,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read, RoleManagement.Read")]
[Permission("ModuleManagement.Read, RoleManagement.Read")]
public async Task<IActionResult> GetAllModulesAsync(CancellationToken cancellationToken)
{
var result = await service.GetAllModules(cancellationToken).ConfigureAwait(false);
@@ -60,8 +59,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read")]
[Permission("ModuleManagement.Read")]
public async Task<IActionResult> GetAllModulesByList([FromBody] string[] modules, CancellationToken cancellationToken)
{
if (modules == null || !modules.Any())
@@ -87,8 +85,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read")]
[Permission("ModuleManagement.Read")]
public async Task<IActionResult> GetModuleByIdAsync([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.GetModuleById(id, cancellationToken).ConfigureAwait(false);
@@ -111,8 +108,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal e|ror.</response>
[HttpPost]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status201Created)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> CreateModuleAsync([FromBody] ModuleRequest newModule, CancellationToken cancellationToken)
{
var result = await service.CreateModule(newModule, cancellationToken).ConfigureAwait(false);
@@ -134,8 +130,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> UpdateModuleAsync([FromRoute] string id, ModuleAdapter entity, CancellationToken cancellationToken)
{
if (id != entity.Id?.ToString())
@@ -163,8 +158,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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).ConfigureAwait(false);

View File

@@ -25,6 +25,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Produces(MimeTypes.ApplicationJson)]
[Consumes(MimeTypes.ApplicationJson)]
[ApiController]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class PermissionController(IPermissionProvider service) : ControllerBase
{
/// <summary>
@@ -38,8 +39,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -59,8 +59,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Read")]
[Permission("PermissionManagement.Read")]
public async Task<IActionResult> GetAllPermissionsByList([FromBody] string[] permissions, CancellationToken cancellationToken)
{
if (permissions == null || !permissions.Any())
@@ -85,8 +84,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -109,8 +107,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal e|ror.</response>
[HttpPost]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status201Created)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -132,8 +129,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Write")]
[Permission("PermissionManagement.Write")]
public async Task<IActionResult> UpdatePermissionAsync([FromRoute] string id, PermissionAdapter entity, CancellationToken cancellationToken)
{
if (id != entity.Id?.ToString())
@@ -161,8 +157,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);

View File

@@ -24,6 +24,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Produces(MimeTypes.ApplicationJson)]
[Consumes(MimeTypes.ApplicationJson)]
[ApiController]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class RoleController(IRoleProvider service) : ControllerBase
{
/// <summary>
@@ -35,8 +36,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<RoleAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Read")]
[Permission("RoleManagement.Read")]
public async Task<IActionResult> GetAllRolesAsync(CancellationToken cancellationToken)
{
var result = await service.GetAllRoles(cancellationToken).ConfigureAwait(false);
@@ -54,8 +54,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpGet]
[Route(Routes.Id)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -78,8 +77,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPost]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status201Created)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -99,8 +97,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPut]
[Route(Routes.Id)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> UpdateRoleAsync([FromRoute] string id, [FromBody] RoleAdapter entity, CancellationToken cancellationToken)
{
if (id != entity.Id?.ToString())
@@ -126,8 +123,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPatch]
[Route(Routes.ChangeStatus)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -146,8 +142,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPost(Routes.AddApplication)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);
@@ -166,8 +161,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpDelete(Routes.RemoveApplication)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[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);

View File

@@ -35,8 +35,8 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[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);
@@ -54,8 +54,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);
@@ -79,7 +79,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpGet]
[Route(Routes.Email)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[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);
@@ -127,8 +127,8 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[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);
@@ -148,8 +148,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?.ToString())
@@ -173,7 +173,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPatch(Routes.LogIn)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[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);
@@ -194,7 +194,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPatch(Routes.LogOut)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[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);
@@ -216,8 +216,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);
@@ -236,8 +236,8 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPost]
[Route(Routes.AddCompany)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> AddCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken)
{
var result = await service.AddCompanyToUser(userId, companyId, cancellationToken).ConfigureAwait(false);
@@ -256,8 +256,8 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpDelete]
[Route(Routes.RemoveCompany)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> RemoveCompanyFromUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken)
{
var result = await service.RemoveCompanyFromUser(userId, companyId, cancellationToken).ConfigureAwait(false); ;
@@ -276,8 +276,8 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPost]
[Route(Routes.AddProject)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> AddProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken)
{
var result = await service.AddProjectToUser(userId, projectId, cancellationToken).ConfigureAwait(false);
@@ -296,8 +296,8 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpDelete]
[Route(Routes.RemoveProject)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> RemoveProjectFromUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken)
{
var result = await service.RemoveProjectFromUser(userId, projectId, cancellationToken).ConfigureAwait(false);
@@ -315,7 +315,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpGet]
[Route("{email}/GetTokenAdapter")]
[ProducesResponseType(typeof(TokenAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[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);

View File

@@ -1,6 +1,8 @@
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.Options;
using Microsoft.Graph.ExternalConnectors;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using Swashbuckle.AspNetCore.SwaggerUI;
@@ -8,13 +10,44 @@ namespace Core.Thalos.DAL.API.Extensions
{
public static class SwaggerExtensions
{
public static void AddSwagger(this IServiceCollection services)
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
AddSwaggerGen(services, configuration);
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
}
public static void AddSwaggerGen(this IServiceCollection services, IConfiguration configuration)
{
services.AddSwaggerGen(c =>
{
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT"
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
Array.Empty<string>()
}
});
});
}
public static void ConfigureSwagger(this WebApplication app)
{
app.UseSwagger();

View File

@@ -2,6 +2,7 @@ using Core.Blueprint.DAL.Mongo.Configuration;
using Core.Blueprint.Logging.Configuration;
using Core.Blueprint.Redis.Configuration;
using Core.Thalos.Adapters.Extensions;
using Core.Thalos.BuildingBlocks.Authentication.Extensions;
using Core.Thalos.DAL.API.Extensions;
using Core.Thalos.Provider;
using Microsoft.AspNetCore.HttpLogging;
@@ -10,6 +11,8 @@ using System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
builder.Services.ConfigureAuthentication(builder.Configuration);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Configuration
@@ -45,7 +48,7 @@ builder.Host.ConfigureServices((context, services) =>
services
.AddEndpointsApiExplorer()
.AddVersioning()
.AddSwagger();
.AddSwagger(builder.Configuration);
services.AddHealthChecks();
services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All);
@@ -65,8 +68,6 @@ var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.UseCors();
app.ConfigureSwagger();
@@ -76,6 +77,8 @@ app.UseRouting();
app.UseResponseCompression();
app.UseOutputCache();
app.UseResponseCaching();
app.UseAuthentication();
app.UseAuthorization();
app.UseLogging(builder.Configuration);
app.MapHealthChecks("/health");

View File

@@ -18,5 +18,18 @@
"UseRedisCache": true,
"CacheSettings": {
"DefaultCacheDurationInMinutes": 3
}
},
"Authentication": {
"Google": {
"ClientId": "128345072002-mtfdgpcur44o9tbd7q6e0bb9qnp2crfp.apps.googleusercontent.com",
"ClientSecret": "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",
"ApplicationName": "Thalos",
"RedirectUri": "https://localhost:7239/api/v1/Authentication/callback"
}
},
"JwtIssuerOptions": {
"Audience": "https://localhost:7239/",
"Issuer": "webApi"
},
"SecretKey": "iNivDmHLpUA223sqsfhqGbMRdRj1PVkH1"
}

View File

@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.3" />
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.5" />
</ItemGroup>
</Project>