Skip to content

Commit dc0da9b

Browse files
ev-gorvjik
andauthored
Fix #92: Use SensitiveParameter attribute to mark sensitive parameters
Co-authored-by: Sergei Predvoditelev <[email protected]>
1 parent eb00e76 commit dc0da9b

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 3.1.2 under development
44

5-
- no changes in this release.
5+
- Enh #92: Use `SensitiveParameter` attribute to mark sensitive parameters (@ev-gor)
66

77
## 3.1.1 May 06, 2024
88

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $authenticationMethod = (new \Yiisoft\Auth\Method\HttpBasic($identityRepository)
6464
->withRealm('Admin')
6565
->withAuthenticationCallback(static function (
6666
?string $username,
67-
?string $password,
67+
#[\SensitiveParameter] ?string $password,
6868
\Yiisoft\Auth\IdentityWithTokenRepositoryInterface $identityRepository
6969
): ?\Yiisoft\Auth\IdentityInterface {
7070
return $identityRepository->findIdentityByToken($username, \Yiisoft\Auth\Method\HttpBasic::class);

src/Method/HttpBasic.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function challenge(ResponseInterface $response): ResponseInterface
6767
*
6868
* ```php
6969
* static function (
70-
* string $username,
71-
* string $password,
70+
* ?string $username,
71+
* #[\SensitiveParameter] ?string $password,
7272
* \Yiisoft\Auth\IdentityRepositoryInterface $identityRepository
7373
* ): ?\Yiisoft\Auth\IdentityInterface
7474
* ```
@@ -159,15 +159,15 @@ private function getTokenFromHeaders(ServerRequestInterface $request): ?string
159159
return $request->getServerParams()['REDIRECT_HTTP_AUTHORIZATION'] ?? null;
160160
}
161161

162-
private function extractCredentialsFromHeader(string $authToken): array
162+
private function extractCredentialsFromHeader(#[\SensitiveParameter] string $authToken): array
163163
{
164164
return array_map(
165165
static fn ($value) => $value === '' ? null : $value,
166166
explode(':', base64_decode(substr($authToken, 6)), 2)
167167
);
168168
}
169169

170-
private function isBasicToken(string $token): bool
170+
private function isBasicToken(#[\SensitiveParameter] string $token): bool
171171
{
172172
return strncasecmp($token, 'basic', 5) === 0;
173173
}

0 commit comments

Comments
 (0)