Skip to content

Commit 8b7feef

Browse files
committed
Added new composer config commands for composer authentication
1 parent 4521fa0 commit 8b7feef

6 files changed

+121
-0
lines changed

src/PHP/ComposerAuthenticationToken.php

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Kiboko\Component\Dockerfile\Dockerfile;
88

9+
/** @deprecated */
910
final readonly class ComposerAuthenticationToken implements Dockerfile\LayerInterface, \Stringable
1011
{
1112
public function __construct(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Dockerfile\PHP;
6+
7+
use Kiboko\Component\Dockerfile\Dockerfile;
8+
9+
final readonly class ComposerGithubOauthAuthentication implements Dockerfile\LayerInterface, \Stringable
10+
{
11+
public function __construct(
12+
private string $token,
13+
) {
14+
}
15+
16+
public function __toString(): string
17+
{
18+
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
19+
set -ex \
20+
&& composer config --auth github-oauth.github.com %s
21+
RUN, $this->token));
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Dockerfile\PHP;
6+
7+
use Kiboko\Component\Dockerfile\Dockerfile;
8+
9+
final readonly class ComposerGitlabOauthAuthentication implements Dockerfile\LayerInterface, \Stringable
10+
{
11+
public function __construct(
12+
private string $token,
13+
private string $instance = 'gitlab.com',
14+
) {
15+
}
16+
17+
public function __toString(): string
18+
{
19+
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
20+
set -ex \
21+
&& composer config --auth gitlab-oauth.%s %s
22+
RUN, $this->instance, $this->token));
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Dockerfile\PHP;
6+
7+
use Kiboko\Component\Dockerfile\Dockerfile;
8+
9+
final readonly class ComposerGitlabTokenAuthentication implements Dockerfile\LayerInterface, \Stringable
10+
{
11+
public function __construct(
12+
private string $token,
13+
private string $instance = 'gitlab.com',
14+
) {
15+
}
16+
17+
public function __toString(): string
18+
{
19+
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
20+
set -ex \
21+
&& composer config --auth gitlab-token.%s %s
22+
RUN, $this->instance, $this->token));
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Dockerfile\PHP;
6+
7+
use Kiboko\Component\Dockerfile\Dockerfile;
8+
9+
final readonly class ComposerHttpBasicAuthentication implements Dockerfile\LayerInterface, \Stringable
10+
{
11+
public function __construct(
12+
private string $url,
13+
private string $username,
14+
private string $password,
15+
) {
16+
}
17+
18+
public function __toString(): string
19+
{
20+
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
21+
set -ex \
22+
&& composer config --auth http-basic.%s %s %s
23+
RUN, $this->url, $this->username, $this->password));
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Dockerfile\PHP;
6+
7+
use Kiboko\Component\Dockerfile\Dockerfile;
8+
9+
final readonly class ComposerHttpBearerAuthentication implements Dockerfile\LayerInterface, \Stringable
10+
{
11+
public function __construct(
12+
private string $url,
13+
private string $token,
14+
) {
15+
}
16+
17+
public function __toString(): string
18+
{
19+
return (string) new Dockerfile\Run(sprintf(<<<'RUN'
20+
set -ex \
21+
&& composer config --auth bearer.%s %s
22+
RUN, $this->url, $this->token));
23+
}
24+
}

0 commit comments

Comments
 (0)