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_idtotoken_id - By passing a
personal_tokenobject, infrom_personal_access_tokenmethod now we can directly accesses related attributes. - Initialization method now accepts
expire_dateparameter.Which is available forfrom_deploy_tokenandfrom_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
- Follow the steps for Generating a personal access token in Gitlab
- 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> - Go into Rails Console and look for the last PersonalToken created or by token
PersonalToken.lastPersonalToken.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
- Follow the steps for Generating a Deploy token in Gitlab
- 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> - Go into Rails Console and look for the last PersonalToken created
DeployToken.lastyou 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 (closed)
Edited by Juan Pablo Gonzalez