Passed
Push — master ( c23af9...047c93 )
by Tim
04:50
created

Ldap::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace SimpleSAML\Module\ldap\Auth\Source;
4
5
use SimpleSAML\Module\ldap\ConfigHelper;
6
use Webmozart\Assert\Assert;
7
8
/**
9
 * LDAP authentication source.
10
 *
11
 * See the ldap-entry in config-templates/authsources.php for information about
12
 * configuration of this authentication source.
13
 *
14
 * This class is based on www/auth/login.php.
15
 *
16
 * @package SimpleSAMLphp
17
 */
18
19
class Ldap extends \SimpleSAML\Module\core\Auth\UserPassBase
20
{
21
    /**
22
     * A LDAP configuration object.
23
     */
24
    private $ldapConfig;
25
26
27
    /**
28
     * Constructor for this authentication source.
29
     *
30
     * @param array $info  Information about this authentication source.
31
     * @param array $config  Configuration.
32
     */
33
    public function __construct(array $info, array $config)
34
    {
35
        // Call the parent constructor first, as required by the interface
36
        parent::__construct($info, $config);
37
38
        $this->ldapConfig = new ConfigHelper(
39
            $config,
40
            'Authentication source ' . var_export($this->authId, true)
41
        );
42
    }
43
44
45
    /**
46
     * Attempt to log in using the given username and password.
47
     *
48
     * @param string $username  The username the user wrote.
49
     * @param string $password  The password the user wrote.
50
     * param array $sasl_arg  Associative array of SASL options
51
     * @return array  Associative array with the users attributes.
52
     */
53
    protected function login(string $username, string $password, array $sasl_args = null): array
54
    {
55
        return $this->ldapConfig->login($username, $password, $sasl_args);
56
    }
57
}
58