Skip to content

feat(server): Read X-Os-Auth from query params#431

Open
lcian wants to merge 3 commits intomainfrom
lcian/x-os-auth-query-param
Open

feat(server): Read X-Os-Auth from query params#431
lcian wants to merge 3 commits intomainfrom
lcian/x-os-auth-query-param

Conversation

@lcian
Copy link
Copy Markdown
Member

@lcian lcian commented Apr 15, 2026

This change is needed for getsentry/sentry#113030.
It allows frontend pages that use standard image components to slap ?X-Os-Auth=<token> to the URLs they retrieve images from, as opposed to needing custom logic to add it as a header whenever the image is known to be stored in Objectstore.

This is the final piece of the puzzle that will allow us to enable auth enforcement and unblock Emerge for EA of Snapshots.

The proper solution would be pre-signed URLs, but that needs design and is significantly more complex. We don't want that to be a blocker for Snapshots.
Moreover, only the frontend will use this way of authenticating, so we can always change it relatively easily.

The only thing we cannot change is old versions of CLI. CLI currently fetches a token from the backend and puts it in the X-Os-Auth header. Now that's a JWT, but in the future it could be something else, we just need to change the semantics of what we return from the backend.

lcian added 2 commits April 15, 2026 11:28
Read the auth token from the `X-Os-Auth` query parameter as a fallback
between the `X-Os-Auth` header and the `Authorization` header. The query
parameter value is the raw JWT without a `Bearer` prefix, useful for
contexts where headers cannot be set (e.g. browser-initiated requests).

Precedence: X-Os-Auth header > X-Os-Auth query param > Authorization header.
@lcian lcian marked this pull request as ready for review April 17, 2026 12:43
@lcian lcian requested a review from a team as a code owner April 17, 2026 12:43
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5316ff6. Configure here.

.and_then(|v| v.to_str().ok())
.and_then(strip_bearer);
.and_then(strip_bearer)
.or_else(|| extract_query_param_value(parts.uri.query(), OBJECTSTORE_AUTH_QUERY_PARAM))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auth token in query string leaks to logs/traces

Medium Severity

Passing the JWT via the X-Os-Auth query parameter means the token will appear in tracing spans and Sentry transactions. The existing make_http_span function records uri = %request.uri() which includes the full query string, and SentryHttpLayer with enable_transaction() also captures request URIs. Unlike headers, which are not included in these spans, query-parameter tokens will be persisted in logs and Sentry. The codebase already redacts sensitive values elsewhere (e.g., DecodingKey debug output, config secrets), but no scrubbing exists for URIs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5316ff6. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay? These tokens have a max validity anyways.

@lcian lcian requested a review from matt-codecov April 17, 2026 15:50
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