-
Notifications
You must be signed in to change notification settings - Fork 312
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
Implement cookie forwarding for api proxy #232
base: master
Are you sure you want to change the base?
Implement cookie forwarding for api proxy #232
Conversation
This prevents the cookie options form the api host are getting set on the client cookie.
This is interesting. What are your use cases? I don't think we want to include this as a default for Rendr. Passing through all client-side cookies to the API seems like a very app-specific change that does not generalize to most use cases. It's easy to pass a custom |
Our API is not stateless and requires a session id sent in a cookie. This PR doesn’t forwards all client-side cookies to all api hosts. If we get a set-cookie header in the response of an api host we will save this header in a new cookie to the client. Only these persisted set-cookie headers will then be sent to the original api host. cc: @c089 |
Ah, I see, thanks for explaining @lo1tuma. It still seems to me that this does not belong in the library because it is specific to your use case. At Airbnb, we have all sorts of overrides in our |
Passing our own Maybe we could change the default apiProxy to pass the Or could you think of a better way to make the apiProxy extensible? |
After toying with some ideas, @lo1tuma and I came up with the following proposal how we could make this extensible without copying the apiProxy. If @spikebrehm likes it we'd be happy to contribute the implementation, as well as rewrite the existing x-forwarded-for header and cookie forwarding stuff to make use of it: Currently, when custom behavior for the This would require two extension points: One before the
|
@@ -142,6 +142,8 @@ RestAdapter.prototype.apiDefaults = function(api, req) { | |||
delete api.body; | |||
} | |||
|
|||
// disable global cookie jar | |||
api.jar = false; |
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.
this will no longer be necessary when #248 is merged
I like this event extension a lot, as we'll rarely be changing the core apiProxy functionality, and just adding stuff to it. |
👍 |
This was one of the reason why I created https://github.com/pjanuario/rendr-auth-rest-adapter and opened this issue #457 |
The cookie name on the client gets prefixed with the name of the api and a separator. This prevents overwriting a cookie with the same name from a different api host and ensures that the cookies retrieved from the client will forwarded only to the correct api host.