Compare commits
7 Commits
main
...
feature/go
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7a3ee2389 | ||
| 0429704cac | |||
| 3b0c31c38e | |||
|
|
cfd6b16e24 | ||
|
|
bb87b0e148 | ||
|
|
2519e1b4fb | ||
|
|
714e18bb65 |
@@ -1,30 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Refit;
|
||||
|
||||
namespace Core.Cerberos.BFF.Api.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class BaseController(ILogger<BaseController> logger) : ControllerBase
|
||||
{
|
||||
private readonly ILogger<BaseController> _logger = logger;
|
||||
|
||||
protected Guid TrackingId => (Guid)(HttpContext.Items["TrackingId"] ?? Guid.NewGuid());
|
||||
|
||||
protected async Task<IActionResult> Handle<T>(Func<Task<ApiResponse<T>>> apiCall) where T : class
|
||||
{
|
||||
var response = await apiCall().ConfigureAwait(false);
|
||||
|
||||
_logger.LogInformation($"{TrackingId} - {response.RequestMessage?.Method} {response.RequestMessage?.RequestUri} - Status: {response.StatusCode}");
|
||||
|
||||
return FromAPIResponse(response);
|
||||
}
|
||||
|
||||
private IActionResult FromAPIResponse<T>(ApiResponse<T> response) where T : class
|
||||
{
|
||||
var errorContent = JsonConvert.DeserializeObject<string>(response.Error?.Content ?? string.Empty) ?? string.Empty;
|
||||
return StatusCode((int)response.StatusCode, (response.Content is not null) ? response.Content : errorContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core.Cerberos.External\Core.Cerberos.External.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.Local.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,6 +0,0 @@
|
||||
@Core.Cerberos.BFF.Api_HostAddress = http://localhost:5219
|
||||
|
||||
GET {{Core.Cerberos.BFF.Api_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -1,123 +0,0 @@
|
||||
using Core.Cerberos.Adapters.Extensions;
|
||||
using Core.Cerberos.Adapters.Helpers;
|
||||
using Core.Cerberos.External.ClientConfiguration;
|
||||
using Microsoft.AspNetCore.ResponseCompression;
|
||||
using OpenTelemetry.Logs;
|
||||
using OpenTelemetry.Resources;
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var authSettings = AuthHelper.GetAuthSettings(builder, "cerberos_bff");
|
||||
|
||||
builder.Services.ConfigureAuthentication(builder.Configuration, authSettings);
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Configuration
|
||||
.AddUserSecrets(Assembly.GetExecutingAssembly())
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
builder.Services.AddResponseCompression();
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddMemoryCache();
|
||||
builder.Services.AddResponseCaching(configureOptions => { configureOptions.UseCaseSensitivePaths = true; });
|
||||
builder.Logging.AddOpenTelemetry(options =>
|
||||
{
|
||||
options.IncludeScopes = true;
|
||||
options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("core.cerberos.bff.api")).AddConsoleExporter();
|
||||
});
|
||||
|
||||
builder.Host.ConfigureServices((context, services) =>
|
||||
{
|
||||
builder.Services.AddHsts(options =>
|
||||
{
|
||||
options.Preload = true;
|
||||
options.IncludeSubDomains = true;
|
||||
options.MaxAge = TimeSpan.FromDays(60);
|
||||
});
|
||||
builder.Services.AddResponseCaching(configureOptions =>
|
||||
{
|
||||
configureOptions.UseCaseSensitivePaths = true;
|
||||
configureOptions.MaximumBodySize = 2048;
|
||||
});
|
||||
builder.Services.AddHttpsRedirection(options =>
|
||||
{
|
||||
options.RedirectStatusCode = 308;
|
||||
});
|
||||
|
||||
services.AddHttpLogging(http =>
|
||||
{
|
||||
http.CombineLogs = true;
|
||||
});
|
||||
services.AddAntiforgery();
|
||||
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll", policyBuilder =>
|
||||
policyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
|
||||
});
|
||||
services.AddMvc().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.WriteIndented = true;
|
||||
options.JsonSerializerOptions.MaxDepth = 20;
|
||||
options.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
||||
});
|
||||
services.Configure<BrotliCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.SmallestSize;
|
||||
});
|
||||
services.Configure<GzipCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.SmallestSize;
|
||||
});
|
||||
services.AddResponseCompression(options =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
options.Providers.Add<BrotliCompressionProvider>();
|
||||
options.Providers.Add<GzipCompressionProvider>();
|
||||
});
|
||||
services.AddResponseCaching();
|
||||
services.AddControllers();
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddVersioning(builder.Configuration);
|
||||
services.AddSwagger(builder.Configuration, "Core.Cerberos.BFF.API.xml", authSettings);
|
||||
services.AddLogging();
|
||||
services.AddProblemDetails();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddTransient<TrackingMechanismExtension>(); // Register the TrackingIdHandler
|
||||
services.RegisterExternalLayer(builder.Configuration);
|
||||
services.AddTelemetry();
|
||||
});
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(
|
||||
builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
|
||||
//*************************************************************************//
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(builder.Configuration, authSettings);
|
||||
app.ConfigureSwagger(builder.Configuration);
|
||||
app.UseResponseCompression();
|
||||
app.UseResponseCaching();
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
app.UseHsts();
|
||||
app.UseAntiforgery();
|
||||
app.UseHttpLogging();
|
||||
|
||||
app.Run();
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Endpoints": {
|
||||
"AppConfigurationURI": "https://sandbox-hci-usc-appcg.azconfig.io"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
{
|
||||
public class GetAllModulesRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
{
|
||||
public class GetAllPermissionsRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class GetAllRolesRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetAllUsersRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,20 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Adapters.Contracts;
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Cerberos.External.Clients.Cerberos.Requests.Users;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Adapters.Contracts;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.BFF.Api.Services;
|
||||
using Core.Thalos.External.Clients.Thalos.Requests.Users;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using LSA.Dashboard.External.Clients.Dashboard;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Graph;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Core.Cerberos.BFF.Api.Controllers
|
||||
namespace Core.Thalos.BFF.Api.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for Authentication.
|
||||
@@ -18,8 +24,23 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[Produces(MimeTypes.ApplicationJson)]
|
||||
[Consumes(MimeTypes.ApplicationJson)]
|
||||
[ApiController]
|
||||
public class AuthenticationController(ICerberosServiceClient cerberosServiceClient, ILogger<AuthenticationController> logger, ITokenService tokenService) : BaseController(logger)
|
||||
public class AuthenticationController(
|
||||
IThalosServiceClient thalosServiceClient,
|
||||
ILogger<AuthenticationController> logger,
|
||||
ITokenService tokenService,
|
||||
IGoogleAuthorization googleAuthorization) : BaseController(logger)
|
||||
{
|
||||
[HttpGet]
|
||||
public IActionResult Authorize() => Ok(googleAuthorization.GetAuthorizationUrl());
|
||||
|
||||
[HttpGet("callback")]
|
||||
public async Task<IActionResult> Callback(string code)
|
||||
{
|
||||
var userCredential = await googleAuthorization.ExchangeCodeForToken(code);
|
||||
|
||||
return Ok(new Token(userCredential!.Token.IdToken));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get token for user.
|
||||
/// </summary>
|
||||
@@ -30,7 +51,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[HttpGet]
|
||||
[Route(Routes.GenerateToken)]
|
||||
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.AzureScheme)]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GenerateTokenService(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -43,7 +64,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(email)) return BadRequest("An error ocurred while desearializing the token");
|
||||
|
||||
var tokenResult = await Handle(() => cerberosServiceClient.GetTokenAdapterService(new GetTokenAdapterRequest { Email = email }, cancellationToken)).ConfigureAwait(false);
|
||||
var tokenResult = await Handle(() => thalosServiceClient.GetTokenAdapterService(new GetTokenAdapterRequest { Email = email }, cancellationToken)).ConfigureAwait(false);
|
||||
|
||||
if (tokenResult is ObjectResult tokenOkResult && tokenOkResult.StatusCode == 200)
|
||||
tokenAdapter = tokenOkResult.Value as TokenAdapter;
|
||||
@@ -52,11 +73,11 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (tokenAdapter is not null && tokenAdapter.User is not null)
|
||||
{
|
||||
tokenAdapter.User.Token = tokenService.GenerateAccessToken(tokenAdapter);
|
||||
var (token, modules) = tokenService.GenerateAccessToken(tokenAdapter);
|
||||
|
||||
await Handle(() => cerberosServiceClient.LoginUserService(new LoginUserRequest { Email = email }, cancellationToken)).ConfigureAwait(false);
|
||||
await Handle(() => thalosServiceClient.LoginUserService(new LoginUserRequest { Email = email }, cancellationToken)).ConfigureAwait(false);
|
||||
|
||||
return Ok(tokenAdapter.User);
|
||||
return Ok(new { token, modules });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -81,13 +102,13 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[HttpGet]
|
||||
[Route(Routes.RefreshToken)]
|
||||
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public async Task<IActionResult> RefreshCustomTokenAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var tokenAdapter = new TokenAdapter();
|
||||
var email = tokenService.GetEmailClaim(this.HttpContext);
|
||||
|
||||
var tokenResult = await Handle(() => cerberosServiceClient.GetTokenAdapterService(new GetTokenAdapterRequest { Email = email }, cancellationToken)).ConfigureAwait(false);
|
||||
var tokenResult = await Handle(() => thalosServiceClient.GetTokenAdapterService(new GetTokenAdapterRequest { Email = email }, cancellationToken)).ConfigureAwait(false);
|
||||
|
||||
if (tokenResult is ObjectResult tokenOkResult && tokenOkResult.StatusCode == 200)
|
||||
{
|
||||
48
Core.Thalos.BFF.Api/Controllers/BaseController.cs
Normal file
48
Core.Thalos.BFF.Api/Controllers/BaseController.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Refit;
|
||||
|
||||
namespace Core.Thalos.BFF.Api.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class BaseController(ILogger<BaseController> logger) : ControllerBase
|
||||
{
|
||||
private readonly ILogger<BaseController> _logger = logger;
|
||||
|
||||
protected Guid TrackingId => (Guid)(HttpContext.Items["TrackingId"] ?? Guid.NewGuid());
|
||||
|
||||
protected async Task<IActionResult> Handle<T>(Func<Task<ApiResponse<T>>> apiCall) where T : class
|
||||
{
|
||||
var response = await apiCall().ConfigureAwait(false);
|
||||
|
||||
_logger.LogInformation($"{TrackingId} - {response.RequestMessage?.Method} {response.RequestMessage?.RequestUri} - Status: {response.StatusCode}");
|
||||
|
||||
return FromAPIResponse(response);
|
||||
}
|
||||
|
||||
private IActionResult FromAPIResponse<T>(ApiResponse<T> response) where T : class
|
||||
{
|
||||
if (response.IsSuccessful)
|
||||
return StatusCode((int)response.StatusCode, response.Content);
|
||||
else
|
||||
{
|
||||
dynamic errorContent = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
errorContent = JsonConvert.DeserializeObject<string>(response.Error?.Content ?? string.Empty) ?? string.Empty;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorContent = JsonConvert.DeserializeObject<HttpError>(response.Error?.Content);
|
||||
if (errorContent?.Error?.ErrorCode is null && errorContent?.Error?.Message is null && errorContent?.Error?.Target is null)
|
||||
errorContent = JsonConvert.DeserializeObject<GenericErrorResponse>(response.Error?.Content);
|
||||
|
||||
}
|
||||
return StatusCode((int)response.StatusCode, errorContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.External.Clients.Cerberos.Requests.Permissions;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.BFF.Api.Services;
|
||||
using Core.Thalos.External.Clients.Thalos.Requests.Permissions;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using LSA.Dashboard.External.Clients.Dashboard;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Core.Cerberos.BFF.Api.Controllers
|
||||
namespace Core.Thalos.BFF.Api.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for module authentication.
|
||||
@@ -19,8 +20,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
public class ModuleController(ICerberosServiceClient cerberosServiceClient, ILogger<ModuleController> logger) : BaseController(logger)
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class ModuleController(IThalosServiceClient thalosServiceClient, ILogger<ModuleController> logger) : BaseController(logger)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the modules.
|
||||
@@ -32,14 +33,15 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("ModuleManagement.Read, RoleManagement.Read")]
|
||||
[Authorize(AuthenticationSchemes = Constant.Scheme)]
|
||||
//[Permission("ModuleManagement.Read, RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllModulesService(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(GetAllModulesService)} - Request received - Payload: ");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetAllModulesService(new GetAllModulesRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetAllModulesService(new GetAllModulesRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -65,7 +67,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("ModuleManagement.Read")]
|
||||
[AllowAnonymous]
|
||||
//[Permission("ModuleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -77,7 +80,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
return BadRequest("Module identifiers are required.");
|
||||
}
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetAllModulesByListService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetAllModulesByListService(request, cancellationToken)).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -98,7 +101,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
[AllowAnonymous]
|
||||
//[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> CreateModuleService(CreateModuleRequest newModule, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -113,7 +117,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(newModule.Route)) return BadRequest("Invalid module route");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.CreateModuleService(newModule, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.CreateModuleService(newModule, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -132,7 +136,7 @@ namespace Core.Cerberos.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
|
||||
@@ -141,7 +145,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid module identifier");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetModuleByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetModuleByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -160,7 +164,7 @@ namespace Core.Cerberos.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
|
||||
@@ -175,7 +179,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(newModule.Route)) return BadRequest("Invalid module route");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.UpdateModuleService(newModule, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.UpdateModuleService(newModule, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -196,7 +200,7 @@ namespace Core.Cerberos.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
|
||||
@@ -205,7 +209,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid module identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.ChangeModuleStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.ChangeModuleStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1,8 +1,8 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.External.Clients.Cerberos.Requests.Permissions;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.External.Clients.Thalos.Requests.Permissions;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using LSA.Dashboard.External.Clients.Dashboard;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Graph;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Core.Cerberos.BFF.Api.Controllers
|
||||
namespace Core.Thalos.BFF.Api.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for permission authentication.
|
||||
@@ -20,8 +20,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
public class PermissionController(ICerberosServiceClient cerberosServiceClient, ILogger<PermissionController> logger) : BaseController(logger)
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class PermissionController(IThalosServiceClient thalosServiceClient, ILogger<PermissionController> logger) : BaseController(logger)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the permissions.
|
||||
@@ -33,14 +33,14 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("PermissionManagement.Read, RoleManagement.Read")]
|
||||
////[Permission("PermissionManagement.Read, RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllPermissionsService(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(GetAllPermissionsService)} - Request received - Payload: ");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetAllPermissionsService(new GetAllPermissionsRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetAllPermissionsService(new GetAllPermissionsRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("PermissionManagement.Read")]
|
||||
//[Permission("PermissionManagement.Read")]
|
||||
public async Task<IActionResult> GetAllPermissionsByListAsync([FromBody] GetAllPermissionsByListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -78,7 +78,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
return BadRequest("Permission identifiers are required.");
|
||||
}
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetAllPermissionsByListService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetAllPermissionsByListService(request, cancellationToken)).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -99,7 +99,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
//[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> CreatePermissionService(CreatePermissionRequest newPermission, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -112,7 +112,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(newPermission.Description)) return BadRequest("Invalid permission description");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.CreatePermissionService(newPermission, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.CreatePermissionService(newPermission, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("PermissionManagement.Read")]
|
||||
//[Permission("PermissionManagement.Read")]
|
||||
public async Task<IActionResult> GetPermissionByIdService(GetPermissionRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -140,7 +140,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid permission identifier");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetPermissionByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetPermissionByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
//[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> UpdatePermissionService(UpdatePermissionRequest newPermission, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -172,7 +172,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(newPermission.Description)) return BadRequest("Invalid permission description");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.UpdatePermissionService(newPermission, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.UpdatePermissionService(newPermission, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
//[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> ChangePermissionStatusService([FromBody] ChangePermissionStatusRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -202,7 +202,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid permission identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.ChangePermissionStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.ChangePermissionStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1,14 +1,14 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using LSA.Dashboard.External.Clients.Dashboard;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Core.Cerberos.BFF.Api.Controllers
|
||||
namespace Core.Thalos.BFF.Api.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for role authentication.
|
||||
@@ -18,8 +18,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
public class RoleController(ICerberosServiceClient cerberosServiceClient, ILogger<RoleController> logger) : BaseController(logger)
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class RoleController(IThalosServiceClient thalosServiceClient, ILogger<RoleController> logger) : BaseController(logger)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the roles.
|
||||
@@ -38,7 +38,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
{
|
||||
logger.LogInformation($"{nameof(GetAllRolesService)} - Request received - Payload: ");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetAllRolesService(new GetAllRolesRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetAllRolesService(new GetAllRolesRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (request.Permissions?.Length <= 0) return BadRequest("Role must have at least one permission");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.CreateRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.CreateRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -104,7 +104,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid role identifier");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetRoleByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetRoleByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
if (request.Permissions?.Length <= 0) return BadRequest("Role must have at least one permission");
|
||||
|
||||
|
||||
return await Handle(() => cerberosServiceClient.UpdateRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.UpdateRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.ChangeRoleStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.ChangeRoleStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.AddApplicationToRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.AddApplicationToRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.RemoveApplicationFromRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.RemoveApplicationFromRoleService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1,15 +1,15 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Cerberos.External.Clients.Cerberos.Requests.Users;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.External.Clients.Thalos.Requests.Users;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using LSA.Dashboard.External.Clients.Dashboard;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Core.Cerberos.BFF.Api.Controllers
|
||||
namespace Core.Thalos.BFF.Api.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for user authentication.
|
||||
@@ -19,7 +19,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
public class UserController(ICerberosServiceClient cerberosServiceClient, ILogger<UserController> logger) : BaseController(logger)
|
||||
public class UserController(IThalosServiceClient thalosServiceClient, ILogger<UserController> logger) : BaseController(logger)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the users.
|
||||
@@ -31,15 +31,15 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetAllUsersService(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(GetAllUsersService)} - Request received - Payload: ");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetAllUsersService(new GetAllUsersRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetAllUsersService(new GetAllUsersRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -58,8 +58,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> CreateUserService(CreateUserRequest newUser, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -78,7 +78,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (!newUser.Companies.Any()) return BadRequest("The user must contain at least one company");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.CreateUserService(newUser, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.CreateUserService(newUser, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -97,8 +97,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetUserByIdService(GetUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -107,7 +107,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid user identifier");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetUserByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetUserByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -126,8 +126,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetUserByEmailService(GetUserByEmailRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -136,7 +136,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Email)) return BadRequest("Invalid user email");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.GetUserByEmailService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.GetUserByEmailService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -155,8 +155,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> UpdateUserService(UpdateUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -175,7 +175,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (!request.Companies.Any()) return BadRequest("The user must contain at least one company");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.UpdateUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.UpdateUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -194,7 +194,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.AzureScheme}, {Schemes.HeathScheme}")]
|
||||
//[Authorize(AuthenticationSchemes = $"{Schemes.AzureScheme}, {Schemes.DefaultScheme}")]
|
||||
public async Task<IActionResult> LoginUserService([FromBody] LoginUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -203,7 +203,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Email)) return BadRequest("Invalid user email");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.LoginUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.LoginUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -222,7 +222,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.AzureScheme}, {Schemes.HeathScheme}")]
|
||||
//[Authorize(AuthenticationSchemes = $"{Schemes.AzureScheme}, {Schemes.DefaultScheme}")]
|
||||
public async Task<IActionResult> LogoutUserService([FromBody] LogoutUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -231,7 +231,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Email)) return BadRequest("Invalid user email");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.LogoutUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.LogoutUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -252,8 +252,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> ChangeUserStatusService([FromBody] ChangeUserStatusRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -262,7 +262,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.ChangeUserStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.ChangeUserStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -283,8 +283,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> AddCompanyToUserService([FromBody] AddCompanyToUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -294,7 +294,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.AddCompanyToUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.AddCompanyToUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -315,8 +315,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> RemoveCompanyFromUserService([FromBody] RemoveCompanyFromUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -326,7 +326,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.RemoveCompanyFromUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.RemoveCompanyFromUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -347,8 +347,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
|
||||
public async Task<IActionResult> AddProjectToUserService([FromBody] AddProjectToUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -359,7 +359,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.AddProjectToUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.AddProjectToUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -380,8 +380,8 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
//[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> RemoveProjectFromUserService([FromBody] RemoveProjectFromUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -391,7 +391,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
|
||||
|
||||
return await Handle(() => cerberosServiceClient.RemoveProjectFromUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.RemoveProjectFromUserService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -419,7 +419,7 @@ namespace Core.Cerberos.BFF.Api.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(request.Email)) return BadRequest("Invalid user email");
|
||||
|
||||
return await Handle(() => cerberosServiceClient.ValidateUserExistenceService(request, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => thalosServiceClient.ValidateUserExistenceService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
33
Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.csproj
Normal file
33
Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.csproj
Normal file
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
|
||||
<PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" />
|
||||
<PackageReference Include="Google.Apis.Auth" Version="1.70.0" />
|
||||
<PackageReference Include="Google.Apis.Oauth2.v2" Version="1.68.0.1869" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.31.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.17" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.17" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core.Thalos.External\Core.Thalos.External.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.Local.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
6
Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.http
Normal file
6
Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.http
Normal file
@@ -0,0 +1,6 @@
|
||||
@Core.Thalos.BFF.Api_HostAddress = http://localhost:5219
|
||||
|
||||
GET {{Core.Thalos.BFF.Api_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
200
Core.Thalos.BFF.Api/Program.cs
Normal file
200
Core.Thalos.BFF.Api/Program.cs
Normal file
@@ -0,0 +1,200 @@
|
||||
using Asp.Versioning;
|
||||
using Azure.Identity;
|
||||
using Core.Blueprint.Logging.Configuration;
|
||||
using Core.Thalos.Adapters.Contracts;
|
||||
using Core.Thalos.Adapters.Extensions;
|
||||
using Core.Thalos.Adapters.Services;
|
||||
using Core.Thalos.BFF.Api.Services;
|
||||
using Core.Thalos.External.ClientConfiguration;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
using Microsoft.AspNetCore.ResponseCompression;
|
||||
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Interfaces;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using OpenTelemetry.Logs;
|
||||
using OpenTelemetry.Resources;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
using System.Security.Claims;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Configuration
|
||||
.AddUserSecrets(Assembly.GetExecutingAssembly())
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
// 🔑 Google Auth config
|
||||
var googleClientId = builder.Configuration["Authentication:Google:ClientId"];
|
||||
var googleClientSecret = builder.Configuration["Authentication:Google:ClientSecret"];
|
||||
var redirectUri = builder.Configuration["Authentication:Google:RedirectUri"];
|
||||
|
||||
// 🧩 Authentication
|
||||
builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = Constant.Scheme;
|
||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
})
|
||||
.AddScheme<AuthenticationSchemeOptions,
|
||||
GoogleAccessTokenAuthenticationHandler>(Constant.Scheme, null)
|
||||
.AddGoogle(options =>
|
||||
{
|
||||
options.ClientId = googleClientId!;
|
||||
options.ClientSecret = googleClientSecret!;
|
||||
//options.SaveTokens = true;
|
||||
options.CallbackPath = $"/{redirectUri}";
|
||||
});
|
||||
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddScoped<IGoogleAuthHelper, GoogleAuthHelperService>();
|
||||
builder.Services.AddScoped<IGoogleAuthorization, GoogleAuthorizationService>();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
||||
// 🧩 Swagger + OAuth2
|
||||
builder.Services.AddSwaggerGen(opts =>
|
||||
{
|
||||
const string schemeName = "oauth2";
|
||||
|
||||
opts.SwaggerDoc("v1",
|
||||
new OpenApiInfo { Title = "Core.Thalos.BFF", Version = "v1" });
|
||||
|
||||
opts.AddSecurityDefinition(schemeName, new OpenApiSecurityScheme
|
||||
{
|
||||
Type = SecuritySchemeType.OAuth2,
|
||||
Scheme = "bearer", // tells Swagger-UI to build an Authorization header
|
||||
BearerFormat = "JWT",
|
||||
Name = "Authorization",
|
||||
In = ParameterLocation.Header,
|
||||
|
||||
/* ⚠️ The key line – tell Swagger-UI to pick id_token instead of access_token */
|
||||
Extensions = new Dictionary<string, IOpenApiExtension>
|
||||
{
|
||||
["x-tokenName"] = new OpenApiString("id_token")
|
||||
},
|
||||
|
||||
Flows = new OpenApiOAuthFlows
|
||||
{
|
||||
AuthorizationCode = new OpenApiOAuthFlow
|
||||
{
|
||||
AuthorizationUrl = new Uri("https://accounts.google.com/o/oauth2/v2/auth"),
|
||||
TokenUrl = new Uri("https://oauth2.googleapis.com/token"),
|
||||
Scopes = new Dictionary<string, string>
|
||||
{
|
||||
{ "openid", "OpenID Connect" },
|
||||
{ "email", "Access email" },
|
||||
{ "profile", "Access profile" }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// every operation requires the scheme
|
||||
opts.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
[new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{ Type = ReferenceType.SecurityScheme, Id = schemeName }
|
||||
}
|
||||
] = new[] { "openid", "email", "profile" }
|
||||
});
|
||||
});
|
||||
|
||||
// 🎯 Existing configs (unchanged)
|
||||
builder.Services.AddResponseCompression();
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddLogs(builder);
|
||||
builder.Services.AddMemoryCache();
|
||||
builder.Services.AddResponseCaching(options => { options.UseCaseSensitivePaths = true; });
|
||||
|
||||
builder.Logging.AddOpenTelemetry(logging =>
|
||||
{
|
||||
logging.IncludeScopes = true;
|
||||
logging.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("core.thalos.bff.api"))
|
||||
.AddConsoleExporter();
|
||||
});
|
||||
|
||||
builder.Host.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddHsts(options =>
|
||||
{
|
||||
options.Preload = true;
|
||||
options.IncludeSubDomains = true;
|
||||
options.MaxAge = TimeSpan.FromDays(60);
|
||||
});
|
||||
|
||||
services.AddHttpsRedirection(options => { options.RedirectStatusCode = 308; });
|
||||
services.AddAntiforgery();
|
||||
services.AddHttpLogging(http => http.CombineLogs = true);
|
||||
services.AddCors(options => options.AddPolicy("AllowAll", policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));
|
||||
|
||||
services.AddMvc().AddJsonOptions(opt =>
|
||||
{
|
||||
opt.JsonSerializerOptions.WriteIndented = true;
|
||||
opt.JsonSerializerOptions.MaxDepth = 20;
|
||||
opt.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
||||
});
|
||||
|
||||
services.Configure<BrotliCompressionProviderOptions>(opt => opt.Level = CompressionLevel.SmallestSize);
|
||||
services.Configure<GzipCompressionProviderOptions>(opt => opt.Level = CompressionLevel.SmallestSize);
|
||||
services.AddResponseCompression(opt =>
|
||||
{
|
||||
opt.EnableForHttps = true;
|
||||
opt.Providers.Add<BrotliCompressionProvider>();
|
||||
opt.Providers.Add<GzipCompressionProvider>();
|
||||
});
|
||||
|
||||
services.AddControllers();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddTransient<TrackingMechanismExtension>();
|
||||
services.RegisterExternalLayer(builder.Configuration);
|
||||
|
||||
services.AddApiVersioning(options => options.ReportApiVersions = true)
|
||||
.AddApiExplorer(opt =>
|
||||
{
|
||||
opt.GroupNameFormat = "'v'VVV";
|
||||
opt.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<ITokenService, TokenService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseDeveloperExceptionPage();
|
||||
|
||||
app.UseSwagger();
|
||||
|
||||
app.UseCors(options => options.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().WithOrigins("https://localhost:7239"));
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
foreach (var version in app.DescribeApiVersions().Select(v => v.GroupName))
|
||||
options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version);
|
||||
|
||||
options.DisplayRequestDuration();
|
||||
options.EnableTryItOutByDefault();
|
||||
options.DocExpansion(DocExpansion.None);
|
||||
|
||||
options.OAuthClientId(googleClientId);
|
||||
options.OAuthClientSecret(googleClientSecret);
|
||||
options.OAuthUsePkce();
|
||||
options.OAuthScopes("openid", "email", "profile");
|
||||
});
|
||||
|
||||
app.UseResponseCompression();
|
||||
app.UseResponseCaching();
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
app.UseHsts();
|
||||
app.UseAntiforgery();
|
||||
app.UseLogging(builder.Configuration);
|
||||
app.Run();
|
||||
7
Core.Thalos.BFF.Api/Services/Constant.cs
Normal file
7
Core.Thalos.BFF.Api/Services/Constant.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Core.Thalos.BFF.Api.Services
|
||||
{
|
||||
public static class Constant
|
||||
{
|
||||
public const string Scheme = "GoogleAccessToken";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Google.Apis.Auth;
|
||||
using Google.Apis.Auth.OAuth2.Flows;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
|
||||
namespace Core.Thalos.BFF.Api.Services
|
||||
{
|
||||
public class GoogleAccessTokenAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options,
|
||||
ILoggerFactory logger,
|
||||
UrlEncoder encoder,
|
||||
IConfiguration config) : AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder)
|
||||
{
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
if (!Request.Headers.ContainsKey("Authorization"))
|
||||
return AuthenticateResult.Fail("Missing Authorization header");
|
||||
|
||||
var authHeader = Request.Headers.Authorization.ToString();
|
||||
if (!authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
||||
return AuthenticateResult.Fail("Invalid Authorization header");
|
||||
|
||||
var idToken = authHeader["Bearer ".Length..].Trim();
|
||||
|
||||
GoogleJsonWebSignature.Payload payload;
|
||||
try
|
||||
{
|
||||
payload = await GoogleJsonWebSignature.ValidateAsync(
|
||||
idToken,
|
||||
new GoogleJsonWebSignature.ValidationSettings
|
||||
{
|
||||
Audience = new[] { config["Authentication:Google:ClientId"]! }
|
||||
});
|
||||
}
|
||||
catch (InvalidJwtException)
|
||||
{
|
||||
return AuthenticateResult.Fail("Invalid Google token");
|
||||
}
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new Claim(ClaimTypes.NameIdentifier, payload.Subject),
|
||||
new Claim(ClaimTypes.Email, payload.Email),
|
||||
new Claim(ClaimTypes.Name, payload.Name ?? "")
|
||||
};
|
||||
|
||||
var identity = new ClaimsIdentity(claims, Constant.Scheme);
|
||||
var principal = new ClaimsPrincipal(identity);
|
||||
|
||||
var userEmail = principal.FindFirst(ClaimTypes.Email)?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(userEmail) ||
|
||||
!userEmail.EndsWith("@agilewebs.com", StringComparison.OrdinalIgnoreCase))
|
||||
return AuthenticateResult.Fail("Unauthorized Access");
|
||||
|
||||
var ticket = new AuthenticationTicket(principal, Constant.Scheme);
|
||||
return AuthenticateResult.Success(ticket);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Core.Thalos.BFF.Api/Services/IGoogleAuthHelper.cs
Normal file
37
Core.Thalos.BFF.Api/Services/IGoogleAuthHelper.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Oauth2.v2;
|
||||
|
||||
namespace Core.Thalos.BFF.Api.Services
|
||||
{
|
||||
public interface IGoogleAuthHelper
|
||||
{
|
||||
string[] GetScopes();
|
||||
string ScopeToString();
|
||||
ClientSecrets GetClientSecrets();
|
||||
}
|
||||
|
||||
public class GoogleAuthHelperService(IConfiguration config) : IGoogleAuthHelper
|
||||
{
|
||||
public ClientSecrets GetClientSecrets()
|
||||
{
|
||||
string clientId = config["Authentication:Google:ClientId"]!;
|
||||
string clientSecret = config["Authentication:Google:ClientSecret"]!;
|
||||
|
||||
return new() { ClientId = clientId, ClientSecret = clientSecret };
|
||||
}
|
||||
|
||||
public string[] GetScopes()
|
||||
{
|
||||
var scopes = new[]
|
||||
{
|
||||
Oauth2Service.Scope.Openid,
|
||||
Oauth2Service.Scope.UserinfoEmail,
|
||||
Oauth2Service.Scope.UserinfoProfile
|
||||
};
|
||||
|
||||
return scopes;
|
||||
}
|
||||
|
||||
public string ScopeToString() => string.Join(", ", GetScopes());
|
||||
}
|
||||
}
|
||||
42
Core.Thalos.BFF.Api/Services/IGoogleAuthorization.cs
Normal file
42
Core.Thalos.BFF.Api/Services/IGoogleAuthorization.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Auth.OAuth2.Flows;
|
||||
|
||||
namespace Core.Thalos.BFF.Api.Services
|
||||
{
|
||||
public interface IGoogleAuthorization
|
||||
{
|
||||
string GetAuthorizationUrl();
|
||||
Task<UserCredential> ExchangeCodeForToken(string code);
|
||||
}
|
||||
|
||||
public class GoogleAuthorizationService(
|
||||
IGoogleAuthHelper googleHelper, IConfiguration config) : IGoogleAuthorization
|
||||
{
|
||||
private string RedirectUrl = config["Authentication:Google:RedirectUri"]!;
|
||||
|
||||
public async Task<UserCredential> ExchangeCodeForToken(string code)
|
||||
{
|
||||
var flow = new GoogleAuthorizationCodeFlow(
|
||||
new GoogleAuthorizationCodeFlow.Initializer
|
||||
{
|
||||
ClientSecrets = googleHelper.GetClientSecrets(),
|
||||
Scopes = googleHelper.GetScopes()
|
||||
});
|
||||
|
||||
var token = await flow.ExchangeCodeForTokenAsync(
|
||||
"user", code, RedirectUrl, CancellationToken.None);
|
||||
|
||||
return new UserCredential(flow, "user", token);
|
||||
}
|
||||
|
||||
public string GetAuthorizationUrl() =>
|
||||
new GoogleAuthorizationCodeFlow(
|
||||
new GoogleAuthorizationCodeFlow.Initializer
|
||||
{
|
||||
|
||||
ClientSecrets = googleHelper.GetClientSecrets(),
|
||||
Scopes = googleHelper.GetScopes(),
|
||||
Prompt = "consent"
|
||||
}).CreateAuthorizationCodeRequest(RedirectUrl).Build().ToString();
|
||||
}
|
||||
}
|
||||
4
Core.Thalos.BFF.Api/Services/Token.cs
Normal file
4
Core.Thalos.BFF.Api/Services/Token.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Core.Thalos.BFF.Api.Services
|
||||
{
|
||||
public record Token(string IdToken);
|
||||
}
|
||||
20
Core.Thalos.BFF.Api/appsettings.Local.json
Normal file
20
Core.Thalos.BFF.Api/appsettings.Local.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"LocalGateways": {
|
||||
"ThalosService": "https://localhost:7253/api"
|
||||
},
|
||||
"Authentication": {
|
||||
"Google": {
|
||||
"ClientId": "128345072002-mtfdgpcur44o9tbd7q6e0bb9qnp2crfp.apps.googleusercontent.com",
|
||||
"ClientSecret": "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",
|
||||
"ApplicationName": "Thalos",
|
||||
"RedirectUri": "https://localhost:7239/api/v1/Authentication/callback"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,5 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"LocalGateways": {
|
||||
"CerberosService": "https://localhost:7253/api"
|
||||
}
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"Gateways": {
|
||||
"CerberosService": "" // Service endpoint for Cerberos
|
||||
"ThalosService": "" // Service endpoint for Thalos
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"KeyVault": "" //KeyVault Uri
|
||||
@@ -17,7 +17,7 @@
|
||||
"CallbackPath": "", // Path for redirect after authentication
|
||||
"Scopes": "" // Access scopes for user permissions
|
||||
},
|
||||
"HeathCerberosApp": {
|
||||
"ThalosApp": {
|
||||
"AuthorizationUrl": "", // URL for authorization endpoint(STORED IN KEY VAULT)
|
||||
"TokenUrl": "", // URL for token endpoint(STORED IN KEY VAULT)
|
||||
"Scope": "", // Scope for application permissions (STORED IN KEY VAULT)
|
||||
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.35027.167
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Cerberos.BFF.Api", "Core.Cerberos.BFF.Api\Core.Cerberos.BFF.Api.csproj", "{3272E8EA-B46B-49DF-9D29-B5BE758E87C4}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Thalos.BFF.Api", "Core.Thalos.BFF.Api\Core.Thalos.BFF.Api.csproj", "{3272E8EA-B46B-49DF-9D29-B5BE758E87C4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Cerberos.External", "Core.Cerberos.External\Core.Cerberos.External.csproj", "{3111115C-A391-4A4C-A886-016A92BAC20E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Thalos.External", "Core.Thalos.External\Core.Thalos.External.csproj", "{3111115C-A391-4A4C-A886-016A92BAC20E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{CBFF88ED-B50D-4A71-BB2A-C0B2BBA489CA}"
|
||||
EndProject
|
||||
@@ -1,14 +1,14 @@
|
||||
using Core.Cerberos.Adapters.Contracts;
|
||||
using Core.Cerberos.Adapters.Handlers;
|
||||
using Core.Cerberos.Adapters.TokenProvider;
|
||||
using Core.Cerberos.External.GatewayConfigurations;
|
||||
using Core.Thalos.Adapters.Contracts;
|
||||
using Core.Thalos.Adapters.Handlers;
|
||||
using Core.Thalos.Adapters.TokenProvider;
|
||||
using Core.Thalos.External.GatewayConfigurations;
|
||||
using LSA.Dashboard.External.Clients.Dashboard;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Refit;
|
||||
|
||||
namespace Core.Cerberos.External.ClientConfiguration
|
||||
namespace Core.Thalos.External.ClientConfiguration
|
||||
{
|
||||
public static class RegisterClientConfiguration
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace Core.Cerberos.External.ClientConfiguration
|
||||
return handler;
|
||||
});
|
||||
|
||||
var cerberosServiceApiUrl = GatewaySettingsConfigurations.GetCerberosServiceAPIEndpoint().Endpoint.Url;
|
||||
var thalosServiceApiUrl = GatewaySettingsConfigurations.GetThalosServiceAPIEndpoint().Endpoint.Url;
|
||||
|
||||
// Register IDashBoardServiceClient with the manually created HttpClient
|
||||
services.AddScoped(provider =>
|
||||
@@ -55,10 +55,10 @@ namespace Core.Cerberos.External.ClientConfiguration
|
||||
|
||||
var httpClient = new HttpClient(handlerTrackingId)
|
||||
{
|
||||
BaseAddress = new Uri(cerberosServiceApiUrl),
|
||||
BaseAddress = new Uri(thalosServiceApiUrl),
|
||||
Timeout = TimeSpan.FromMinutes(1)
|
||||
};
|
||||
return RestService.For<ICerberosServiceClient>(httpClient);
|
||||
return RestService.For<IThalosServiceClient>(httpClient);
|
||||
});
|
||||
|
||||
return services;
|
||||
@@ -1,14 +1,14 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Cerberos.External.Clients.Cerberos.Requests.Permissions;
|
||||
using Core.Cerberos.External.Clients.Cerberos.Requests.Users;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.External.Clients.Thalos.Requests.Permissions;
|
||||
using Core.Thalos.External.Clients.Thalos.Requests.Users;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Refit;
|
||||
|
||||
namespace LSA.Dashboard.External.Clients.Dashboard
|
||||
{
|
||||
public interface ICerberosServiceClient
|
||||
public interface IThalosServiceClient
|
||||
{
|
||||
[Post("/v1/User/Create")]
|
||||
Task<ApiResponse<UserAdapter>> CreateUserService([Header("TrackingId")][Body] CreateUserRequest request, CancellationToken cancellationToken = default);
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class ChangeModuleStatusRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class CreateModuleRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class GetAllModulesByListRequest
|
||||
{
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class GetAllModulesRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class GetModuleRequest
|
||||
{
|
||||
@@ -1,6 +1,8 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using StatusEnum = Core.Blueprint.Mongo.StatusEnum;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class UpdateModuleRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class ChangePermissionStatusRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class CreatePermissionRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class GetAllPermissionsByListRequest
|
||||
{
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class GetAllPermissionsRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class GetPermissionRequest
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using StatusEnum = Core.Blueprint.Mongo.StatusEnum;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Permissions
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions
|
||||
{
|
||||
public class UpdatePermissionRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class AddApplicationToRoleRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class ChangeRoleStatusRequest
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class CreateRoleRequest
|
||||
{
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class GetAllRolesRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class GetRoleRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class RemoveApplicationFromRoleRequest
|
||||
{
|
||||
@@ -1,7 +1,8 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
using StatusEnum = Core.Blueprint.Mongo.StatusEnum;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class UpdateRoleRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AddCompanyToUserRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AddProjectToUserRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class ChangeUserStatusRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class CreateUserRequest
|
||||
{
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetAllUsersRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetUserByEmailRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetTokenAdapterRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetUserRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Users
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Users
|
||||
{
|
||||
public class LoginUserRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Cerberos.Requests.Users
|
||||
namespace Core.Thalos.External.Clients.Thalos.Requests.Users
|
||||
{
|
||||
public class LogoutUserRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class RemoveCompanyFromUserRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class RemoveProjectFromUserRequest
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class UpdateUserRequest
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class ValidateUserExistenceRequest
|
||||
{
|
||||
@@ -7,8 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="0.9.0-alpha0001" />
|
||||
<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>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using Core.Blueprint.External;
|
||||
|
||||
namespace Core.Cerberos.External.GatewayConfigurations
|
||||
namespace Core.Thalos.External.GatewayConfigurations
|
||||
{
|
||||
public record GatewayConfiguration
|
||||
{
|
||||
public GatewayConfiguration()
|
||||
{
|
||||
CerberosService = new CerberosServiceAPI();
|
||||
ThalosService = new ThalosServiceAPI();
|
||||
}
|
||||
|
||||
public CerberosServiceAPI CerberosService { get; set; }
|
||||
public ThalosServiceAPI ThalosService { get; set; }
|
||||
}
|
||||
public record CerberosServiceAPI
|
||||
public record ThalosServiceAPI
|
||||
{
|
||||
public string Channel { get; set; }
|
||||
public BaseEndpoint Endpoint { get; set; }
|
||||
@@ -1,7 +1,7 @@
|
||||
using Core.Blueprint.External;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Core.Cerberos.External.GatewayConfigurations
|
||||
namespace Core.Thalos.External.GatewayConfigurations
|
||||
{
|
||||
public class GatewaySettingsConfigurations
|
||||
{
|
||||
@@ -13,9 +13,9 @@ namespace Core.Cerberos.External.GatewayConfigurations
|
||||
_configuration = configuration;
|
||||
SetDashboardServiceAPIEndpoint();
|
||||
}
|
||||
public static CerberosServiceAPI GetCerberosServiceAPIEndpoint()
|
||||
public static ThalosServiceAPI GetThalosServiceAPIEndpoint()
|
||||
{
|
||||
return GatewayConfigurations.CerberosService;
|
||||
return GatewayConfigurations.ThalosService;
|
||||
}
|
||||
private GatewayConfiguration SetDashboardServiceAPIEndpoint()
|
||||
{
|
||||
@@ -27,18 +27,18 @@ namespace Core.Cerberos.External.GatewayConfigurations
|
||||
else
|
||||
source = _configuration.GetSection("Gateways");
|
||||
|
||||
var endpoint = source["CerberosService"] ?? string.Empty;
|
||||
var endpoint = source["ThalosService"] ?? string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Cerberos Service endpoint is empty or null");
|
||||
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Thalos Service endpoint is empty or null");
|
||||
|
||||
GatewayConfigurations.CerberosService = new CerberosServiceAPI()
|
||||
GatewayConfigurations.ThalosService = new ThalosServiceAPI()
|
||||
{
|
||||
Endpoint = new BaseEndpoint()
|
||||
{
|
||||
Uri = new Uri(endpoint),
|
||||
Url = endpoint,
|
||||
Token = string.Empty,
|
||||
APIName = "Cerberos Service"
|
||||
APIName = "Thalos Service"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Core.Cerberos.External
|
||||
namespace Core.Thalos.External
|
||||
{
|
||||
public sealed class TrackingMechanismExtension(IHttpContextAccessor httpContextAccessor) : DelegatingHandler
|
||||
{
|
||||
Reference in New Issue
Block a user