Skip to content

Commit 38d8b23

Browse files
committed
feat: prefill R2 upload token creation
1 parent a1bc821 commit 38d8b23

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎docs/guide/platform/installation/credentials.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The installer deploys the email gateway, prepares the shared mail route, and ver
7474

7575
## R2 Upload Credentials
7676

77-
In the **R2 token creation** form opened by the installer, select **Object Read & Write** and **Apply to all buckets in this account (including newly created buckets)**. Create an account token, or a user token if your role requires it. Save its **Access Key ID** and **Secret Access Key** in your password manager. These differ from the management and runtime API tokens. See [R2’s token instructions](https://developers.cloudflare.com/r2/api/tokens/).
77+
The installer opens the **R2 token creation** form with a token name based on your platform's display name, **Object Read & Write**, and **Apply to all buckets in this account (including newly created buckets)** preselected. Review the settings and create an account token, or a user token if your role requires it. Save its **Access Key ID** and **Secret Access Key** in your password manager, then paste both into the installer. These differ from the management and runtime API tokens. See [R2’s token instructions](https://developers.cloudflare.com/r2/api/tokens/).
7878

7979
## Signing and Encryption Keys {#signing-and-encryption-keys}
8080

‎packages/void/src/cli/platform-setup.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,17 @@ export function platformSetupPages(plan: PlatformInstallPlan): {
223223
},
224224
r2: {
225225
title: 'R2 upload token',
226-
// R2's form accepts the token type but does not read permission/name
227-
// prefills. Open creation directly and make the remaining choice explicit.
228226
url:
229227
'https://dash.cloudflare.com/?' +
230228
new URLSearchParams({
231229
to: '/' + plan.account.id + '/r2/api-tokens/create',
232230
type: 'account',
231+
name: plan.deployment.displayName + ' Uploads',
232+
permission: 'object-write',
233+
bucketScope: 'all',
233234
}),
234235
instructions: [
235-
'Select Object Read & Write.',
236-
'Keep Apply to all buckets in this account selected.',
236+
'Review the preselected Object Read & Write access to all buckets in this account.',
237237
'Create the token, then copy the Access Key ID and Secret Access Key into the CLI.',
238238
].join('\n'),
239239
},

‎packages/void/test/unit/platform-setup.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,19 @@ describe('platform credential setup links', () => {
286286
'Create a Cloudflare runtime token that Void can use to manage the platform. Please review the permissions and then paste the token here.',
287287
);
288288
});
289-
it('opens R2 creation without claiming unsupported permission prefills', () => {
289+
it('prefills an R2 upload token with object write access to all current and future buckets', () => {
290290
const page = platformSetupPages(plan()).r2;
291291
const url = new URL(page.url);
292292
expect([...url.searchParams]).toEqual([
293293
['to', '/account/r2/api-tokens/create'],
294294
['type', 'account'],
295+
['name', 'Test & Team Uploads'],
296+
['permission', 'object-write'],
297+
['bucketScope', 'all'],
295298
]);
296-
expect(page.instructions).toContain('Select Object Read & Write.');
297-
expect(page.instructions).toContain('Keep Apply to all buckets in this account selected.');
299+
expect(page.instructions).toContain(
300+
'Review the preselected Object Read & Write access to all buckets in this account.',
301+
);
298302
expect(page.instructions).not.toMatch(/[();]/);
299303
expect(page.instructions).toContain('Access Key ID and Secret Access Key');
300304
expect(page.instructions).not.toContain('Admin Read');

0 commit comments

Comments
 (0)