-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Handle cookies on redirection #3589
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
20c1092
feat: Set and send cookies on redirection (louislam#3587).
dakriy 934cea0
Merge branch '2.0.X' of github.com:louislam/uptime-kuma into handle-c…
dakriy 29bad2d
feat: Make proxy agents handle cookies
dakriy f1b4d04
Merge branch 'master' into handle-cookies
louislam dfc06c1
Merge package-lock.json
louislam 7014f3a
Merge branch 'master' into handle-cookies
louislam 251604d
Merge package-lock.json
louislam 018b807
Fix lint
louislam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't quite understand how adding these two dependencies solves the problem.
(the implementation looks reasonable, I just don't understand the documentation of the two projects and why they are needed)
http-cookie-agent
needed?(what is the difference between
https.Agent
andHttpsCookieAgent
)CookieJar
shared?(Can other requests leak cookies via this mechanism?)
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.
tough-cookie
should be just a pure standalone cookie api and storage.http-cookie-agent
connects betweentough-cookie
andaxios
.However, the problem is that a http agent and
axios
is an one-to-one relationship and it should be used byCacheableDnsHttpAgent
already.And the fun fact is that I just realized that I maybe messed up something in #1853,CacheableDnsHttpAgent
does not seem to be used in http/https monitor.Edit: Just realized again it is registered globally by
CacheableDnsHttpAgent.registerGlobalAgent()
.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.
A new cookie jar is created for every request (variable is scoped to the
monitor.js:beat
function) and it uses an in memory storage implementation by default . It should be per request meaning that no cookies are ever shared outside of a single request if my understanding of thebeat
function is correct. I was under the impression that theCachableDnsHttpAgent
was only used for docker and steam types of heartbeats meaning there shouldn't be any conflict since the beat types are mutually exclusive (else if). Those types also don't need cookie storage so I thought it wasn't needed there. I do think though there should be one central place to create an http agent rather than many things each creating one slightly differently but that's more a matter of design. I tested the changes and they worked as expected. Should I implement it differently?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.
I also must be missing something because I don't see any references forCacheableDnsHttpAgent.registerGlobalAgent()
in the project in the2.0.X
branch or themaster
branch.Oh I found it. In the commit 3b87209 it was changed to update. And it seems the only usages of it which are in the beat function in
monitor.js
pulls the agent and manually sets it on the axios options every beat anyway meaning there is no conflict and it's not really registered "globally" per se.uptime-kuma/server/model/monitor.js
Lines 656 to 677 in fe431d6