Skip to content

Commit

Permalink
Improve support for GitLab personal access tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
codedmonkey committed Aug 1, 2024
1 parent 889dcc6 commit 930a578
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/Composer/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public static function createForRegistry(Registry $registry): Config
],
],
]);
} elseif ($credentials?->getType() === CredentialsType::GitlabPersonalAccessToken) {
$config->merge([
'config' => [
'gitlab-token' => [
$registry->getDomain() => [
'username' => $credentials->getToken(),
'token' => 'private-token',
],
],
],
]);
}

return $config;
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/Dashboard/DashboardCredentialsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ public function configureFields(string $pageName): iterable
->onlyOnForms();
yield TextField::new('password')
->onlyOnForms();
yield TextField::new('token')
->onlyOnForms();
}
}
13 changes: 13 additions & 0 deletions src/Doctrine/Entity/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Credentials
#[Column(nullable: true)]
private ?string $password = null;

#[Column(nullable: true)]
private ?string $token = null;

public function getId(): ?int
{
return $this->id;
Expand Down Expand Up @@ -91,4 +94,14 @@ public function setPassword(?string $password): void
{
$this->password = $password;
}

public function getToken(): ?string
{
return $this->token;
}

public function setToken(?string $token): void
{
$this->token = $token;
}
}
2 changes: 1 addition & 1 deletion src/Doctrine/Entity/CredentialsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ enum CredentialsType: string
{
case HttpBasic = 'http-basic';
case GitlabOauth = 'gitlab-oauth';
case GitlabToken = 'gitlab-token';
case GitlabPersonalAccessToken = 'gitlab-pat';
}
2 changes: 1 addition & 1 deletion translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ credentials:
type:
http-basic: HTTP Basic credentials
gitlab-oauth: GitLab OAuth token
gitlab-token: GitLab access token
gitlab-pat: GitLab personal access token
registry:
package_mirroring:
none: Package mirroring disabled
Expand Down

0 comments on commit 930a578

Please sign in to comment.