Skip to content

Improve Conan package registry authentication method

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

co-authored by @oceane_scania

What does this MR do and why?

Improve Conan package registry authentication method

By updating the current methods, we extract the expiration date for personal and deploy tokens.Effectively setting conan token expiration dates based on the personal and deploy tokens.

Summary of changes

  • Rename Parameters from user_id to token_id
  • By passing a personal_token object, in from_personal_access_token method now we can directly accesses related attributes.
  • Initialization method now accepts expire_date parameter.Which is available for from_deploy_token and from_personal_access_tokenmethods
  • Modify API Helper methods for Conan to reflect the changes above mentioned

How to set up and validate locally

For Personal Tokens

  1. Follow the steps for Generating a personal access token in Gitlab
  2. Execute the conan command to authenticate a user with a conan repo using this personal token conan user <gitlab_username> -r gitlab-instance -p <personal_access_token>
  3. Go into Rails Console and look for the last PersonalToken created or by token PersonalToken.last PersonalToken.find_by_token('TokenString')

you should see that the the expires_at field is setup the same as your Gitlab personal token expire date.

For Deploy Tokens

  1. Follow the steps for Generating a Deploy token in Gitlab
  2. Execute the conan command to authenticate a user with a conan repo using a deploy token conan user <deploy_token_username> -r gitlab-instance -p <deploy_token>
  3. Go into Rails Console and look for the last PersonalToken created DeployToken.last you should see that the the expires_at field is setup the same as your Gitlab personal token expire date or the Default date for a deploy token

Related to #378826

Edited by Juan Pablo Gonzalez

Merge request reports