Skip to content

Commit

Permalink
Fix regex for gitlab tokens. (#427)
Browse files Browse the repository at this point in the history
* Fix regex for gitlab tokens.

* Install terminus using phar file.

* Breakout curl statement into two lines

Co-authored-by: Ryan Marks <[email protected]>
  • Loading branch information
kporras07 and Ryan Marks authored Jan 28, 2022
1 parent 9c33cbd commit 4c3eb3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .circleci/set-up-globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ set -ex
# Update terminus temporarily.
rm /usr/local/bin/terminus
mkdir ~/terminus && cd ~/terminus
curl -L https://github.com/pantheon-systems/terminus/releases/download/`curl --silent "https://api.github.com/repos/pantheon-systems/terminus/releases/latest" | perl -nle'print $& while m#"tag_name": "\K[^"]*#g'`/terminus.phar --output terminus
TERMINUS_RELEASE=$(curl --silent "https://api.github.com/repos/pantheon-systems/terminus/releases/latest" | perl -nle'print $& while m#"tag_name": "\K[^"]*#g')
curl -L https://github.com/pantheon-systems/terminus/releases/download/$TERMINUS_RELEASE/terminus.phar --output terminus
chmod +x terminus
ln -s ~/terminus/terminus /usr/local/bin/terminus
terminus self:info
Expand Down
4 changes: 2 additions & 2 deletions src/API/GitLab/GitLabAPITrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function credentialRequests()
{
$instructions = "Please generate a GitLab personal access token by visiting the page:\n\n https://" . $this->getGitLabUrl() . "/profile/personal_access_tokens\n\n For more information, see:\n\n https://" . $this->getGitLabUrl() . "/help/user/profile/personal_access_tokens.md.\n\n Give it the 'api', 'read_repository', and 'write_repository' (required) scopes.";

$validation_message = 'GitLab authentication tokens should be 20-character strings containing only the letters a-z and digits (0-9). Please enter your token again.';
$validation_message = 'GitLab authentication tokens should be 20 or 26 characters strings containing only the letters a-z and digits (0-9). Please enter your token again.';

$could_not_authorize = 'Your provided authentication token could not be used to authenticate with the GitLab service. Please re-enter your credential.';

Expand All @@ -77,7 +77,7 @@ public function credentialRequests()
$gitlabTokenRequest = (new CredentialRequest($this->tokenKey()))
->setInstructions($instructions)
->setPrompt("Enter GitLab personal access token: ")
->setValidateRegEx('#^[0-9a-zA-Z\-_]{20}$#')
->setValidateRegEx('#^[0-9a-zA-Z\-_]{20,26}$#')
->setValidationErrorMessage($validation_message)
->setValidationCallbackErrorMessage($could_not_authorize)
->setValidateFn(
Expand Down

0 comments on commit 4c3eb3a

Please sign in to comment.