Skip to content

Commit daa3e1f

Browse files
committed
Record the scopes the server registered a DCR client for
1 parent f0f920f commit daa3e1f

15 files changed

Lines changed: 86 additions & 35 deletions

‎.changeset/dcr-registered-scopes.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@executor-js/sdk": patch
33
---
44

5-
Keep OAuth requests within the scopes a dynamically registered client registered for. DCR clients now persist their registered scopes (`oauth_client.origin_scopes`). Reuse picks a client only when its registration covers the requested scopes, so reconnecting after a server adds scopes registers a new client instead of pairing the old one with scopes the server refuses with `invalid_scope`. `oauth.start` narrows discovered scopes to the client's registration and fails with a clear error when declared scopes fall outside it. Clients registered before this release have no recorded scopes and are registered again on their next connect; existing connections keep refreshing through them.
5+
Keep OAuth requests within the scopes a dynamically registered client was registered for. DCR clients now persist the scopes their registration asked for (`oauth_client.origin_requested_scopes`) and the scopes the server registered, from the registration response (`oauth_client.origin_scopes`, RFC 7591 §3.2.1). Reuse picks a client only when its registration covers the requested scopes, so reconnecting after a server adds scopes registers a new client instead of pairing the old one with scopes the server refuses with `invalid_scope`. `oauth.start` narrows discovered scopes to the server-registered set and fails with a clear error when declared scopes fall outside it. Clients registered before this release have no recorded scopes and are registered again on their next connect; existing connections keep refreshing through them.

‎apps/cloud/drizzle/0023_blushing_thor_girl.sql‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "oauth_client" ADD COLUMN "origin_requested_scopes" text;--> statement-breakpoint
2+
ALTER TABLE "oauth_client" ADD COLUMN "origin_scopes" text;

‎apps/cloud/drizzle/meta/0023_snapshot.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "f8434522-4dec-4ec3-a98d-7835dd9ed956",
2+
"id": "dd2a6125-3d4a-4dd1-85db-3c6a9aa7c8d7",
33
"prevId": "9d3bc667-63af-4a1b-99d9-b490ffcd80ef",
44
"version": "7",
55
"dialect": "postgresql",
@@ -1140,6 +1140,12 @@
11401140
"primaryKey": false,
11411141
"notNull": false
11421142
},
1143+
"origin_requested_scopes": {
1144+
"name": "origin_requested_scopes",
1145+
"type": "text",
1146+
"primaryKey": false,
1147+
"notNull": false
1148+
},
11431149
"origin_scopes": {
11441150
"name": "origin_scopes",
11451151
"type": "text",

‎apps/cloud/drizzle/meta/_journal.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@
166166
{
167167
"idx": 23,
168168
"version": "7",
169-
"when": 1793066713689,
170-
"tag": "0023_blushing_thor_girl",
169+
"when": 1793077208148,
170+
"tag": "0023_wild_gwen_stacy",
171171
"breakpoints": true
172172
}
173173
]

‎apps/cloud/src/db/executor-schema.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const oauth_client = pgTable(
106106
origin_integration: text("origin_integration"),
107107
origin_issuer: text("origin_issuer"),
108108
origin_redirect_uri: text("origin_redirect_uri"),
109+
origin_requested_scopes: text("origin_requested_scopes"),
109110
origin_scopes: text("origin_scopes"),
110111
created_at: timestamp("created_at").notNull(),
111112
row_id: varchar("row_id", { length: 255 })

‎apps/local/drizzle/0007_lethal_nebula.sql‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE `oauth_client` ADD `origin_requested_scopes` text;--> statement-breakpoint
2+
ALTER TABLE `oauth_client` ADD `origin_scopes` text;

‎apps/local/drizzle/meta/0007_snapshot.json‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "6",
33
"dialect": "sqlite",
4-
"id": "ccdfb606-c5fd-4f3c-8296-2667eb31cd1a",
4+
"id": "8037cf3d-eb52-4f29-aa94-63b614909837",
55
"prevId": "89a4fd1b-f0f6-4482-a991-0db78c859f76",
66
"tables": {
77
"blob": {
@@ -479,6 +479,13 @@
479479
"notNull": false,
480480
"autoincrement": false
481481
},
482+
"origin_requested_scopes": {
483+
"name": "origin_requested_scopes",
484+
"type": "text",
485+
"primaryKey": false,
486+
"notNull": false,
487+
"autoincrement": false
488+
},
482489
"origin_scopes": {
483490
"name": "origin_scopes",
484491
"type": "text",

‎apps/local/drizzle/meta/_journal.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
{
5555
"idx": 7,
5656
"version": "6",
57-
"when": 1793066713918,
58-
"tag": "0007_lethal_nebula",
57+
"when": 1793077208384,
58+
"tag": "0007_mean_lucky_pierre",
5959
"breakpoints": true
6060
}
6161
]

0 commit comments

Comments
 (0)