Skip to content

Commit

Permalink
Added new composer config commands for composer authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Jun 26, 2024
1 parent 4521fa0 commit 8b7feef
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/PHP/ComposerAuthenticationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Kiboko\Component\Dockerfile\Dockerfile;

/** @deprecated */
final readonly class ComposerAuthenticationToken implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
Expand Down
23 changes: 23 additions & 0 deletions src/PHP/ComposerGithubOauthAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\PHP;

use Kiboko\Component\Dockerfile\Dockerfile;

final readonly class ComposerGithubOauthAuthentication implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
private string $token,
) {
}

public function __toString(): string
{
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
set -ex \
&& composer config --auth github-oauth.github.com %s
RUN, $this->token));
}
}
24 changes: 24 additions & 0 deletions src/PHP/ComposerGitlabOauthAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\PHP;

use Kiboko\Component\Dockerfile\Dockerfile;

final readonly class ComposerGitlabOauthAuthentication implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
private string $token,
private string $instance = 'gitlab.com',
) {
}

public function __toString(): string
{
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
set -ex \
&& composer config --auth gitlab-oauth.%s %s
RUN, $this->instance, $this->token));
}
}
24 changes: 24 additions & 0 deletions src/PHP/ComposerGitlabTokenAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\PHP;

use Kiboko\Component\Dockerfile\Dockerfile;

final readonly class ComposerGitlabTokenAuthentication implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
private string $token,
private string $instance = 'gitlab.com',
) {
}

public function __toString(): string
{
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
set -ex \
&& composer config --auth gitlab-token.%s %s
RUN, $this->instance, $this->token));
}
}
25 changes: 25 additions & 0 deletions src/PHP/ComposerHttpBasicAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\PHP;

use Kiboko\Component\Dockerfile\Dockerfile;

final readonly class ComposerHttpBasicAuthentication implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
private string $url,
private string $username,
private string $password,
) {
}

public function __toString(): string
{
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
set -ex \
&& composer config --auth http-basic.%s %s %s
RUN, $this->url, $this->username, $this->password));
}
}
24 changes: 24 additions & 0 deletions src/PHP/ComposerHttpBearerAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Dockerfile\PHP;

use Kiboko\Component\Dockerfile\Dockerfile;

final readonly class ComposerHttpBearerAuthentication implements Dockerfile\LayerInterface, \Stringable
{
public function __construct(
private string $url,
private string $token,
) {
}

public function __toString(): string
{
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
set -ex \
&& composer config --auth bearer.%s %s
RUN, $this->url, $this->token));
}
}

0 comments on commit 8b7feef

Please sign in to comment.