Skip to content

Commit 44fe196

Browse files
committed
Add sensitive data attribute
1 parent 4b40d4e commit 44fe196

8 files changed

Lines changed: 44 additions & 14 deletions

File tree

modules/core/src/Auth/Source/AdminPassword.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ public function __construct(array $info, array $config)
4545
* @param string $password The password the user wrote.
4646
* @return array Associative array with the users attributes.
4747
*/
48-
protected function login(string $username, string $password): array
49-
{
48+
protected function login(
49+
string $username,
50+
#[\SensitiveParameter]
51+
string $password,
52+
): array {
5053
$config = Configuration::getInstance();
5154
$adminPassword = $config->getString('auth.adminpassword');
5255
if ($adminPassword === '123') {

modules/core/src/Auth/UserPassBase.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function authenticate(Request $request, array &$state): ?Response
263263
* @param string $password The password the user wrote.
264264
* @return array Associative array with the user's attributes.
265265
*/
266-
abstract protected function login(string $username, string $password): array;
266+
abstract protected function login(string $username, #[\SensitiveParameter] string $password): array;
267267

268268

269269
/**
@@ -277,8 +277,12 @@ abstract protected function login(string $username, string $password): array;
277277
* @param string $username The username the user wrote.
278278
* @param string $password The password the user wrote.
279279
*/
280-
public static function handleLogin(string $authStateId, string $username, string $password): Response
281-
{
280+
public static function handleLogin(
281+
string $authStateId,
282+
string $username,
283+
#[\SensitiveParameter]
284+
string $password,
285+
): Response {
282286
// Here we retrieve the state array we saved in the authenticate-function.
283287
$state = Auth\State::loadState($authStateId, self::STAGEID);
284288

modules/core/src/Auth/UserPassOrgBase.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,12 @@ public function authenticate(Request $request, array &$state): ?Response
238238
* @param string $organization The id of the organization the user chose.
239239
* @return array Associative array with the user's attributes.
240240
*/
241-
abstract protected function login(string $username, string $password, string $organization): array;
241+
abstract protected function login(
242+
string $username,
243+
#[\SensitiveParameter]
244+
string $password,
245+
string $organization
246+
): array;
242247

243248

244249
/**
@@ -269,6 +274,7 @@ abstract protected function getOrganizations(): array;
269274
public static function handleLogin(
270275
string $authStateId,
271276
string $username,
277+
#[\SensitiveParameter]
272278
string $password,
273279
string $organization,
274280
): Response {

modules/cron/src/Controller/Cron.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function info(/** @scrutinizer ignore-unused */Request $request): Respons
117117
public function run(
118118
/** @scrutinizer ignore-unused */Request $request,
119119
string $tag,
120+
#[\SensitiveParameter]
120121
string $key,
121122
string $output = 'xhtml',
122123
): Template {

modules/exampleauth/src/Auth/Source/UserPass.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ public function __construct(array $info, array $config)
9393
* @param string $password The password the user wrote.
9494
* @return array Associative array with the users attributes.
9595
*/
96-
protected function login(string $username, string $password): array
97-
{
96+
protected function login(
97+
string $username,
98+
#[\SensitiveParameter]
99+
string $password,
100+
): array {
98101
$userpass = $username . ':' . $password;
99102
if (!array_key_exists($userpass, $this->users)) {
100103
throw new Error\Error(Error\ErrorCodes::WRONGUSERPASS);

modules/saml/hooks/hook_sanitycheck.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ function saml_hook_sanitycheck(array &$hookinfo): void
5353
}
5454
}
5555

56-
function matchingKeyPair(string $publicKey, string $privateKey, ?string $password = null): bool
57-
{
56+
function matchingKeyPair(
57+
string $publicKey,
58+
string $privateKey,
59+
#[\SensitiveParameter]
60+
?string $password = null
61+
): bool {
5862
return openssl_x509_check_private_key($publicKey, [$privateKey, $password]);
5963
}

src/SimpleSAML/Database.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,13 @@ private static function generateInstanceId(Configuration $config): string
152152
* @throws \Exception If an error happens while trying to connect to the database.
153153
* @return \PDO object
154154
*/
155-
private function connect(string $dsn, string $username = null, string $password = null, array $options): PDO
156-
{
155+
private function connect(
156+
string $dsn,
157+
string $username = null,
158+
#[\SensitiveParameter]
159+
string $password = null,
160+
array $options
161+
): PDO {
157162
try {
158163
$db = new PDO($dsn, $username, $password, $options);
159164
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

src/SimpleSAML/XML/Signer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ public function loadPrivateKeyArray(array $privatekey): void
132132
* Default to false.
133133
* @throws \Exception
134134
*/
135-
public function loadPrivateKey(string $location, ?string $pass, bool $full_path = false): void
136-
{
135+
public function loadPrivateKey(
136+
string $location,
137+
#[\SensitiveParameter]
138+
?string $pass,
139+
bool $full_path = false
140+
): void {
137141
$cryptoUtils = new Utils\Crypto();
138142
$keyData = $cryptoUtils->retrieveKey($location, $full_path);
139143

0 commit comments

Comments
 (0)