Skip to content

Commit 210a3ae

Browse files
authored
refactor: rename GITHUB_FALLBACK_TOKEN to WORLDDRIVEN_GITHUB_TOKEN (#325)
The old name was misleading - it's not a "fallback" but a specific token used for operations like accepting repository invitations. The new name matches the convention used in the documentation repository. Requires updating server config: dokku config:set worlddriven-core WORLDDRIVEN_GITHUB_TOKEN=<token>
1 parent 25cdc01 commit 210a3ae

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

AUTHENTICATION_ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The system tries authentication methods in this priority order:
2727
1. **Session User PAT** (Priority 1) - If user is logged in, use their personal access token
2828
2. **Repository GitHub App** (Priority 2) - If repository is configured with GitHub App
2929
3. **Repository Owner PAT** (Priority 3) - Fallback to repository owner's personal access token
30-
4. **Environment Token** (Priority 4) - System-wide fallback using `GITHUB_FALLBACK_TOKEN`
30+
4. **Environment Token** (Priority 4) - System-wide token using `WORLDDRIVEN_GITHUB_TOKEN`
3131

3232
## Configuration Options
3333

GITHUB_APP_MIGRATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The `repositories` collection uses GitHub App authentication:
4242

4343
**Repository Operations (PR management, webhooks):**
4444
1. **GitHub App** (Priority 1): Uses `installationId` from repository configuration
45-
2. **Fallback Token** (Priority 2): Uses `GITHUB_FALLBACK_TOKEN` environment variable for public repositories
45+
2. **Worlddriven Token** (Priority 2): Uses `WORLDDRIVEN_GITHUB_TOKEN` environment variable for public repositories
4646
3. **Error**: If repository has no `installationId`, it cannot be processed
4747

4848
**User-Specific Operations (UI, user API calls):**

src/helpers/auth.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ export class Auth {
6666
console.warn('Failed to load repository config:', error.message);
6767
}
6868

69-
// Priority 2: Environment token fallback (if available)
70-
if (process.env.GITHUB_FALLBACK_TOKEN) {
69+
// Priority 2: Environment token (if available)
70+
if (process.env.WORLDDRIVEN_GITHUB_TOKEN) {
7171
this._methods.push({
7272
type: 'ENV',
73-
token: process.env.GITHUB_FALLBACK_TOKEN,
73+
token: process.env.WORLDDRIVEN_GITHUB_TOKEN,
7474
priority: 2,
75-
description: 'Environment fallback token',
75+
description: 'Worlddriven GitHub token',
7676
});
7777
}
7878

src/helpers/invitationProcessor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ const GITHUB_API_BASE = 'https://api.github.com';
88
const DOCUMENTATION_REPO = 'worlddriven/documentation';
99

1010
export async function acceptRepositoryInvitations() {
11-
const token = process.env.GITHUB_FALLBACK_TOKEN;
11+
const token = process.env.WORLDDRIVEN_GITHUB_TOKEN;
1212

1313
if (!token) {
14-
console.log('[Invitations] No GITHUB_FALLBACK_TOKEN configured, skipping');
14+
console.log(
15+
'[Invitations] No WORLDDRIVEN_GITHUB_TOKEN configured, skipping'
16+
);
1517
return { accepted: 0, failed: 0 };
1618
}
1719

tests/auth.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('Auth class', async t => {
1313
findByOwnerAndRepoStub = sinon.stub(Repository, 'findByOwnerAndRepo');
1414

1515
// Clear environment variable
16-
delete process.env.GITHUB_FALLBACK_TOKEN;
16+
delete process.env.WORLDDRIVEN_GITHUB_TOKEN;
1717
});
1818

1919
t.afterEach(() => {
@@ -68,7 +68,7 @@ test('Auth class', async t => {
6868
installationId: 12345,
6969
};
7070
findByOwnerAndRepoStub.resolves(mockRepo);
71-
process.env.GITHUB_FALLBACK_TOKEN = 'env-token';
71+
process.env.WORLDDRIVEN_GITHUB_TOKEN = 'env-token';
7272

7373
const auth = new Auth({ owner: 'test', repo: 'repo' });
7474
const methods = await auth.getAllMethods();
@@ -81,7 +81,7 @@ test('Auth class', async t => {
8181
});
8282

8383
await t.test('should add environment token when available', async () => {
84-
process.env.GITHUB_FALLBACK_TOKEN = 'env-token';
84+
process.env.WORLDDRIVEN_GITHUB_TOKEN = 'env-token';
8585
findByOwnerAndRepoStub.resolves(null);
8686

8787
const auth = new Auth({ owner: 'test', repo: 'repo' });
@@ -91,7 +91,7 @@ test('Auth class', async t => {
9191
assert.strictEqual(methods[0].type, 'ENV');
9292
assert.strictEqual(methods[0].priority, 2);
9393
assert.strictEqual(methods[0].token, 'env-token');
94-
assert.strictEqual(methods[0].description, 'Environment fallback token');
94+
assert.strictEqual(methods[0].description, 'Worlddriven GitHub token');
9595
});
9696

9797
await t.test('should provide auth strategy description', async () => {
@@ -102,14 +102,14 @@ test('Auth class', async t => {
102102
installationId: 12345,
103103
};
104104
findByOwnerAndRepoStub.resolves(mockRepo);
105-
process.env.GITHUB_FALLBACK_TOKEN = 'env-token';
105+
process.env.WORLDDRIVEN_GITHUB_TOKEN = 'env-token';
106106

107107
const auth = new Auth({ owner: 'test', repo: 'repo' });
108108
const strategy = await auth.getAuthStrategy();
109109

110110
assert.ok(strategy.includes('Auth strategy (with fallbacks)'));
111111
assert.ok(strategy.includes('1. Repository GitHub App'));
112-
assert.ok(strategy.includes('2. Environment fallback token'));
112+
assert.ok(strategy.includes('2. Worlddriven GitHub token'));
113113
});
114114

115115
await t.test('should cache methods on repeated calls', async () => {

0 commit comments

Comments
 (0)