-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop using token authentication in the UI (#8289)
Currently, the UI authenticates with the server using two parallel methods: * A cookie set by the `/api/auth/login` endpoint. * A token returned by the same endpoint. This is redundant and confusing, and also causes several usability & security issues: * If a user creates 2 or more concurrent sessions (e.g. logs in on two computers), and then logs out of one of them, it will effectively log them out of all other sessions too. This happens because: 1. The same token is shared between all sessions. 2. Logging out destroys the token in the DB. 3. The server tries to authenticate the browser using the token first, so if a browser presents a token that's no longer present in the DB, the server responds with a 401 (even if the cookie is still valid). * When a user changes their password, Django invalidates all of that user's other sessions... except that doesn't work, because the user's token remains valid. This is bad, because if an attacker steals a user's password and logs in, the most obvious recourse (changing the password) will not work - the attacker will stay logged in. * Sessions effectively last forever, because, while Django's session data expires after `SESSION_COOKIE_AGE`, the token never expires. * The token is stored in local storage, so it could be stolen in an XSS attack. The session cookie is not susceptible to this, because it's marked `HttpOnly`. The common theme in all these problems is the token, so by ceasing to use it we can fix them all. Note that this patch does not remove the server-side token creation & authentication logic, or remove the token from the output of the `/api/auth/login` endpoint. This is because that would break the `Client.login` method in the SDK. However, I believe that in the future we should get rid of the whole "generate token on login" logic, and let users create API tokens explicitly if (and only if) they wish to use the SDK.
- Loading branch information
Showing
8 changed files
with
20 additions
and
88 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
### Fixed | ||
|
||
- Logging out of one session will no longer log the user out of all their | ||
other sessions | ||
(<https://github.com/cvat-ai/cvat/pull/8289>) | ||
|
||
### Changed | ||
|
||
- User sessions now expire after two weeks of inactivity | ||
(<https://github.com/cvat-ai/cvat/pull/8289>) | ||
|
||
- A user changing their password will now invalidate all of their sessions | ||
except for the current one | ||
(<https://github.com/cvat-ai/cvat/pull/8289>) | ||
|
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
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
34 changes: 0 additions & 34 deletions
34
tests/cypress/e2e/issues_prs/pr_5331_missing_authentication_data.js
This file was deleted.
Oops, something went wrong.