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 684bdc8..3cc1e90 100644 --- a/Core.Thalos.BuildingBlocks/Adapters/UserAdapter.cs +++ b/Core.Thalos.BuildingBlocks/Adapters/UserAdapter.cs @@ -64,6 +64,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..5988595 100644 --- a/Core.Thalos.BuildingBlocks/Common/Constants/Claims.cs +++ b/Core.Thalos.BuildingBlocks/Common/Constants/Claims.cs @@ -26,7 +26,17 @@ namespace Core.Thalos.BuildingBlocks 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..e8d3468 100644 --- a/Core.Thalos.BuildingBlocks/Services/TokenService.cs +++ b/Core.Thalos.BuildingBlocks/Services/TokenService.cs @@ -89,6 +89,8 @@ 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.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),