Skip to content

Commit 8956001

Browse files
authored
feat: forward OIDC env vars into agent container (#1796)
* Initial plan * feat: forward OIDC env vars into agent container Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/2c3d051f-04fc-4032-9fd4-18ac82b173d3 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 91bd673 commit 8956001

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

src/docker-manager.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,65 @@ describe('docker-manager', () => {
12851285
}
12861286
});
12871287

1288+
it('should pass through ACTIONS_ID_TOKEN_REQUEST_URL when present in environment', () => {
1289+
const originalEnv = process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
1290+
process.env.ACTIONS_ID_TOKEN_REQUEST_URL = 'https://token.actions.githubusercontent.com/abc';
1291+
1292+
try {
1293+
const result = generateDockerCompose(mockConfig, mockNetworkConfig);
1294+
const env = result.services.agent.environment as Record<string, string>;
1295+
expect(env.ACTIONS_ID_TOKEN_REQUEST_URL).toBe('https://token.actions.githubusercontent.com/abc');
1296+
} finally {
1297+
if (originalEnv !== undefined) {
1298+
process.env.ACTIONS_ID_TOKEN_REQUEST_URL = originalEnv;
1299+
} else {
1300+
delete process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
1301+
}
1302+
}
1303+
});
1304+
1305+
it('should pass through ACTIONS_ID_TOKEN_REQUEST_TOKEN when present in environment', () => {
1306+
const originalEnv = process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
1307+
process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = 'test-oidc-token-value';
1308+
1309+
try {
1310+
const result = generateDockerCompose(mockConfig, mockNetworkConfig);
1311+
const env = result.services.agent.environment as Record<string, string>;
1312+
expect(env.ACTIONS_ID_TOKEN_REQUEST_TOKEN).toBe('test-oidc-token-value');
1313+
} finally {
1314+
if (originalEnv !== undefined) {
1315+
process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = originalEnv;
1316+
} else {
1317+
delete process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
1318+
}
1319+
}
1320+
});
1321+
1322+
it('should not pass through OIDC variables when not in environment', () => {
1323+
const origUrl = process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
1324+
const origToken = process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
1325+
delete process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
1326+
delete process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
1327+
1328+
try {
1329+
const result = generateDockerCompose(mockConfig, mockNetworkConfig);
1330+
const env = result.services.agent.environment as Record<string, string>;
1331+
expect(env.ACTIONS_ID_TOKEN_REQUEST_URL).toBeUndefined();
1332+
expect(env.ACTIONS_ID_TOKEN_REQUEST_TOKEN).toBeUndefined();
1333+
} finally {
1334+
if (origUrl !== undefined) {
1335+
process.env.ACTIONS_ID_TOKEN_REQUEST_URL = origUrl;
1336+
} else {
1337+
delete process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
1338+
}
1339+
if (origToken !== undefined) {
1340+
process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = origToken;
1341+
} else {
1342+
delete process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
1343+
}
1344+
}
1345+
});
1346+
12881347
it('should add additional environment variables from config', () => {
12891348
const configWithEnv = {
12901349
...mockConfig,

src/docker-manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,10 @@ export function generateDockerCompose(
708708
// interfere with credential isolation.
709709
if (process.env.GITHUB_API_URL) environment.GITHUB_API_URL = process.env.GITHUB_API_URL;
710710

711+
// GitHub Actions OIDC — required for MCP servers with auth.type: 'github-oidc'
712+
if (process.env.ACTIONS_ID_TOKEN_REQUEST_URL) environment.ACTIONS_ID_TOKEN_REQUEST_URL = process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
713+
if (process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN) environment.ACTIONS_ID_TOKEN_REQUEST_TOKEN = process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
714+
711715
}
712716

713717
// Always derive GH_HOST from GITHUB_SERVER_URL to prevent proxy-rewritten values

0 commit comments

Comments
 (0)