diff --git a/Core.Thalos.BuildingBlocks/Adapters/TokenAdapter.cs b/Core.Thalos.BuildingBlocks/Adapters/TokenAdapter.cs index c8e5da5..183b768 100644 --- a/Core.Thalos.BuildingBlocks/Adapters/TokenAdapter.cs +++ b/Core.Thalos.BuildingBlocks/Adapters/TokenAdapter.cs @@ -11,6 +11,7 @@ namespace Core.Thalos.BuildingBlocks public UserAdapter? User { get; set; } public RoleAdapter? Role { get; set; } + public TenantAdapter? Tenant { get; set; } public IEnumerable? Permissions { get; set; } public IEnumerable Modules { get; set; } = null!; diff --git a/Core.Thalos.BuildingBlocks/Adapters/UserAdapter.cs b/Core.Thalos.BuildingBlocks/Adapters/UserAdapter.cs index c4cc62c..449f0ca 100644 --- a/Core.Thalos.BuildingBlocks/Adapters/UserAdapter.cs +++ b/Core.Thalos.BuildingBlocks/Adapters/UserAdapter.cs @@ -16,14 +16,6 @@ namespace Core.Thalos.BuildingBlocks [CollectionAttributeName("Users")] public class UserAdapter : Document { - /// - /// Gets or sets the guid of the user. - /// - [BsonElement("guid")] - [BsonRepresentation(BsonType.String)] - [JsonPropertyName("guid")] - public string? Guid { get; set; } - /// /// Gets or sets the email address of the user. /// @@ -64,6 +56,14 @@ namespace Core.Thalos.BuildingBlocks [JsonPropertyName("displayName")] public string? DisplayName { get; set; } + /// + /// Gets or sets the Tenand ID of the user. + /// + [BsonElement("tenantId")] + [BsonRepresentation(BsonType.ObjectId)] + [JsonPropertyName("tenantId")] + public string TenantId { get; set; } = null!; + /// /// Gets or sets the role ID of the user. /// diff --git a/Core.Thalos.BuildingBlocks/Common/Constants/Claims.cs b/Core.Thalos.BuildingBlocks/Common/Constants/Claims.cs index b50ac6c..5bd3e65 100644 --- a/Core.Thalos.BuildingBlocks/Common/Constants/Claims.cs +++ b/Core.Thalos.BuildingBlocks/Common/Constants/Claims.cs @@ -23,10 +23,20 @@ namespace Core.Thalos.BuildingBlocks /// /// Claim name for user's ID. /// - public const string Id = "id"; + public const string Id = "_id"; /// - /// Claim name for user's role ID. + /// Claim name for user's tenant name. + /// + public const string Tenant = "tenant"; + + /// + /// Claim name for user's tenant identifier. + /// + public const string TenantId = "tenantId"; + + /// + /// Claim name for user's role name. /// public const string Role = "role"; diff --git a/Core.Thalos.BuildingBlocks/Services/TokenService.cs b/Core.Thalos.BuildingBlocks/Services/TokenService.cs index 790ff37..84d537b 100644 --- a/Core.Thalos.BuildingBlocks/Services/TokenService.cs +++ b/Core.Thalos.BuildingBlocks/Services/TokenService.cs @@ -87,8 +87,10 @@ namespace Core.Thalos.BuildingBlocks { 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.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.RoleId, adapter?.Role?.Id ?? string.Empty), new Claim(Claims.Applications, JsonSerializer.Serialize(adapter?.Role?.Applications), JsonClaimValueTypes.JsonArray),