Improve Conan package registry authentication method
requested to merge gitlab-community/gitlab:378826-Improve-Conan-package-registry-authentication-method into master
-
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
totoken_id
- By passing a
personal_token
object, infrom_personal_access_token
method now we can directly accesses related attributes. - Initialization method now accepts
expire_date
parameter.Which is available forfrom_deploy_token
andfrom_personal_access_token
methods - 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.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
- 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.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 (closed)
Edited by Juan Pablo Gonzalez