- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.3k
 
[public-api-server] Forward Origin header where provided #16405
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
| 
           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) | 
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.
Ah, I like this!
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | 
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.
💯
| 
           @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