Skip to content

test-companion: post as the BrowserStack GitHub App with no key in the repository - #98

Draft
naimish-browse wants to merge 1 commit into
browserstack:masterfrom
naimish-browse:test-companion-app-token-broker
Draft

naimish-browse wants to merge 1 commit into
browserstack:masterfrom
naimish-browse:test-companion-app-token-broker

Conversation

@naimish-browse

@naimish-browse naimish-browse commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Lets a customer's workflow post as the BrowserStack GitHub App without storing the App's key anywhere in their repository.

Needs the token service endpoint to be live (POST https://test-companion.browserstack.com/api/github-app/token); until then every run falls back to the workflow token, as today.

How it works

Without app-id / app-private-key, the Action now:

  1. asks GitHub for the job's short-lived OIDC identity token, addressed to test-companion.browserstack.com (needs permissions: id-token: write);
  2. sends only that token to BrowserStack's token service, which holds the App's key;
  3. uses the App token it gets back, after checking it was issued for this repository.

The App token is then used exactly like the one from the direct-key path: comments, checks and commits are credited to browserstack[bot].

Falling back

Any failure falls back to the workflow token, so the run carries on as github-actions[bot], with a one-line notice saying why. That covers: no id-token: write, the App not installed (404), sign-in turned off (503), the service unreachable, and a token issued for another repository.

Retries: up to 3 tries, 10s each, on network errors, 5xx (not 503) and 429. Never on 401/403/404/422/503.

Keeping the tokens safe

  • Both the identity token and the App token are masked the moment they arrive, and redacted from everything posted to GitHub.
  • GitHub's identity-token variables are removed from the environment once used.
  • They were never in the agent's allowlisted environment; a test checks that.

Changes

  • app-id / app-private-key: still sign in directly, unchanged. The token service is never called then.
  • New inputs: token-broker-url (https only, defaults to the service) and app-slug (defaults to browserstack), for pointing at a test service and its App.
  • Bot identity: the service's reply doesn't name the App, so the bot account is <app-slug>[bot], and its user id is looked up with the new token, as the direct path does.
  • Starter workflow: gains id-token: write, and a note that installing the App needs no key.
  • README: new "Posting as BrowserStack" section.

Tests

1026 pass, 0 fail, and no not ok lines (rebased onto v1.1.0). The new test/token-broker.test.mjs covers:

  • the identity-token request and its audience;
  • that the service gets only the identity token;
  • masking;
  • each error status and its notice;
  • no id-token: write → no calls;
  • https-only addresses;
  • retries and the time limit;
  • a token for another repository being refused;
  • the direct-key path never calling the service;
  • the agent never getting the identity-token variables.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto (fallback from Default branch)
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML (base), Organization UI (inherited), Workspace UI (inherited); Enforced overrides: Organization
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 4d82473e-e7d0-4820-8060-ce2fa831db6f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…vice, with no key in the repository

Without app-id/app-private-key, the Action now asks GitHub for the job's
OIDC identity token (audience test-companion.browserstack.com), sends it to
BrowserStack's token service, and uses the App token it returns, limited to
this repository. The App's key stays with the service. Any failure (no
id-token: write, App not installed, service off or unreachable, a token for
another repository) falls back to the workflow token with a one-line notice.

Both tokens are masked as they arrive and redacted from everything posted;
GitHub's identity-token variables are removed once spent and were never in
the agent's allowlisted environment. The direct key path is unchanged.

New inputs token-broker-url (https only) and app-slug, for a test service.
The starter workflow gains id-token: write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@naimish-browse
naimish-browse force-pushed the test-companion-app-token-broker branch from 5377bd7 to ce3396a Compare November 17, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant