@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | { |
| 8 | 8 | public $storage = []; |
| 9 | 9 | |
| 10 | - public function log($level, $message, array $context=[]) |
|
| 10 | + public function log($level, $message, array $context = []) |
|
| 11 | 11 | { |
| 12 | 12 | $this->storage[] = [ |
| 13 | 13 | 'level' => $level, |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @var bool |
| 70 | 70 | */ |
| 71 | - protected $tls=false; |
|
| 71 | + protected $tls = false; |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param Logger $logger |
| 87 | 87 | * @return resource |
| 88 | 88 | */ |
| 89 | - public function __construct(?Iterable $config, Logger $logger) |
|
| 89 | + public function __construct(? Iterable $config, Logger $logger) |
|
| 90 | 90 | { |
| 91 | 91 | $this->setOptions($config); |
| 92 | 92 | $this->logger = $logger; |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function connect(): Ldap |
| 102 | 102 | { |
| 103 | - if($this->binddn === null) { |
|
| 103 | + if ($this->binddn === null) { |
|
| 104 | 104 | $this->logger->warning('no binddn set for ldap connection, you should avoid anonymous bind', [ |
| 105 | 105 | 'category' => get_class($this), |
| 106 | 106 | ]); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if($this->tls === false && substr($this->uri, 0, 5) !== 'ldaps') { |
|
| 109 | + if ($this->tls === false && substr($this->uri, 0, 5) !== 'ldaps') { |
|
| 110 | 110 | $this->logger->warning('neither tls nor ldaps enabled for ldap connection, it is strongly reccommended to encrypt ldap connections', [ |
| 111 | 111 | 'category' => get_class($this), |
| 112 | 112 | ]); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if ($this->connection) { |
| 126 | - if($this->binddn !== null) { |
|
| 126 | + if ($this->binddn !== null) { |
|
| 127 | 127 | $bind = ldap_bind($this->connection, $this->binddn, $this->bindpw); |
| 128 | 128 | |
| 129 | 129 | if ($bind) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param Iterable $config |
| 166 | 166 | * @return Ldap |
| 167 | 167 | */ |
| 168 | - public function setOptions(?Iterable $config=null): Ldap |
|
| 168 | + public function setOptions(? Iterable $config = null) : Ldap |
|
| 169 | 169 | { |
| 170 | 170 | if ($config === null) { |
| 171 | 171 | return $this; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * Set options |
| 77 | 77 | * |
| 78 | 78 | * @param Iterable $config |
| 79 | - * @return Log |
|
| 79 | + * @return Auth |
|
| 80 | 80 | */ |
| 81 | 81 | public function setOptions(?Iterable $config=null): Auth |
| 82 | 82 | { |
@@ -210,7 +210,6 @@ discard block |
||
| 210 | 210 | /** |
| 211 | 211 | * Authenticate |
| 212 | 212 | * |
| 213 | - * @param Iterable $adapters |
|
| 214 | 213 | * @return bool |
| 215 | 214 | */ |
| 216 | 215 | public function requireOne(): bool |
@@ -252,7 +251,7 @@ discard block |
||
| 252 | 251 | /** |
| 253 | 252 | * Get identity |
| 254 | 253 | * |
| 255 | - * @return identity |
|
| 254 | + * @return Identity |
|
| 256 | 255 | */ |
| 257 | 256 | public function getIdentity(): Identity |
| 258 | 257 | { |
@@ -242,7 +242,7 @@ |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $this->logger->warning("all authentication adapter have failed", [ |
| 245 | - 'category' => get_class($this) |
|
| 245 | + 'category' => get_class($this) |
|
| 246 | 246 | ]); |
| 247 | 247 | |
| 248 | 248 | return false; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param Logger $logger |
| 66 | 66 | * @return void |
| 67 | 67 | */ |
| 68 | - public function __construct(?Iterable $config=null, Logger $logger) |
|
| 68 | + public function __construct(? Iterable $config = null, Logger $logger) |
|
| 69 | 69 | { |
| 70 | 70 | $this->logger = $logger; |
| 71 | 71 | $this->setOptions($config); |
@@ -78,27 +78,27 @@ discard block |
||
| 78 | 78 | * @param Iterable $config |
| 79 | 79 | * @return Log |
| 80 | 80 | */ |
| 81 | - public function setOptions(?Iterable $config=null): Auth |
|
| 81 | + public function setOptions(? Iterable $config = null) : Auth |
|
| 82 | 82 | { |
| 83 | - if($config === null) { |
|
| 83 | + if ($config === null) { |
|
| 84 | 84 | return $this; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - foreach($config as $option => $value) { |
|
| 88 | - switch($option) { |
|
| 87 | + foreach ($config as $option => $value) { |
|
| 88 | + switch ($option) { |
|
| 89 | 89 | case 'identity_class': |
| 90 | 90 | case 'attribute_map_class': |
| 91 | 91 | $this->{$option} = (string)$value; |
| 92 | 92 | break; |
| 93 | 93 | |
| 94 | 94 | case 'adapter': |
| 95 | - foreach($value as $name => $adapter) { |
|
| 96 | - if(!isset($adapter['enabled']) || $adapter['enabled'] === '1') { |
|
| 97 | - if(!isset($adapter['class'])) { |
|
| 95 | + foreach ($value as $name => $adapter) { |
|
| 96 | + if (!isset($adapter['enabled']) || $adapter['enabled'] === '1') { |
|
| 97 | + if (!isset($adapter['class'])) { |
|
| 98 | 98 | throw new Exception('class option is required'); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if(isset($adapter['config'])) { |
|
| 101 | + if (isset($adapter['config'])) { |
|
| 102 | 102 | $config = $adapter['config']; |
| 103 | 103 | } else { |
| 104 | 104 | $config = null; |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | * @param Iterable $config |
| 139 | 139 | * @return AdapterInterface |
| 140 | 140 | */ |
| 141 | - public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface |
|
| 141 | + public function addAdapter(string $name, string $class, ? Iterable $config = null) : AdapterInterface |
|
| 142 | 142 | { |
| 143 | - if($this->hasAdapter($name)) { |
|
| 143 | + if ($this->hasAdapter($name)) { |
|
| 144 | 144 | throw new Exception('auth adapter '.$name.' is already registered'); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $adapter = new $class($config, $this->logger); |
| 148 | - if(!($adapter instanceof AdapterInterface)) { |
|
| 148 | + if (!($adapter instanceof AdapterInterface)) { |
|
| 149 | 149 | throw new Exception('auth adapter must include AdapterInterface interface'); |
| 150 | 150 | } |
| 151 | 151 | $this->adapter[$name] = $adapter; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function getAdapter(string $name): AdapterInterface |
| 163 | 163 | { |
| 164 | - if(!$this->hasAdapter($name)) { |
|
| 164 | + if (!$this->hasAdapter($name)) { |
|
| 165 | 165 | throw new Exception('auth adapter '.$name.' is not registered'); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | * @param array $adapters |
| 176 | 176 | * @return array |
| 177 | 177 | */ |
| 178 | - public function getAdapters(array $adapters=[]): array |
|
| 178 | + public function getAdapters(array $adapters = []): array |
|
| 179 | 179 | { |
| 180 | - if(empty($adapter)) { |
|
| 180 | + if (empty($adapter)) { |
|
| 181 | 181 | return $this->adapter; |
| 182 | 182 | } else { |
| 183 | 183 | $list = []; |
| 184 | - foreach($adapter as $name) { |
|
| 185 | - if(!$this->hasAdapter($name)) { |
|
| 184 | + foreach ($adapter as $name) { |
|
| 185 | + if (!$this->hasAdapter($name)) { |
|
| 186 | 186 | throw new Exception('auth adapter '.$name.' is not registered'); |
| 187 | 187 | } |
| 188 | 188 | $list[$name] = $this->adapter[$name]; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | $result = false; |
| 219 | 219 | |
| 220 | - foreach($this->adapter as $name => $adapter) { |
|
| 220 | + foreach ($this->adapter as $name => $adapter) { |
|
| 221 | 221 | try { |
| 222 | 222 | if ($adapter->authenticate()) { |
| 223 | 223 | $this->createIdentity($adapter); |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * Set options |
| 37 | 37 | * |
| 38 | 38 | * @param Iterable $config |
| 39 | - * @return LdapServer |
|
| 39 | + * @return LdapPreauth |
|
| 40 | 40 | */ |
| 41 | 41 | public function setOptions(?Iterable $config=null): LdapServer |
| 42 | 42 | { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param Iterable $config |
| 39 | 39 | * @return LdapServer |
| 40 | 40 | */ |
| 41 | - public function setOptions(?Iterable $config=null): LdapServer |
|
| 41 | + public function setOptions(? Iterable $config = null) : LdapServer |
|
| 42 | 42 | { |
| 43 | 43 | if ($config === null) { |
| 44 | 44 | return $this; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | protected function preauth(string $value): bool |
| 108 | 108 | { |
| 109 | - $parts = explode('|', $value); |
|
| 109 | + $parts = explode('|', $value); |
|
| 110 | 110 | |
| 111 | 111 | if (count($parts) !== 2) { |
| 112 | 112 | $this->logger->warning('invalid header x-preauth value, parts != 2', [ |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | 'category' => get_class($this) |
| 194 | 194 | ]); |
| 195 | 195 | |
| 196 | - $this->ldap_dn = $dn; |
|
| 196 | + $this->ldap_dn = $dn; |
|
| 197 | 197 | |
| 198 | 198 | return true; |
| 199 | 199 | } |
@@ -218,6 +218,6 @@ discard block |
||
| 218 | 218 | $ip_decimal = ip2long($ip); |
| 219 | 219 | $wildcard_decimal = pow(2, (32 - $netmask)) - 1; |
| 220 | 220 | $netmask_decimal = ~ $wildcard_decimal; |
| 221 | - return (($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal)); |
|
| 221 | + return (($ip_decimal&$netmask_decimal) == ($range_decimal&$netmask_decimal)); |
|
| 222 | 222 | } |
| 223 | 223 | } |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param Logger $logger |
| 48 | 48 | * @return void |
| 49 | 49 | */ |
| 50 | - public function __construct(?Iterable $config, Logger $logger) |
|
| 50 | + public function __construct(? Iterable $config, Logger $logger) |
|
| 51 | 51 | { |
| 52 | 52 | $this->logger = $logger; |
| 53 | 53 | $this->setOptions($config); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param Iterable $config |
| 72 | 72 | * @return AdapterInterface |
| 73 | 73 | */ |
| 74 | - public function setOptions(?Iterable $config=null): AdapterInterface |
|
| 74 | + public function setOptions(? Iterable $config = null) : AdapterInterface |
|
| 75 | 75 | { |
| 76 | 76 | if ($config === null) { |
| 77 | 77 | return $this; |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |