Compare commits

..

13 Commits

Author SHA1 Message Date
Sergio Matias
8cfbad61fb retrieve redirec uri gogle from app settings 2025-08-29 12:51:41 -06:00
Sergio Matias
9b7e55c439 Retrieve redirect uri from app settings 2025-08-29 12:50:26 -06:00
OscarMmtz
806b5242b0 Merge pull request 'Add the code to retrieve the idToken instead of accessToken in google authentication' (#7) from feature/use-id-token into development
Reviewed-on: https://gitea.white-enciso.pro/AgileWebs/Core.Thalos.BuildingBlocks/pulls/7
Reviewed-by: efrain_marin <efrain.marin@agilewebs.com>
Reviewed-by: Sergio Matías <sergio.matias@agilewebs.com>
2025-08-28 17:39:55 +00:00
Oscar Morales
24f5711e1c Add the code to retrieve the idToken instead of accessToken in google authentication 2025-08-27 23:23:04 -06:00
Sergio Matias
e3d75fbfa8 Fix duplicated property 2025-08-26 14:18:33 -06:00
Sergio Matías
9872c1b88b Merge pull request 'Add tenant property to user' (#6) from feature/add-tenant-to-user into development
Reviewed-on: https://gitea.white-enciso.pro/AgileWebs/Core.Thalos.BuildingBlocks/pulls/6
Reviewed-by: OscarMmtz <oscar.morales@agilewebs.com>
2025-08-26 20:18:04 +00:00
Sergio Matias
fe4c0696e8 Merge branch 'development' into feature/add-tenant-to-user 2025-08-26 14:16:33 -06:00
Sergio Matias
3b752f182f fix 2025-08-26 14:11:09 -06:00
Sergio Matias
4a2ed52a2f fix 2025-08-26 14:10:48 -06:00
Sergio Matias
5277896bdc Add tenant identifier in user property 2025-08-26 14:10:29 -06:00
Sergio Matias
4cd89c6a83 Fix id property in user claims 2025-08-08 23:51:23 -06:00
Sergio Matias
0bd46f2594 Remove GUID property from user 2025-08-08 23:49:44 -06:00
Sergio Matias
7bbb8ebfe5 Add tenant property to user 2025-08-08 23:05:27 -06:00
7 changed files with 33 additions and 12 deletions

View File

@ -11,6 +11,7 @@ namespace Core.Thalos.BuildingBlocks
public UserAdapter? User { get; set; } public UserAdapter? User { get; set; }
public RoleAdapter? Role { get; set; } public RoleAdapter? Role { get; set; }
public TenantAdapter? Tenant { get; set; }
public IEnumerable<PermissionAdapter>? Permissions { get; set; } public IEnumerable<PermissionAdapter>? Permissions { get; set; }
public IEnumerable<ModuleAdapter> Modules { get; set; } = null!; public IEnumerable<ModuleAdapter> Modules { get; set; } = null!;

View File

@ -16,14 +16,6 @@ namespace Core.Thalos.BuildingBlocks
[CollectionAttributeName("Users")] [CollectionAttributeName("Users")]
public class UserAdapter : Document public class UserAdapter : Document
{ {
/// <summary>
/// Gets or sets the guid of the user.
/// </summary>
[BsonElement("guid")]
[BsonRepresentation(BsonType.String)]
[JsonPropertyName("guid")]
public string? Guid { get; set; }
/// <summary> /// <summary>
/// Gets or sets the email address of the user. /// Gets or sets the email address of the user.
/// </summary> /// </summary>
@ -64,6 +56,14 @@ namespace Core.Thalos.BuildingBlocks
[JsonPropertyName("displayName")] [JsonPropertyName("displayName")]
public string? DisplayName { get; set; } public string? DisplayName { get; set; }
/// <summary>
/// Gets or sets the Tenand ID of the user.
/// </summary>
[BsonElement("tenantId")]
[BsonRepresentation(BsonType.ObjectId)]
[JsonPropertyName("tenantId")]
public string TenantId { get; set; } = null!;
/// <summary> /// <summary>
/// Gets or sets the role ID of the user. /// Gets or sets the role ID of the user.
/// </summary> /// </summary>

View File

@ -23,10 +23,20 @@ namespace Core.Thalos.BuildingBlocks
/// <summary> /// <summary>
/// Claim name for user's ID. /// Claim name for user's ID.
/// </summary> /// </summary>
public const string Id = "id"; public const string Id = "_id";
/// <summary> /// <summary>
/// Claim name for user's role ID. /// Claim name for user's tenant name.
/// </summary>
public const string Tenant = "tenant";
/// <summary>
/// Claim name for user's tenant identifier.
/// </summary>
public const string TenantId = "tenantId";
/// <summary>
/// Claim name for user's role name.
/// </summary> /// </summary>
public const string Role = "role"; public const string Role = "role";

View File

@ -58,5 +58,6 @@ namespace Core.Thalos.BuildingBlocks
public const string GoogleClientId = "GoogleClientId"; public const string GoogleClientId = "GoogleClientId";
public const string GoogleClientSecret = "GoogleClientSecret"; public const string GoogleClientSecret = "GoogleClientSecret";
public const string GoogleRedirectUri = "GoogleRedirectUri"; public const string GoogleRedirectUri = "GoogleRedirectUri";
public const string GoogleLocalRedirectUri = "GoogleLocalRedirectUri";
} }
} }

View File

@ -10,6 +10,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
using Swashbuckle.AspNetCore.SwaggerUI; using Swashbuckle.AspNetCore.SwaggerUI;
@ -114,6 +115,12 @@ namespace Core.Thalos.BuildingBlocks.Configuration
c.AddSecurityDefinition(googleScheme, new OpenApiSecurityScheme c.AddSecurityDefinition(googleScheme, new OpenApiSecurityScheme
{ {
Type = SecuritySchemeType.OAuth2, Type = SecuritySchemeType.OAuth2,
Extensions = new Dictionary<string, IOpenApiExtension>
{
["x-tokenName"] = new OpenApiString("id_token")
},
Flows = new OpenApiOAuthFlows Flows = new OpenApiOAuthFlows
{ {
AuthorizationCode = new OpenApiOAuthFlow AuthorizationCode = new OpenApiOAuthFlow

View File

@ -112,7 +112,7 @@ namespace Core.Thalos.BuildingBlocks
{ {
googleSettings.ClientId = (await keyVaultProvider.GetSecretAsync(Secrets.GoogleClientId, new CancellationToken { })).Secret.Value; ; googleSettings.ClientId = (await keyVaultProvider.GetSecretAsync(Secrets.GoogleClientId, new CancellationToken { })).Secret.Value; ;
googleSettings.ClientSecret = (await keyVaultProvider.GetSecretAsync(Secrets.GoogleClientSecret, new CancellationToken { })).Secret.Value; googleSettings.ClientSecret = (await keyVaultProvider.GetSecretAsync(Secrets.GoogleClientSecret, new CancellationToken { })).Secret.Value;
googleSettings.RedirectUri = (await keyVaultProvider.GetSecretAsync(Secrets.GoogleRedirectUri, new CancellationToken { })).Secret.Value; googleSettings.RedirectUri = builder.Configuration.GetSection(Secrets.GoogleLocalRedirectUri).Value;
} }
else else
{ {

View File

@ -87,8 +87,10 @@ namespace Core.Thalos.BuildingBlocks
{ {
new Claim(Claims.Name, adapter?.User?.DisplayName ?? string.Empty), new Claim(Claims.Name, adapter?.User?.DisplayName ?? string.Empty),
new Claim(Claims.GUID, adapter?.User?.Guid ?? string.Empty), new Claim(Claims.Id, adapter?.User?.Id ?? string.Empty),
new Claim(Claims.Email, adapter?.User?.Email ?? string.Empty), new Claim(Claims.Email, adapter?.User?.Email ?? string.Empty),
new Claim(Claims.Tenant, adapter?.Tenant?.Name ?? string.Empty),
new Claim(Claims.Tenant, adapter?.Tenant?.Id ?? string.Empty),
new Claim(Claims.Role, adapter?.Role?.Name ?? string.Empty), new Claim(Claims.Role, adapter?.Role?.Name ?? string.Empty),
new Claim(Claims.RoleId, adapter?.Role?.Id ?? string.Empty), new Claim(Claims.RoleId, adapter?.Role?.Id ?? string.Empty),
new Claim(Claims.Applications, JsonSerializer.Serialize(adapter?.Role?.Applications), JsonClaimValueTypes.JsonArray), new Claim(Claims.Applications, JsonSerializer.Serialize(adapter?.Role?.Applications), JsonClaimValueTypes.JsonArray),