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

feat: add name and last four characters to ApiToken model #58876

Closed
wants to merge 4 commits into from

Conversation

mdtro
Copy link
Member

@mdtro mdtro commented Oct 26, 2023

  • Add a nullable name column to the ApiToken model to help users identify and give meaningful names to their API tokens.
  • Add a last_token_characters column that will contain the last four characters of the API token to help users with identify the token in the UI when the majority of it is obfuscated.
  • Include a migration that will backfill existing API tokens and their last_token_characters.

Related to RFC => getsentry/rfcs#32.
And issue: #9600

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 26, 2023
This reverts commit e8061f1ec408899ad4e1f29403adf360bc2d956e.
@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0584_apitoken_add_name_and_last_four.py src/sentry/migrations/0585_apitoken_backfill_last_chars.py ()

--
-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:
-- Raw Python operation
--

@mdtro mdtro marked this pull request as ready for review October 26, 2023 23:23
@mdtro mdtro requested a review from a team as a code owner October 26, 2023 23:23
@mdtro
Copy link
Member Author

mdtro commented Oct 26, 2023

Now that I'm thinking about this. I'll need to separate this into three different PRs to avoid any weird states.

  1. Add the name and last_token_characters columns with a migration.
  2. Update the save() method on the ApiToken model to save the appropriate characters in the last_token_characters column.
  3. Backfill existing API token last characters with a migration.

@mdtro mdtro closed this Oct 26, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants