fix(backend): Use tenant_id claim name in MCP API Key authentication
Fixed TenantId claim name mismatch between McpApiKeyAuthenticationHandler and ITenantContext implementations. Changed claim name from "TenantId" to "tenant_id" to match what TenantContext.GetCurrentTenantId() expects. This fixes the "TenantId cannot be empty" error when MCP SDK Resources attempt to retrieve the tenant ID after API Key authentication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -48,11 +48,12 @@ public class McpApiKeyAuthenticationHandler : AuthenticationHandler<McpApiKeyAut
|
||||
}
|
||||
|
||||
// Create claims from validation result
|
||||
// Note: Use "tenant_id" to match ITenantContext implementations that look for this claim name
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new(ClaimTypes.NameIdentifier, validationResult.UserId.ToString()),
|
||||
new("ApiKeyId", validationResult.ApiKeyId.ToString()),
|
||||
new("TenantId", validationResult.TenantId.ToString()),
|
||||
new("tenant_id", validationResult.TenantId.ToString()),
|
||||
new("UserId", validationResult.UserId.ToString()),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user