Skip to content
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

Fix order of caching + authorization middlewares #1661

Open
wants to merge 6 commits into
base: v8
Choose a base branch
from

Conversation

DimitriosLisenko
Copy link

@DimitriosLisenko DimitriosLisenko commented Jan 18, 2024

Resolves #1660


Before the change?

The HTTP caching doesn't have the Authorization header available to it, and therefore caches + returns values across user boundaries.

After the change?

The HTTP caching middleware happens after then authorization middleware, and therefore has the Authorization header and can cache requests per user.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

…rization middleware because it needs the Authorization header to be set
@DimitriosLisenko
Copy link
Author

DimitriosLisenko commented Jan 18, 2024

Alternatively, could use Faraday::RackBuilder#insert to place the authorization middleware first in the list of handlers, which guarantees it will run before the caching middleware (which is set as part of the Faraday object initialization if the README is followed). Since the authorization middleware just sets some headers, this might be safer to do than rearranging the caching middleware, and it also works if somebody is not using Faraday::HttpCache as their caching middleware.

@nickfloyd nickfloyd self-requested a review January 19, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

None yet

1 participant