Describe the bug
Node.js version: 20.11.0
OS version: MacOS Sonoma 14.5
Description:
We are using superagent agent to perform an OpenID authorization code flow before interface tests, crossing domain boundaries on multiple redirects. After upgrading from superagent 8.0.8 to 9.0.2, this fails because of missing cookies in the latter redirects.
After adding some console.logs to the agent lib, it looks like in 8.0.8 the _saveCookies() method is not storing the right url.hostname/path but null/null, which means that all cookies are attached later irrespective of the domain, while in 9.0.2 it's passing wrong domains and paths into this.jar.setCookies(), so that they are not attached later.
Actual behavior
Example:
agent starts in domain www.service.org which sets a session Cookie, then redirects to oidc.service.org for authentication, which itself sets cookies.
Afterwards the same agent is used to post login credentials on oidc.service.org, which causes a redirect back to www.service.org. Now the session cookie is not passed to www.service.org, as it has been saved in the cookie jar with the redirection host/path for oidc.service.org.
Expected behavior
Cookies set in the response of any redirecting request that have no domain part by themselves should be saved with the domain of that exact request, not with that of the followup request.
Checklist
Describe the bug
Node.js version: 20.11.0
OS version: MacOS Sonoma 14.5
Description:
We are using superagent agent to perform an OpenID authorization code flow before interface tests, crossing domain boundaries on multiple redirects. After upgrading from superagent 8.0.8 to 9.0.2, this fails because of missing cookies in the latter redirects.
After adding some console.logs to the agent lib, it looks like in 8.0.8 the
_saveCookies()method is not storing the right url.hostname/path butnull/null, which means that all cookies are attached later irrespective of the domain, while in 9.0.2 it's passing wrong domains and paths intothis.jar.setCookies(), so that they are not attached later.Actual behavior
Example:
agent starts in domain
www.service.orgwhich sets asessionCookie, then redirects tooidc.service.orgfor authentication, which itself sets cookies.Afterwards the same agent is used to post login credentials on
oidc.service.org, which causes a redirect back towww.service.org. Now thesessioncookie is not passed towww.service.org, as it has been saved in the cookie jar with the redirection host/path foroidc.service.org.Expected behavior
Cookies set in the response of any redirecting request that have no domain part by themselves should be saved with the domain of that exact request, not with that of the followup request.
Checklist