[public-api-server] Forward Origin header where provided#16405
[public-api-server] Forward Origin header where provided#16405
Conversation
|
started the job as gitpod-build-gpl-papi-forward.2 because the annotations in the pull request description changed |
|
/hold for testing in preview env |
f70eeed to
fee7ee4
Compare
fee7ee4 to
6f6fedd
Compare
|
/werft run 👍 started the job as gitpod-build-gpl-papi-forward.5 🐌 DB... |
394330f to
3483089
Compare
|
@geropl Added the context-style approach.
|
3483089 to
21275b3
Compare
| ) | ||
|
|
||
| func ToContext(ctx context.Context, origin string) context.Context { | ||
| return context.WithValue(ctx, originContextKey, origin) |
| func (i *Interceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc { | ||
| return connect.UnaryFunc(func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) { | ||
| if req.Spec().IsClient { | ||
| req.Header().Add("Origin", FromContext(ctx)) |
There was a problem hiding this comment.
Trying to understand what this branch is for: Is this interceptor both usable for servers and clients (e.g., when forwarding upstream)? 🤔
There was a problem hiding this comment.
Correct. The way the interceptor is implemented (as per the interceptor inteface) is that you could write a single interceptor for both clients, and servers.
Here, we don't focus on the client version too much, but we do "make it work" by honouring the value that was on the context.
| } | ||
|
|
||
| func (p *ConnectionPool) Get(ctx context.Context, token auth.Token) (gitpod.APIInterface, error) { | ||
| cached, found := p.cache.Get(token) |
|
@easyCZ Thank you, I like it (and tested and works) ✔️ Would you go ahead and approve your own code? 🙃 |
Care to create a few more "blank check" PRs for me? |
|
/unhold |
Description
Related Issue(s)
Fixes #
How to test
Release Notes
Documentation
Build Options:
Experimental feature to run the build with GitHub Actions (and not in Werft).
leeway-target=components:all
Run Leeway with
--dont-testPublish Options
Installer Options
Add desired feature flags to the end of the line above, space separated
Preview Environment Options:
If enabled this will build
install/previewIf enabled this will create the environment on GCE infra
Valid options are
all,workspace,webapp,ide,jetbrains,vscode,ssh