Skip to content

Set group_id and user_type for human users' personal access tokens

What does this MR do and why?

This MR

  • ensures that when creating a personal access token for human user we set group_id and user_type for the new token
  • ensures that when rotating a personal access token for human user we set group_id and user_type for the new token
  • ensures that Groups::EnterpriseUsers::AssociateService that claims a user, sets group_id to the group ID for the user's personal_access_tokens
  • ensures that Groups::EnterpriseUsers::DisassociateService that disassociates a user from the group, sets group_id to NULL for the user's personal_access_tokens
  • adds DB migration to set group_id based on user_details.enterprise_group_id and user_type based on users.user_type for existing human users' personal_access_tokens

We need to backfill those columns to be able to optimize retrieving personal access tokens for Credentials inventory index page and API endpoints, see #558112 (closed) and !201312 (merged). We will definitely benefit from this denormalization in other parts of the application.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Bogdan Denkovych

Merge request reports

Loading