Skip to content

feat(api): Validate Auth Tokens client-side #1885

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

Merged
merged 15 commits into from
Jan 4, 2024

Conversation

szokeasaurusrex
Copy link
Member

Perform client-side validation of all Auth Tokens input to the Sentry CLI. To ensure future-compatibility, we only provide soft validation, meaning that we only print a warning message if we detect that the Auth Token is invalid – the CLI will still proceed with normal execution if the Auth Token is invalid.

An example warning message generated by the CLI is copied below:

  WARN    2024-01-03 18:52:53.810662 +01:00 Unrecognized auth token format!
        Hint: Did you copy your token correctly?

Fixes GH-1859

wip

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Description: This commit refactors the authentication code in `login.rs` and `mod.rs` files. It replaces the deprecated `Auth::Token` variant with the new `Auth::AuthToken` variant. The changes include updating the `update_config` and `execute` functions in `login.rs`, as well as the `configure_args` function in `mod.rs`. This ensures that the authentication logic is up to date and avoids using deprecated code
Also, added documentation comments, and cleaned up the tests by using parameterization
@szokeasaurusrex szokeasaurusrex merged commit 627559b into master Jan 4, 2024
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/auth-token-validation branch January 4, 2024 14:48
szokeasaurusrex added a commit that referenced this pull request Jan 5, 2024
szokeasaurusrex added a commit that referenced this pull request Jan 8, 2024
Perform client-side validation of all Auth Tokens input to the Sentry CLI. To ensure future-compatibility, we only provide soft validation, meaning that we only print a warning message if we detect that the Auth Token is invalid – the CLI will still proceed with normal execution if the Auth Token is invalid.

Fixes GH-1859
szokeasaurusrex added a commit that referenced this pull request Jan 8, 2024
… `--auth-token` (#1893)

This PR fixes the bug in #1885 that led us to revert that commit. The bug, reported in #1888, caused the CLI to panic when the sentry-cli login command was called with the --auth-token argument.

We determined that the CLI panicked because the auth_token was being downcast to a String instead of to an AuthToken type when being read from the matches within the login command. This PR corrects the login command, so that the auth_token is correctly obtained from the matches as an AuthToken. We also checked whether the auth_token argument was being read as a String anywhere else in the code, and found that the login command was the only place the argument was being read as a String. Therefore, we would expect this PR to fix this class of bug completely.

Fixes GH-1859
Fixes GH-1888
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.

Improve error message if not full token is not copied (Checksum correct)
2 participants