Skip to content

Commit 53bee9d

Browse files
committed
Ensure uniqeness between "sub" and "client_id" claims when resolving user id
1 parent f95922a commit 53bee9d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/HttpClient.Cache/CacheKeyComputer.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ public class CacheKeyComputer : ICacheKeyComputer
114114

115115
protected virtual string? GetUserId(JwtSecurityToken jwt)
116116
{
117-
return jwt.Payload.Sub ?? jwt.Payload.GetValueOrDefault("client_id") as string;
117+
if (jwt.Payload.Sub is not null)
118+
{
119+
return "sub:" + jwt.Payload.Sub;
120+
}
121+
else if (jwt.Payload.TryGetValue("client_id", out var clientId))
122+
{
123+
return "client_id:" + clientId;
124+
}
125+
126+
return null;
118127
}
119128
}

0 commit comments

Comments
 (0)