Repository navigation
Send chat streams through the install's signed CloudFront path - #353
Merged
Merged
Conversation
On a self-hosted install the streaming function's URL now takes only calls CloudFront signs (origin access control). CloudFront's signature is the Authorization header and Lambda needs a signed POST's body hash, so a stream on the dashboard's own hostname sends the token in x-coderhelm-stream-token and the body's SHA-256 in x-amz-content-sha256. A stream on another hostname keeps the bearer token.
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.
Summary
Self-hosted installs are moving their streaming function URL off the public internet (AWS Security Hub Lambda.1, critical): the URL takes only calls CloudFront signs with origin access control (CoderHelm/coderhelm-platform,
fix/security-hub). CloudFront's signature is theAuthorizationheader, and Lambda refuses a signed POST without its body hash, so the dashboard has to send the stream token and the body differently on the install's own hostname.Changes
src/lib/stream-client.ts:streamPost(token, payload)builds a stream POST. On the dashboard's own hostname (streamUrlis "", a self-hosted install) it sends the token inx-coderhelm-stream-tokenand the body's SHA-256 (hex, over the exact UTF-8 bytes sent) inx-amz-content-sha256, with noAuthorization. On another hostname (the hosted service) it sendsAuthorization: Beareras before, so its cross-origin preflight is unchanged.src/lib/brain.ts) both use it.e2e/chat.spec.ts: the self-hosted request carries the token header and a hash equal to SHA-256 of its body, with noAuthorization; the other-hostname request carries only the bearer token.Verification
npx tsc --noEmit: no errors.npm run lint: passes.playwright test e2e/chat.spec.ts e2e/audit-plans.spec.ts e2e/agent-permissions.spec.ts: 68 passed, the 2 new ones included.crypto.subtleSHA-256 overTextEncoderbytes checked against Node'screateHashon non-ASCII text.