Skip to content

Commit f947691

Browse files
committed
Add use-statements
1 parent 520d9f4 commit f947691

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lib/Auth/Source/Hash.php

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

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

5+
use SimpleSAML\Logger;
6+
use SimpleSAML\Utils\Attributes;
7+
use SimpleSAML\Utils\Crypto;
8+
59
/**
610
* Authentication source for username & hashed password.
711
*
@@ -55,7 +59,7 @@ public function __construct($info, $config)
5559
$passwordhash = $userpass[1];
5660

5761
try {
58-
$attributes = \SimpleSAML\Utils\Attributes::normalizeAttributesArray($attributes);
62+
$attributes = Attributes::normalizeAttributesArray($attributes);
5963
} catch (\Exception $e) {
6064
throw new \Exception('Invalid attributes for user '.$username.
6165
' in authentication source '.$this->authId.': '.
@@ -91,10 +95,10 @@ protected function login($username, $password)
9195
foreach ($this->users as $userpass => $attrs) {
9296
$matches = explode(':', $userpass, 2);
9397
if ($matches[0] === $username) {
94-
if (\SimpleSAML\Utils\Crypto::pwValid($matches[1], $password)) {
98+
if (Crypto::pwValid($matches[1], $password)) {
9599
return $attrs;
96100
} else {
97-
\SimpleSAML\Logger::debug('Incorrect password "'.$password.'" for user '.$username);
101+
Logger::debug('Incorrect password "'.$password.'" for user '.$username);
98102
}
99103
}
100104
}

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 WhiteHat101\Crypt\APR1_MD5;
1316

1417
class Htpasswd extends \SimpleSAML\Module\core\Auth\UserPassBase
@@ -53,7 +56,7 @@ public function __construct($info, $config)
5356
$this->users = explode("\n", trim($htpasswd));
5457

5558
try {
56-
$this->attributes = \SimpleSAML\Utils\Attributes::normalizeAttributesArray($config['static_attributes']);
59+
$this->attributes = Attributes::normalizeAttributesArray($config['static_attributes']);
5760
} catch (\Exception $e) {
5861
throw new \Exception('Invalid static_attributes in authentication source '.
5962
$this->authId.': '.$e->getMessage());
@@ -91,23 +94,23 @@ protected function login($username, $password)
9194
$attributes = array_merge(['uid' => [$username]], $this->attributes);
9295

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

102105
// Apache's custom MD5
103106
if (APR1_MD5::check($password, $crypted)) {
104-
\SimpleSAML\Logger::debug('User '.$username.' authenticated successfully');
107+
Logger::debug('User '.$username.' authenticated successfully');
105108
return $attributes;
106109
}
107110

108111
// PASSWORD_BCRYPT
109-
if (\SimpleSAML\Utils\Crypto::pwValid($crypted, $password)) {
110-
\SimpleSAML\Logger::debug('User '.$username.' authenticated successfully');
112+
if (Crypto::pwValid($crypted, $password)) {
113+
Logger::debug('User '.$username.' authenticated successfully');
111114
return $attributes;
112115
}
113116
throw new \SimpleSAML\Error\Error('WRONGUSERPASS');

0 commit comments

Comments
 (0)