Skip to content

Commit 063690e

Browse files
GromNaNfabpot
authored andcommitted
Hide sensitive information with SensitiveParameter attribute
1 parent 788a28d commit 063690e

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

Adapter/ConnectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ public function isBound(): bool;
3232
* @throws ConnectionTimeoutException When the connection can't be created because of an LDAP_TIMEOUT error
3333
* @throws InvalidCredentialsException When the connection can't be created because of an LDAP_INVALID_CREDENTIALS error
3434
*/
35-
public function bind(string $dn = null, string $password = null);
35+
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null);
3636
}

Adapter/ExtLdap/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function isBound(): bool
6969
*
7070
* @param string $password WARNING: When the LDAP server allows unauthenticated binds, a blank $password will always be valid
7171
*/
72-
public function bind(string $dn = null, string $password = null)
72+
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null)
7373
{
7474
if (!$this->connection) {
7575
$this->connect();

Ldap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(AdapterInterface $adapter)
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
public function bind(string $dn = null, string $password = null)
35+
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null)
3636
{
3737
$this->adapter->getConnection()->bind($dn, $password);
3838
}

LdapInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface LdapInterface
3030
*
3131
* @throws ConnectionException if dn / password could not be bound
3232
*/
33-
public function bind(string $dn = null, string $password = null);
33+
public function bind(string $dn = null, #[\SensitiveParameter] string $password = null);
3434

3535
/**
3636
* Queries a ldap server for entries matching the given criteria.

Security/LdapUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class LdapUser implements UserInterface, PasswordAuthenticatedUserInterface, Equ
2929
private array $roles;
3030
private array $extraFields;
3131

32-
public function __construct(Entry $entry, string $username, ?string $password, array $roles = [], array $extraFields = [])
32+
public function __construct(Entry $entry, string $username, #[\SensitiveParameter] ?string $password, array $roles = [], array $extraFields = [])
3333
{
3434
if (!$username) {
3535
throw new \InvalidArgumentException('The username cannot be empty.');
@@ -97,7 +97,7 @@ public function getExtraFields(): array
9797
return $this->extraFields;
9898
}
9999

100-
public function setPassword(string $password)
100+
public function setPassword(#[\SensitiveParameter] string $password)
101101
{
102102
$this->password = $password;
103103
}

Security/LdapUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa
4343
private ?string $passwordAttribute;
4444
private array $extraFields;
4545

46-
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = [], string $uidKey = null, string $filter = null, string $passwordAttribute = null, array $extraFields = [])
46+
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, #[\SensitiveParameter] string $searchPassword = null, array $defaultRoles = [], string $uidKey = null, string $filter = null, string $passwordAttribute = null, array $extraFields = [])
4747
{
4848
if (null === $uidKey) {
4949
$uidKey = 'sAMAccountName';

0 commit comments

Comments
 (0)