Skip to content

Commit 1d521d4

Browse files
committed
fix: sign cloudery token under 'settings' subject
Drive's installed permission doc grants only GET on io.cozy.nextcloud.migrations. The Stack ignores a JWT's `scope` claim for app-audience tokens and authorizes from the named webapp's perm doc, so every PUT against the tracking doc came back 403: setRunning failed mid-migration, and the recovery flushAndFail write 403'd in turn, leaving the doc stuck in pending. The Settings app owns the migration UI and has ALL verbs on the doctype, so piggybacking there gives the service the writes it actually needs.
1 parent defccab commit 1d521d4

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/clients/cloudery-client.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,16 @@ export function createClouderyClient(
7979
body: JSON.stringify({
8080
audience: 'app',
8181
scope: MIGRATION_TOKEN_SCOPE,
82-
// The Stack uses Subject as the slug for the permission-doc
83-
// lookup that resolves an app-audience JWT into permissions.
84-
// Without one, every data request fails with 404
85-
// "no permission doc for ". We piggyback on the Drive app's
86-
// permission doc — its scope is a superset of the doctypes
87-
// this migration touches.
88-
subject: 'drive',
82+
// The Stack ignores the JWT's `scope` claim for app-audience
83+
// tokens and authorizes every request against the permission
84+
// doc of the webapp named by `subject`. We piggyback on the
85+
// Settings app: it owns the migration UI and its manifest
86+
// grants ALL verbs on io.cozy.nextcloud.migrations, plus the
87+
// io.cozy.files and io.cozy.settings rules the rest of the
88+
// migration needs. Drive's perm doc only has GET on
89+
// io.cozy.nextcloud.migrations, so PUTs from setRunning /
90+
// flushProgress / flushAndFail come back 403.
91+
subject: 'settings',
8992
}),
9093
signal: controller.signal,
9194
})

test/cloudery-client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('ClouderyClient', () => {
4343
body: JSON.stringify({
4444
audience: 'app',
4545
scope: MIGRATION_TOKEN_SCOPE,
46-
subject: 'drive',
46+
subject: 'settings',
4747
}),
4848
signal: expect.any(AbortSignal),
4949
})

0 commit comments

Comments
 (0)