feat(oauth): add CIMD support for client metadata discovery#3285
feat(oauth): add CIMD support for client metadata discovery#3285waleedlatif1 merged 5 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryAdds CIMD (Client ID Metadata Document) support to enable OAuth clients like Claude Desktop to register dynamically via metadata URL instead of manual Dynamic Client Registration. The implementation fetches and validates CIMD documents with SSRF protection using DNS-pinned IP resolution, caches metadata with a 5-minute TTL and deduplicates concurrent requests, and upserts clients as public PKCE-only apps with Key changes:
Issue found: Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Start[OAuth Request with URL clientId] --> Check{isMetadataUrl?}
Check -->|No| Normal[Normal OAuth Flow]
Check -->|Yes| CacheCheck{In Cache?}
CacheCheck -->|Yes| UseCache[Use Cached Metadata]
CacheCheck -->|No| Fetch[Fetch CIMD Document]
Fetch --> DNS[DNS Lookup]
DNS --> ValidateIP{IP Private?}
ValidateIP -->|Yes| Block[Block Request]
ValidateIP -->|No| PinnedFetch[Fetch with Pinned IP]
PinnedFetch --> Validate[Validate Document]
Validate --> ValidateClient{clientId matches URL?}
ValidateClient -->|No| Error1[Reject - Mismatch]
ValidateClient -->|Yes| ValidateRedirects{redirectUris valid?}
ValidateRedirects -->|No| Error2[Reject - Invalid URIs]
ValidateRedirects -->|Yes| Cache[Cache Metadata 5min]
Cache --> UseCache
UseCache --> Upsert[Upsert to DB]
Upsert --> UpsertOK{Success?}
UpsertOK -->|No| Evict[Evict Cache]
UpsertOK -->|Yes| Continue[Continue OAuth]
Evict --> Fail[Fail Request]
Last reviewed commit: f61ff70 |
aa05f87 to
adeb7d3
Compare
adeb7d3 to
03396ce
Compare
|
@greptile |
|
@cursor review |
03396ce to
5808c9d
Compare
|
@cursor review |
|
@greptile |
…tion to CIMD - Add maxResponseBytes (256KB) to prevent oversized responses - Validate redirect_uri schemes (https/http only) and reject commas - Validate logo_uri requires HTTPS, silently drop invalid logos
|
@greptile |
|
@curosr review |
|
@cursor review |
|
@greptile |
Additional Comments (1)
|
- Move scheme check outside try/catch so specific error isn't swallowed - Return fromCache flag from resolveClientMetadata to skip redundant DB writes
|
@greptile |
|
@cursor review |
|
@cursor review |
|
@greptile |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Summary
client_id_metadata_document_supportedin OIDC discoveryencodeURIComponent) and arbitrary logo domains (<img>)Type of Change
Testing
Tested manually
Checklist