Skip to content

Commit cbe4a68

Browse files
betegonclaude
andcommitted
docs: update credential storage docs and remove stale config.json references
Auth credentials moved to SQLite (cli.db) but several docs pages and code comments still referenced the old ~/.sentry/config.json file. Rewrites the auth command docs with the actual schema, env var precedence, and external access instructions. Fixes stale comments in logout, oauth, and dsn types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2988043 commit cbe4a68

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

docs/src/content/docs/commands/auth.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,38 @@ sentry auth refresh
8484

8585
This is typically handled automatically when tokens expire.
8686

87-
## Configuration
87+
## Credential Storage
8888

89-
Credentials are stored in `~/.sentry/config.json` with restricted file permissions (mode 600).
89+
We store credentials in a SQLite database at `~/.sentry/cli.db` with restricted file permissions (mode 600). The database uses a single-row `auth` table with the following columns:
9090

91-
**Config structure:**
91+
| Column | Type | Description |
92+
|--------|------|-------------|
93+
| `token` | TEXT | OAuth access token |
94+
| `refresh_token` | TEXT | OAuth refresh token |
95+
| `expires_at` | INTEGER | Token expiry (ms since epoch) |
96+
| `issued_at` | INTEGER | Token issue time (ms since epoch) |
97+
| `updated_at` | INTEGER | Last modification time (ms since epoch) |
9298

93-
```json
94-
{
95-
"auth": {
96-
"token": "...",
97-
"refreshToken": "...",
98-
"expiresAt": "2024-12-31T00:00:00Z"
99-
}
100-
}
99+
### Environment Variable Precedence
100+
101+
The CLI checks for auth tokens in the following order, using the first one found:
102+
103+
1. `SENTRY_AUTH_TOKEN` environment variable
104+
2. `SENTRY_TOKEN` environment variable (legacy)
105+
3. The `auth` table in the SQLite database
106+
107+
When a token comes from an environment variable, the CLI skips expiry checks and automatic refresh.
108+
109+
### Reading the Token Externally
110+
111+
Other tools can read the stored token directly from the database. The config directory defaults to `~/.sentry/` but can be overridden with the `SENTRY_CONFIG_DIR` environment variable.
112+
113+
```bash
114+
sqlite3 ~/.sentry/cli.db "SELECT token FROM auth WHERE id = 1;"
101115
```
116+
117+
Keep in mind a few caveats when accessing the database from outside the CLI:
118+
119+
- **Token expiry** — Check `expires_at` before using the token. The CLI automatically refreshes tokens when they are close to expiring, but an external reader will not trigger a refresh.
120+
- **WAL mode** — The database uses SQLite WAL (Write-Ahead Logging). Open it in read-only mode to avoid lock contention with a running CLI process.
121+
- **Env var precedence** — If `SENTRY_AUTH_TOKEN` or `SENTRY_TOKEN` is set, the CLI uses that instead of the database value. We recommend following the same precedence in external tools.

docs/src/content/docs/configuration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ The `sentry api` command also uses `--verbose` to show full HTTP request/respons
138138

139139
## Credential Storage
140140

141-
Credentials are stored in a SQLite database at `~/.sentry/` (or the path set by `SENTRY_CONFIG_DIR`) with restricted file permissions (mode 600) for security. The database also caches:
141+
We store credentials and caches in a SQLite database (`cli.db`) inside the config directory (`~/.sentry/` by default, overridable via `SENTRY_CONFIG_DIR`). The database file and its WAL side-files are created with restricted permissions (mode 600) so that only the current user can read them. The database also caches:
142142

143143
- Organization and project defaults
144144
- DSN resolution results
145145
- Region URL mappings
146146
- Project aliases (for monorepo support)
147+
148+
Other tools can query the database directly to read the stored auth token. See [Credential Storage](./commands/auth/#credential-storage) in the auth command docs for the schema and usage details.

src/commands/auth/logout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const logoutCommand = buildCommand({
3030
docs: {
3131
brief: "Log out of Sentry",
3232
fullDescription:
33-
"Remove stored authentication credentials from the configuration file.",
33+
"Remove stored authentication credentials from the local database.",
3434
},
3535
output: { json: true, human: formatLogoutResult },
3636
parameters: {

src/lib/dsn/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export type ResolvedProject = ResolvedProjectInfo & {
6666
/**
6767
* Cached DSN entry with full resolution info
6868
*
69-
* Stored in ~/.sentry/config.json under dsnCache[directory]
69+
* Stored in ~/.sentry/cli.db in the dsn_cache table
7070
*/
7171
export type CachedDsnEntry = {
7272
/** The raw DSN string */

src/lib/oauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export async function performDeviceFlow(
301301
}
302302

303303
/**
304-
* Complete the OAuth flow by storing the token in the config file.
304+
* Complete the OAuth flow by storing the token in the database.
305305
*
306306
* @param tokenResponse - The token response from performDeviceFlow
307307
*/

0 commit comments

Comments
 (0)