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

Remove the undocumented login-with-token page #8336

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Aug 22, 2024

Motivation and context

There are several problems with this feature:

  1. To use it, you have to put the user's token in the URL. This token lasts forever (unless the user explicitly logs out), so it is nearly as sensitive as the user's password. Embedding such sensitive information in the URL is problematic, because URLs are saved in the browser history, dumped to server logs and displayed on the screen, none of which are secure locations. A user could also accidentally share a URL with an embedded token.

  2. If an attacker can get a user to follow a malicious link, they could forcibly log that user into the attacker's account (AKA "login CSRF"). This by itself is just a nuisance, but the attacker could potentially use this to trick the victim into, for example, uploading confidential data to the attacker's account.

  3. By design, it requires the use of token authentication, whose drawbacks I have explained in Stop using token authentication in the UI #8289.

    In fairness, when originally implemented, this feature set the session cookie rather than the token, but this cannot work if the user is already logged in, as the sessionid cookie is marked HTTPOnly and cannot be overridden by JavaScript. So the only way for this feature to work in all circumstances is to set the token.

Generally, the use cases of this feature are better served by single sign-on protocols, which don't suffer from these drawbacks.

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • [ ] I have updated the documentation accordingly
  • [ ] I have added tests to cover my changes
  • [ ] I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • New Features

    • Updated the authentication strategy by removing token-based login, streamlining the login process.
  • Bug Fixes

    • Improved routing within the application by eliminating support for token-based login.
  • Tests

    • Removed obsolete test case for token-based login and logout, reflecting changes in the authentication mechanism.
  • Chores

    • Updated version number of the cvat-ui package to indicate a new release.

Copy link
Contributor

coderabbitai bot commented Aug 22, 2024

Walkthrough

The changes involve the removal of the /auth/login-with-token endpoint from the application, indicating a shift in authentication strategy. As a result, the associated routing in the CVATApplication component has been updated, and a corresponding Cypress test case for token-based login has been deleted. Additionally, the version of the cvat-ui package has been updated from 1.64.6 to 1.65.0.

Changes

File Change Summary
changelog.d/20240822_134319_roman_rm_login_with_token.md Removed /auth/login-with-token, indicating a change in authentication strategy.
cvat-ui/package.json Updated version from 1.64.6 to 1.65.0.
cvat-ui/src/components/cvat-app.tsx Removed routing for LoginWithTokenComponent, affecting the authentication flow.
tests/cypress/e2e/actions_users/issue_1810_login_logout.js Deleted test case "Logout and login to task via token", reducing coverage for token-based login.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant AuthAPI

    User->>App: Request login
    App->>AuthAPI: Send credentials
    AuthAPI-->>App: Return authentication token
    App-->>User: Successful login
Loading

🐰 "In the fields of code we play,
No more tokens lead astray.
A simpler path, we hop along,
With each new change, we sing our song!
Version's up, our joy is bright,
Hop, hop, hop, into the light!" 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

There are several problems with this feature:

1. To use it, you have to put the user's token in the URL. This token lasts
   forever (unless the user explicitly logs out), so it is nearly as
   sensitive as the user's password. Embedding such sensitive information in
   the URL is problematic, because URLs are saved in the browser history,
   dumped to server logs and displayed on the screen, none of which are
   secure locations. A user could also accidentally share a URL with an
   embedded token.

2. If an attacker can get a user to follow a malicious link, they could
   forcibly log that user into the attacker's account (AKA "login CSRF").
   This by itself is just a nuisance, but the attacker could potentially use
   this to trick the victim into, for example, uploading confidential data
   to the attacker's account.

3. By design, it requires the use of token authentication, whose drawbacks I
   have explained in cvat-ai#8289.

   In fairness, when originally implemented, this feature set the session
   cookie rather than the token, but this cannot work if the user is already
   logged in, as the `sessionid` cookie is marked `HTTPOnly` and cannot be
   overridden by JavaScript. So the only way for this feature to work in all
   circumstances is to set the token.

Generally, the use cases of this feature are better served by single sign-on
protocols, which don't suffer from these drawbacks.
@SpecLad SpecLad marked this pull request as ready for review August 22, 2024 10:55
Copy link

sonarcloud bot commented Aug 22, 2024

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 86c1b22 and f3ebea1.

Files selected for processing (4)
  • changelog.d/20240822_134319_roman_rm_login_with_token.md (1 hunks)
  • cvat-ui/package.json (1 hunks)
  • cvat-ui/src/components/cvat-app.tsx (3 hunks)
  • tests/cypress/e2e/actions_users/issue_1810_login_logout.js (1 hunks)
Files skipped from review due to trivial changes (3)
  • cvat-ui/package.json
  • cvat-ui/src/components/cvat-app.tsx
  • tests/cypress/e2e/actions_users/issue_1810_login_logout.js
Additional comments not posted (1)
changelog.d/20240822_134319_roman_rm_login_with_token.md (1)

1-4: Changelog entry looks good.

The changelog entry is clear and follows the expected format. It accurately describes the removal of the /auth/login-with-token page and provides a link to the pull request for reference.

@SpecLad SpecLad merged commit d49247e into cvat-ai:develop Aug 22, 2024
41 of 42 checks passed
@SpecLad SpecLad deleted the rm-login-with-token branch August 22, 2024 11:53
@cvat-bot cvat-bot bot mentioned this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants