Self-hosting
Register a GitHub App
Create the GitHub App that receives pull request events, posts reviews and links users' GitHub accounts.
Self-hosting
Create the GitHub App that receives pull request events, posts reviews and links users' GitHub accounts.
OpenVScan talks to GitHub through a GitHub App that you own. The App receives pull request, comment and check run webhooks, posts check runs and comments, and mints short-lived read-only tokens for cloning. Its OAuth client is how users link their GitHub account, which OpenVScan checks before it connects an installation. This page walks through registering it and collecting the values you will set as secrets.
You need your web origin before you start. See "Choose your web origin first" in the Self-hosting guide. The examples use https://openvscan.example.com.
Open the new App form
Create the App under the account that owns the repositories you want reviewed.
Name and homepage
| Field | Value |
|---|---|
| GitHub App name | Any unique name, for example OpenVScan (Acme). GitHub derives the App's slug from it. |
| Homepage URL | https://openvscan.example.com |
Identifying and authorizing users
These settings are for linking GitHub accounts. See Linking GitHub.
| Field | Value |
|---|---|
| Callback URL | https://openvscan.example.com/api/github/link/callback |
| Expire user authorization tokens | Leave checked (the default). OpenVScan refreshes the tokens. |
| Request user authorization (OAuth) during installation | Leave unchecked. When it is checked, GitHub disables the Setup URL below. |
| Enable Device Flow | Leave unchecked. |
If users will sign in with GitHub through WorkOS, add a second callback URL: the GitHub redirect URI that the WorkOS dashboard shows for its GitHub connection. You can add more callback URLs later, for example http://localhost:3000/api/github/link/callback for local development.
Post installation
After someone installs the App, GitHub redirects them to the Setup URL with an installation_id. The web Worker checks that the signed-in user can manage that installation, links it to their account and sends them to the repositories page.
| Field | Value |
|---|---|
| Setup URL | https://openvscan.example.com/api/github/setup |
| Redirect on update | Checked, so changes to the installed repositories also return to OpenVScan. |
Webhook
| Field | Value |
|---|---|
| Active | Checked |
| Webhook URL | https://openvscan.example.com/api/github/webhook |
| Webhook secret | A random string. Save it: it becomes GITHUB_WEBHOOK_SECRET. |
Generate the secret with:
openssl rand -hex 32The web Worker rejects every delivery with a 401 until GITHUB_WEBHOOK_SECRET is set to the same value.
Permissions
Under Repository permissions:
| Permission | Access | Used for |
|---|---|---|
| Checks | Read and write | Creating and updating the "OpenVScan Security Review" check run and its annotations. |
| Pull requests | Read and write | Reading PR files, posting the inline review and the summary comment. |
| Contents | Read-only | Cloning the PR head in the sandbox, with a token scoped to that one repository. |
| Issues | Read-only | Receiving the Issue comment event for @<app> comment commands. GitHub hides that event until this permission is set. |
| Metadata | Read-only | Required by GitHub for every App. |
Under Organization permissions, set Members to Read-only. When someone connects an installation on an organization, OpenVScan checks with their GitHub token that they are an admin of that organization.
Under Account permissions, set Email addresses to Read-only. When users sign in with GitHub through WorkOS, WorkOS reads their email from GitHub, and users who keep their email private only expose it through this permission.
Leave everything else at No access.
Events
Under Subscribe to events, check:
@<app> review, pause, resume and help comments.You do not need to subscribe to installation events. GitHub sends installation and installation_repositories to every App, and OpenVScan uses them to remove repositories and installations that were uninstalled, and to pause reviews while an installation is suspended. If a webhook is missed, Sync on the Repositories page reconciles with GitHub.
Where the App can be installed
Choose Only on this account if you only review repositories owned by the account that owns the App. Choose Any account if other users or organizations will install it on your deployment.
Then select Create GitHub App.
After the App is created you land on its General settings page. Collect these values:
| Value | Where to find it | Becomes |
|---|---|---|
| App ID | About section, "App ID" | GITHUB_APP_ID (both Workers) |
| Slug | The App's public URL, https://github.com/apps/<slug> | GITHUB_APP_SLUG (web) |
| Client ID | About section, "Client ID" | GITHUB_CLIENT_ID (web) |
| Client secret | Client secrets → Generate a new client secret. Copy it now, GitHub shows it once. | GITHUB_CLIENT_SECRET (web) |
| Private key | Private keys → Generate a private key. Your browser downloads a .pem file. | GITHUB_APP_PRIVATE_KEY (both Workers) |
| Webhook secret | The value you generated above | GITHUB_WEBHOOK_SECRET (web) |
The slug is used to build the install link in the dashboard, https://github.com/apps/<slug>/installations/new. Without it, the dashboard cannot show the install button.
Keep the .pem file out of the repository. Both Workers accept the key with real newlines or with escaped \n sequences, so you can store it on one line.
Signing in and linking GitHub are separate. Users sign in through WorkOS AuthKit (see Configuration). Linking GitHub uses this App's own OAuth client, GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET, through /api/github/link and back to /api/github/link/callback. Users link GitHub under Settings → GitHub account. Connecting an installation without a linked account fails with a message asking them to link it.
The tokens are GitHub App user tokens. OpenVScan seals them with CREDENTIALS_KEY, refreshes them when they expire after eight hours, and uses them only to check installation access. One GitHub account can be linked to one OpenVScan user.
When a user returns from installing the App, the web Worker checks that they administer the installation's account before linking it:
GET /user/memberships/orgs/{org} and their GitHub token. This needs the Members organization permission above.An installation stays with the OpenVScan user who connected it first. Nobody else can connect it again or take over its repositories. A user without a linked GitHub account cannot connect an installation.
If you enable GitHub as a sign-in method in WorkOS, you can have it link GitHub too, so users who sign in with GitHub skip the separate link step:
/api/github/link/callback.On sign-in, OpenVScan saves the returned token as the user's linked GitHub account. Users who sign in another way link GitHub in Settings.
GitHub sends webhooks to one URL per App. If you also run OpenVScan locally, register a second App for development with:
http://localhost:3000/api/github/link/callback, plus the WorkOS GitHub redirect URI of your staging environment if you sign in with GitHub therehttp://localhost:3000/api/github/setupSee Local development.
Continue with Deploy to Cloudflare.