Skip to content

Commit 231bd75

Browse files
authored
Revert "feat: send additional_permissions in token exchange request (#859)" (#864)
This reverts commit 0c70417.
1 parent 4126f9d commit 231bd75

File tree

3 files changed

+10
-159
lines changed

3 files changed

+10
-159
lines changed

docs/configuration.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,9 @@ jobs:
172172

173173
**Important Notes**:
174174

175-
- The GitHub token must have the corresponding permission in your workflow
175+
- The GitHub token must have the `actions: read` permission in your workflow
176176
- If the permission is missing, Claude will warn you and suggest adding it
177-
- The following additional permissions can be requested beyond the defaults:
178-
- `actions: read`
179-
- `checks: read`
180-
- `discussions: read` or `discussions: write`
181-
- `workflows: read` or `workflows: write`
182-
- Standard permissions (`contents: write`, `pull_requests: write`, `issues: write`) are always included and do not need to be specified
177+
- Currently, only `actions: read` is supported, but the format allows for future extensions
183178

184179
## Custom Environment Variables
185180

src/github/token.ts

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,60 +16,15 @@ async function getOidcToken(): Promise<string> {
1616
}
1717
}
1818

19-
const DEFAULT_PERMISSIONS: Record<string, string> = {
20-
contents: "write",
21-
pull_requests: "write",
22-
issues: "write",
23-
};
24-
25-
export function parseAdditionalPermissions():
26-
| Record<string, string>
27-
| undefined {
28-
const raw = process.env.ADDITIONAL_PERMISSIONS;
29-
if (!raw || !raw.trim()) {
30-
return undefined;
31-
}
32-
33-
const additional: Record<string, string> = {};
34-
for (const line of raw.split("\n")) {
35-
const trimmed = line.trim();
36-
if (!trimmed) continue;
37-
const colonIndex = trimmed.indexOf(":");
38-
if (colonIndex === -1) continue;
39-
const key = trimmed.slice(0, colonIndex).trim();
40-
const value = trimmed.slice(colonIndex + 1).trim();
41-
if (key && value) {
42-
additional[key] = value;
43-
}
44-
}
45-
46-
if (Object.keys(additional).length === 0) {
47-
return undefined;
48-
}
49-
50-
return { ...DEFAULT_PERMISSIONS, ...additional };
51-
}
52-
53-
async function exchangeForAppToken(
54-
oidcToken: string,
55-
permissions?: Record<string, string>,
56-
): Promise<string> {
57-
const headers: Record<string, string> = {
58-
Authorization: `Bearer ${oidcToken}`,
59-
};
60-
const fetchOptions: RequestInit = {
61-
method: "POST",
62-
headers,
63-
};
64-
65-
if (permissions) {
66-
headers["Content-Type"] = "application/json";
67-
fetchOptions.body = JSON.stringify({ permissions });
68-
}
69-
19+
async function exchangeForAppToken(oidcToken: string): Promise<string> {
7020
const response = await fetch(
7121
"https://api.anthropic.com/api/github/github-app-token-exchange",
72-
fetchOptions,
22+
{
23+
method: "POST",
24+
headers: {
25+
Authorization: `Bearer ${oidcToken}`,
26+
},
27+
},
7328
);
7429

7530
if (!response.ok) {
@@ -134,11 +89,9 @@ export async function setupGitHubToken(): Promise<string> {
13489
const oidcToken = await retryWithBackoff(() => getOidcToken());
13590
console.log("OIDC token successfully obtained");
13691

137-
const permissions = parseAdditionalPermissions();
138-
13992
console.log("Exchanging OIDC token for app token...");
14093
const appToken = await retryWithBackoff(() =>
141-
exchangeForAppToken(oidcToken, permissions),
94+
exchangeForAppToken(oidcToken),
14295
);
14396
console.log("App token successfully obtained");
14497

test/parse-permissions.test.ts

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)