You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewNotImplementedException("anuchan to discuss with svukel (Steven).");
44
44
}
45
45
46
46
/// <summary>
@@ -49,60 +49,7 @@ public Task<TokenCredential> CreateAsync(string? tenant = null)
49
49
/// <returns>User identity string extracted from the incoming token, or null if not available.</returns>
50
50
publicstring?GetCurrentUserId()
51
51
{
52
-
try
53
-
{
54
-
varhttpContext=_httpContextAccessor.HttpContext;
55
-
varprincipal=httpContext?.User;
56
-
57
-
if(principal?.Identity?.IsAuthenticated!=true)
58
-
{
59
-
thrownewInvalidOperationException("User is not authenticated. JWT exchange authentication requires an authenticated user context.");
60
-
}
61
-
62
-
// Extract user object ID using the same pattern as the reference code
63
-
varuserObjectId=ExtractUserObjectId(principal);
64
-
vartenantId=ExtractTenantId(principal);
65
-
66
-
// Combine tenant and user for unique identifier (similar to cache key pattern)
67
-
if(!string.IsNullOrEmpty(userObjectId))
68
-
{
69
-
return!string.IsNullOrEmpty(tenantId)
70
-
?$"{tenantId}_{userObjectId}"
71
-
:userObjectId;
72
-
}
73
-
74
-
thrownewInvalidOperationException("Unable to extract user object ID from authentication context. Required claims (oid, sub, etc.) are missing from the token.");
75
-
}
76
-
catch(Exceptionex)
77
-
{
78
-
// Throw exception to prevent cache contamination between users
79
-
// Better to fail the request than risk cross-user data leakage
80
-
thrownewInvalidOperationException("Failed to extract user identity from authentication context. This is required for secure multi-user operations.",ex);
81
-
}
82
-
}
83
-
84
-
/// <summary>
85
-
/// Extracts the tenant ID from the ClaimsPrincipal.
86
-
/// </summary>
87
-
/// <param name="principal">The ClaimsPrincipal containing user claims.</param>
88
-
/// <returns>The tenant ID, or null if not found.</returns>
0 commit comments