|
9 | 9 | * @package SimpleSAMLphp |
10 | 10 | */ |
11 | 11 |
|
| 12 | +use SimpleSAML\Logger; |
| 13 | +use SimpleSAML\Utils\Attributes; |
| 14 | +use SimpleSAML\Utils\Crypto; |
12 | 15 | use WhiteHat101\Crypt\APR1_MD5; |
13 | 16 |
|
14 | 17 | class Htpasswd extends \SimpleSAML\Module\core\Auth\UserPassBase |
@@ -53,7 +56,7 @@ public function __construct($info, $config) |
53 | 56 | $this->users = explode("\n", trim($htpasswd)); |
54 | 57 |
|
55 | 58 | try { |
56 | | - $this->attributes = \SimpleSAML\Utils\Attributes::normalizeAttributesArray($config['static_attributes']); |
| 59 | + $this->attributes = Attributes::normalizeAttributesArray($config['static_attributes']); |
57 | 60 | } catch (\Exception $e) { |
58 | 61 | throw new \Exception('Invalid static_attributes in authentication source '. |
59 | 62 | $this->authId.': '.$e->getMessage()); |
@@ -91,23 +94,23 @@ protected function login($username, $password) |
91 | 94 | $attributes = array_merge(['uid' => [$username]], $this->attributes); |
92 | 95 |
|
93 | 96 | // 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( |
97 | 100 | 'CRYPT authentication is insecure. Please consider using something else.' |
98 | 101 | ); |
99 | 102 | return $attributes; |
100 | 103 | } |
101 | 104 |
|
102 | 105 | // Apache's custom MD5 |
103 | 106 | if (APR1_MD5::check($password, $crypted)) { |
104 | | - \SimpleSAML\Logger::debug('User '.$username.' authenticated successfully'); |
| 107 | + Logger::debug('User '.$username.' authenticated successfully'); |
105 | 108 | return $attributes; |
106 | 109 | } |
107 | 110 |
|
108 | 111 | // 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'); |
111 | 114 | return $attributes; |
112 | 115 | } |
113 | 116 | throw new \SimpleSAML\Error\Error('WRONGUSERPASS'); |
|
0 commit comments