Skip to content

Commit 8fb301e

Browse files
Mark authentication parameters sensitive
1 parent c98669a commit 8fb301e

5 files changed

Lines changed: 6 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
* Add PHP 8.5 support
1111
* Add support for `symfony/options-resolver:^8.0`
12+
* Add sensitive parameter annotations for authentication, trigger tokens, and user passwords
1213
* Add support for `force` in `Repositories::createCommit`
1314
* Add support for personal access tokens
1415
* Add support for project access token filters and rotation

src/Api/Projects.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function removeTrigger(int|string $project_id, int $trigger_id): mixed
251251
return $this->delete($this->getProjectPath($project_id, 'triggers/'.self::encodePath($trigger_id)));
252252
}
253253

254-
public function triggerPipeline(int|string $project_id, string $ref, string $token, array $variables = []): mixed
254+
public function triggerPipeline(int|string $project_id, string $ref, #[\SensitiveParameter] string $token, array $variables = []): mixed
255255
{
256256
return $this->post($this->getProjectPath($project_id, 'trigger/pipeline'), [
257257
'ref' => $ref,

src/Api/Users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function user(): mixed
281281
return $this->get('user');
282282
}
283283

284-
public function create(string $email, string $password, array $params = []): mixed
284+
public function create(string $email, #[\SensitiveParameter] string $password, array $params = []): mixed
285285
{
286286
$params['email'] = $email;
287287
$params['password'] = $password;

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public function wiki(): Wiki
325325
* @param string $token Gitlab private token
326326
* @param string $authMethod One of the AUTH_* class constants
327327
*/
328-
public function authenticate(string $token, string $authMethod, ?string $sudo = null): void
328+
public function authenticate(#[\SensitiveParameter] string $token, string $authMethod, ?string $sudo = null): void
329329
{
330330
$this->getHttpClientBuilder()->removePlugin(Authentication::class);
331331
$this->getHttpClientBuilder()->addPlugin(new Authentication($authMethod, $token, $sudo));

src/HttpClient/Plugin/Authentication.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class Authentication implements Plugin
3636
*/
3737
private readonly array $headers;
3838

39-
public function __construct(string $method, string $token, ?string $sudo = null)
39+
public function __construct(string $method, #[\SensitiveParameter] string $token, ?string $sudo = null)
4040
{
4141
$this->headers = self::buildHeaders($method, $token, $sudo);
4242
}
@@ -62,7 +62,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
6262
*
6363
* @return array<string,string>
6464
*/
65-
private static function buildHeaders(string $method, string $token, ?string $sudo = null): array
65+
private static function buildHeaders(string $method, #[\SensitiveParameter] string $token, ?string $sudo = null): array
6666
{
6767
$headers = [];
6868

0 commit comments

Comments
 (0)