feat: prefer X-Coder-Owner-Id header when present#244
Draft
dannykopping wants to merge 3 commits intomainfrom
Draft
feat: prefer X-Coder-Owner-Id header when present#244dannykopping wants to merge 3 commits intomainfrom
dannykopping wants to merge 3 commits intomainfrom
Conversation
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
dannykopping
commented
Mar 31, 2026
Comment on lines
+178
to
+179
| if client == ClientCoderAgents { | ||
| if ownerID := r.Header.Get("X-Coder-Owner-Id"); ownerID != "" { |
Collaborator
Author
There was a problem hiding this comment.
We have to consider that it's possible that someone malicious could spoof the User-Agent and the X-Coder-Owner-Id header here. We're validating that it's at least a valid UUIDv4 value to prevent XSS, so the best they could do is make their interceptions masquerade as someone else's, but we still log this change.
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
c6ba45e to
a011104
Compare
29f644a to
aa36659
Compare
Signed-off-by: Danny Kopping <danny@coder.com>
aa36659 to
3f328ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Disclaimer: implemented using Claude Opus 4.6, reviewed by me.
When AI Bridge is used in conjunction with Coder Agents, it passes along a header (
X-Coder-Owner-Id) which specifies the user which initiated the interaction with Coder Agents (and transitively with AI Bridge).We should prefer this ID over the initiator passed through in the auth credential because Coder Agents can currently only provide a single token for all users when using an OpenAI-compatible provider. If a service account credential is used, we don't want the service account to show up as the initiator but rather the actual end-user.
This header was introduced in coder/coder#23578.
Manually tested and it works as expected.