-
Notifications
You must be signed in to change notification settings - Fork 3
feat: conditionally add actor headers #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
ssncferreira
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM 👍 just some nits around header key/value sanitization. I know most of this is validated on the coder side, but since this is a library might be worth sanitizing or rejecting bad input.
|
|
||
| // Add headers for provided metadata. | ||
| for k, v := range actor.Metadata { | ||
| headers[ActorMetadataHeader(k)] = fmt.Sprintf("%v", v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we should probably be sanitizing the headers/vallues to make sure they don't have whitespaces or invalid characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace is fine in headers (well, not newlines) and I believe net/http takes care of invalid chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or did you perhaps mean the header key?
Also passes along the authenticated username as actor metadata. Closes coder/aibridge#135 Depends on coder/aibridge#142 **Replace aibridge tag with merge commit once coder/aibridge#142 lands.** --------- Signed-off-by: Danny Kopping <danny@coder.com>
Closes #135
Introduces a new header (
X-AI-Bridge-Actor-Id) which will optionally be sent along with upstream requests with the actor's identity as the value.Any metadata includes in the
context.Actorstruct will also be added to the headers in the formatX-AI-Bridge-Actor-{Key}={Value}.When enabled in
coder/coder, two new headers will be added: