Skip to content

Commit d7e43e9

Browse files
committed
fix(auth): bake public OAuth client ID as fallback in getClientId()
The OAuth client ID is a public value — Device Authorization Grant (RFC 8628) uses a public-client flow with no client secret. The value is already stored as a plain repo variable (vars.SENTRY_CLIENT_ID) in CI, not a secret. Committing it as DEFAULT_OAUTH_CLIENT_ID eliminates the .env.local requirement for local development against sentry.io. The priority chain is unchanged: SENTRY_CLIENT_ID env var → SENTRY_CLIENT_ID_BUILD (build-time) → committed default Self-hosted users still override via SENTRY_CLIENT_ID env var; production release builds still inject via SENTRY_CLIENT_ID_BUILD — no behaviour change for either path.
1 parent c662830 commit d7e43e9

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copy this to .env.local and fill in your values
2-
SENTRY_CLIENT_ID=your-sentry-oauth-client-id
2+
# SENTRY_CLIENT_ID=your-sentry-oauth-client-id # Only needed for self-hosted or a custom OAuth app
33
# SENTRY_URL=https://sentry.io # Uncomment for self-hosted
44

55
# Test credentials (for running E2E tests)

src/lib/oauth.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,23 @@ function getSentryUrl(): string {
4343
return getConfiguredSentryUrl() ?? DEFAULT_SENTRY_URL;
4444
}
4545

46+
/**
47+
* Public OAuth client ID for sentry.io.
48+
*
49+
* Device Authorization Grant (RFC 8628) is a public-client flow — no client
50+
* secret is involved, so this value is safe to commit. It is equivalent to the
51+
* `SENTRY_CLIENT_ID` repo variable used by CI.
52+
*
53+
* Self-hosted instances must override this via the `SENTRY_CLIENT_ID` env var
54+
* or the `SENTRY_CLIENT_ID_BUILD` build-time define.
55+
*/
56+
const DEFAULT_OAUTH_CLIENT_ID =
57+
"1d673b81d60ef84c951359c36296972ca6fd41bd8f45acd2d3a783a3b3c28e41";
58+
4659
/**
4760
* OAuth client ID
4861
*
49-
* Build-time: Injected via esbuild define: { SENTRY_CLIENT_ID_BUILD: "..." }
50-
* Runtime: Can be overridden via SENTRY_CLIENT_ID env var (for self-hosted)
62+
* Priority: SENTRY_CLIENT_ID env var → SENTRY_CLIENT_ID_BUILD (build-time) → committed default
5163
*
5264
* Read at call time (not module load time) so tests can override SENTRY_CLIENT_ID
5365
* after module initialization.
@@ -60,7 +72,7 @@ function getClientId(): string {
6072
getEnv().SENTRY_CLIENT_ID ??
6173
(typeof SENTRY_CLIENT_ID_BUILD !== "undefined"
6274
? SENTRY_CLIENT_ID_BUILD
63-
: "")
75+
: DEFAULT_OAUTH_CLIENT_ID)
6476
);
6577
}
6678

0 commit comments

Comments
 (0)