-
Notifications
You must be signed in to change notification settings - Fork 19
Allow multiple cookies per user #262
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
base: main
Are you sure you want to change the base?
Conversation
df9a4c8 to
80cfd00
Compare
c3f7e13 to
db95665
Compare
db95665 to
dce5aa0
Compare
dce5aa0 to
764e6d2
Compare
SHAcollision
left a comment
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.
Looks like the test suite is failing because of clippy warnings. I anyway wonder whether it should succeed at all because as I understand create_session_and_cookie now sets the cookie path to capabilities.most_specific_scope() for both the new UUID cookie and the legacy public key cooki. For most apps that request /pub/<app>/... access, this path will look like /pub/<app>/. Browser cookie path rules mean that such a cookie will not be sent on requests to /session (or any other path outside that subtree). So I would expect that authenticated endpoints such as GET/DELETE /session can no longer see any cookies when hit from the browser, so session() and signout() will always fail with 401 right? The rust SDK keeps working because it manually injects the cookie header, but it bypasses browser semantics.
I don't know if there is any fix for this. Maybe setting path is not the best way to solve this issue to begin with. Maybe to preserve the filtering intent while keeping session endpoints working, we could attach an additional cookie scoped to /session, this one will suffer of the same bugs we've already seen in the current main codebase with chromium browsers...
| let sessions = sessions_from_cookies(&state, &cookies, pubky.public_key()) | ||
| .await | ||
| .unwrap_or_default(); |
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.
If I understand correctly, this converts every error, including database failures or internal errors, into “no sessions” and still returns 200 OK, right? The previous version returned the DB error to the client, so maybe is a regression in observability and correctness. Should propagate non-401 errors instead of unwrapping. For example, handle the unauthorized case explicitly and return Err(err) for everything else.
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 didnt want the failure of one session deletion to affect the deletion of the other sessions. Ive pushed code to awkwardly return the first error which it saw after attempting to remove all other sessions. I think this is the best we can do without introducing a regression?
|
@SHAcollision The reason for setting If we can get away with that only by introducing another cookie for |
Problem
See linked ticket for explanation of problem.
Changes
signout()will now remove all sessions belonging to the Usersession()will return information about the first cookie in the headers list. This is the same behaviour as before. We will consider expanding on this functionality hereLimitations
The main difference here is that multiple Cookies for a single user is now supported. This means that we need to do a trip to the db for each to verify their secrets. Ive assumed that this will not be an issue since Cookie count is generally low. We may want to think about imropving this thought, eg: