Add Anthropic access-review driver and resolver
The driver lists organization members through the Anthropic Admin API (GET /v1/organizations/users) with cursor pagination, mapping the role and the RFC 3339 added_at timestamp. The name resolver reads the organization name from /v1/organizations/me; a non-2xx response (for example a revoked key) yields no name rather than making the source-name worker retry forever. Both send the required anthropic-version header. Add a VCR test helper that injects the key via x-api-key so the cassette stays recordable, and strip x-api-key on save. The cassette holds synthetic members covering the user, developer, and admin roles. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
39
pkg/accessreview/drivers/testdata/anthropic.yaml
vendored
Normal file
39
pkg/accessreview/drivers/testdata/anthropic.yaml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
version: 2
|
||||
interactions:
|
||||
- id: 0
|
||||
request:
|
||||
proto: HTTP/1.1
|
||||
proto_major: 1
|
||||
proto_minor: 1
|
||||
content_length: 0
|
||||
host: api.anthropic.com
|
||||
form:
|
||||
limit:
|
||||
- "100"
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Anthropic-Version:
|
||||
- "2023-06-01"
|
||||
url: https://api.anthropic.com/v1/organizations/users?limit=100
|
||||
method: GET
|
||||
response:
|
||||
proto: HTTP/2.0
|
||||
proto_major: 2
|
||||
proto_minor: 0
|
||||
content_length: -1
|
||||
uncompressed: true
|
||||
body: '{"data":[{"id":"user_01WCz1FkmYMm4gnmykNKUu3Q","type":"user","email":"jane@example.com","name":"Jane Doe","role":"user","added_at":"2024-10-30T23:58:27.427722Z"},{"id":"user_01AbCdEfGhIjKlMnOpQrStUv","type":"user","email":"alex@example.com","name":"Alex Martin","role":"developer","added_at":"2025-02-14T09:12:03.001000Z"},{"id":"user_01ZyXwVuTsRqPoNmLkJiHgFe","type":"user","email":"john@example.com","name":"John Smith","role":"admin","added_at":"2026-01-05T16:40:51.500000Z"}],"has_more":false,"first_id":"user_01WCz1FkmYMm4gnmykNKUu3Q","last_id":"user_01ZyXwVuTsRqPoNmLkJiHgFe"}'
|
||||
headers:
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 28 May 2026 12:55:02 GMT
|
||||
Request-Id:
|
||||
- req_011CRgSyntheticExampleId01
|
||||
Server:
|
||||
- cloudflare
|
||||
status: 200 OK
|
||||
code: 200
|
||||
duration: 199.11175ms
|
||||
Reference in New Issue
Block a user