Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spicy-donuts-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/service-utils": patch
---

Scope service-key authorization cache entries by teamId, and ignore cache entries that lack a timestamp
9 changes: 5 additions & 4 deletions packages/service-utils/src/core/authorize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ export async function authorize(

// Use a separate cache key per auth method.
const cacheKey = authData.incomingServiceApiKey
? // incoming service key + clientId case
`key-v2:service-key:${authData.incomingServiceApiKeyHash}:${authData.clientId ?? "client_default"}`
? // incoming service key + teamId + clientId case
// do not cache service-key requests that carry no tenant selector
authData.teamId || authData.clientId
? `key-v2:service-key:${authData.incomingServiceApiKeyHash}:${authData.teamId ?? "team_default"}:${authData.clientId ?? "client_default"}`
: null
Comment thread
0xFirekeeper marked this conversation as resolved.
: authData.secretKeyHash
? // secret key case
`key-v2:secret-key:${authData.secretKeyHash}`
Expand Down Expand Up @@ -80,8 +83,6 @@ export async function authorize(
if (diff < cacheTtlMs) {
teamAndProjectResponse = parsed.teamAndProjectResponse;
}
} else {
teamAndProjectResponse = parsed;
}
}
} catch {
Expand Down
Loading