Skip to content

Commit d3d3035

Browse files
committed
Add use-statements
1 parent 3fb9190 commit d3d3035

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

lib/Auth/Source/Hash.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace SimpleSAML\Module\authcrypt\Auth\Source;
44

5+
use SimpleSAML\Logger;
6+
use SimpleSAML\Utils\Attributes;
7+
use SimpleSAML\Utils\Crypto;
58
use Webmozart\Assert\Assert;
69

710
/**
@@ -57,7 +60,7 @@ public function __construct($info, $config)
5760
$passwordhash = $userpass[1];
5861

5962
try {
60-
$attributes = \SimpleSAML\Utils\Attributes::normalizeAttributesArray($attributes);
63+
$attributes = Attributes::normalizeAttributesArray($attributes);
6164
} catch (\Exception $e) {
6265
throw new \Exception('Invalid attributes for user '.$username.
6366
' in authentication source '.$this->authId.': '.
@@ -93,10 +96,10 @@ protected function login($username, $password)
9396
foreach ($this->users as $userpass => $attrs) {
9497
$matches = explode(':', $userpass, 2);
9598
if ($matches[0] === $username) {
96-
if (\SimpleSAML\Utils\Crypto::pwValid($matches[1], $password)) {
99+
if (Crypto::pwValid($matches[1], $password)) {
97100
return $attrs;
98101
} else {
99-
\SimpleSAML\Logger::debug('Incorrect password "'.$password.'" for user '.$username);
102+
Logger::debug('Incorrect password "'.$password.'" for user '.$username);
100103
}
101104
}
102105
}

lib/Auth/Source/Htpasswd.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* @package SimpleSAMLphp
1010
*/
1111

12+
use SimpleSAML\Logger;
13+
use SimpleSAML\Utils\Attributes;
14+
use SimpleSAML\Utils\Crypto;
1215
use Webmozart\Assert\Assert;
1316
use WhiteHat101\Crypt\APR1_MD5;
1417

@@ -55,7 +58,7 @@ public function __construct($info, $config)
5558
$this->users = explode("\n", trim($htpasswd));
5659

5760
try {
58-
$this->attributes = \SimpleSAML\Utils\Attributes::normalizeAttributesArray($config['static_attributes']);
61+
$this->attributes = Attributes::normalizeAttributesArray($config['static_attributes']);
5962
} catch (\Exception $e) {
6063
throw new \Exception('Invalid static_attributes in authentication source '.
6164
$this->authId.': '.$e->getMessage());
@@ -93,23 +96,23 @@ protected function login($username, $password)
9396
$attributes = array_merge(['uid' => [$username]], $this->attributes);
9497

9598
// Traditional crypt(3)
96-
if (\SimpleSAML\Utils\Crypto::secureCompare($crypted, crypt($password, $crypted))) {
97-
\SimpleSAML\Logger::debug('User '.$username.' authenticated successfully');
98-
\SimpleSAML\Logger::warning(
99+
if (Crypto::secureCompare($crypted, crypt($password, $crypted))) {
100+
Logger::debug('User '.$username.' authenticated successfully');
101+
Logger::warning(
99102
'CRYPT authentication is insecure. Please consider using something else.'
100103
);
101104
return $attributes;
102105
}
103106

104107
// Apache's custom MD5
105108
if (APR1_MD5::check($password, $crypted)) {
106-
\SimpleSAML\Logger::debug('User '.$username.' authenticated successfully');
109+
Logger::debug('User '.$username.' authenticated successfully');
107110
return $attributes;
108111
}
109112

110113
// PASSWORD_BCRYPT
111-
if (\SimpleSAML\Utils\Crypto::pwValid($crypted, $password)) {
112-
\SimpleSAML\Logger::debug('User '.$username.' authenticated successfully');
114+
if (Crypto::pwValid($crypted, $password)) {
115+
Logger::debug('User '.$username.' authenticated successfully');
113116
return $attributes;
114117
}
115118
throw new \SimpleSAML\Error\Error('WRONGUSERPASS');

0 commit comments

Comments
 (0)