Definition at line 11 of file SQL.php.
◆ __construct()
sspmod_sqlauth_Auth_Source_SQL::__construct |
( |
|
$info, |
|
|
|
$config |
|
) |
| |
Constructor for this authentication source.
- Parameters
-
array | $info | Information about this authentication source. |
array | $config | Configuration. |
Definition at line 46 of file SQL.php.
References $config, $info, array, and to.
47 assert(
'is_array($info)');
48 assert(
'is_array($config)');
54 foreach (
array(
'dsn',
'username',
'password',
'query') as $param) {
55 if (!array_key_exists($param,
$config)) {
56 throw new Exception(
'Missing required attribute \'' . $param .
57 '\' for authentication source
' . $this->authId); 60 if (!is_string($config[$param])) { 61 throw new Exception('Expected parameter \
'' . $param .
62 '\' for authentication source
' . $this->authId . 63 ' to be a
string. Instead it was:
' . 64 var_export($config[$param], TRUE)); 68 $this->dsn = $config['dsn
']; 69 $this->username = $config['username
']; 70 $this->password = $config['password
']; 71 $this->query = $config['query
'];
Create styles array
The data for the language used.
◆ connect()
sspmod_sqlauth_Auth_Source_SQL::connect |
( |
| ) |
|
|
private |
Create a database connection.
- Returns
- PDO The database connection.
Definition at line 80 of file SQL.php.
82 $db =
new PDO($this->dsn, $this->username, $this->password);
83 }
catch (PDOException $e) {
84 throw new Exception(
'sqlauth:' . $this->authId .
': - Failed to connect to \'' .
85 $this->dsn .
'\':
'. $e->getMessage()); 88 $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 91 $driver = explode(':
', $this->dsn, 2); 92 $driver = strtolower($driver[0]); 94 /* Driver specific initialization. */ 98 $db->exec("SET NAMES 'utf8mb4
'"); 102 $db->exec("SET NAMES 'UTF8
'");
◆ login()
sspmod_sqlauth_Auth_Source_SQL::login |
( |
|
$username, |
|
|
|
$password |
|
) |
| |
|
protected |
Attempt to log in using the given username and password.
On a successful login, this function should return the users attributes. On failure, it should throw an exception. If the error was caused by the user entering the wrong username or password, a SimpleSAML_Error_Error('WRONGUSERPASS') should be thrown.
Note that both the username and the password are UTF-8 encoded.
- Parameters
-
string | $username | The username the user wrote. |
string | $password | The password the user wrote. |
- Returns
- array Associative array with the users attributes.
Definition at line 123 of file SQL.php.
124 assert(
'is_string($username)');
125 assert(
'is_string($password)');
130 $sth = $db->prepare($this->query);
131 }
catch (PDOException $e) {
132 throw new Exception(
'sqlauth:' . $this->authId .
133 ': - Failed to prepare query: ' . $e->getMessage());
138 }
catch (PDOException $e) {
139 throw new Exception(
'sqlauth:' . $this->authId .
140 ': - Failed to execute query: ' . $e->getMessage());
144 $data = $sth->fetchAll(PDO::FETCH_ASSOC);
145 }
catch (PDOException $e) {
146 throw new Exception(
'sqlauth:' . $this->authId .
147 ': - Failed to fetch result set: ' . $e->getMessage());
151 ' rows from database');
153 if (count(
$data) === 0) {
156 ': No rows in result set. Probably wrong username/password.');
166 foreach ($row as
$name => $value) {
168 if ($value === NULL) {
$username
The username we should connect to the database with.
$password
The password we should connect to the database with.
connect()
Create a database connection.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
◆ $dsn
sspmod_sqlauth_Auth_Source_SQL::$dsn |
|
private |
The DSN we should connect to.
Definition at line 17 of file SQL.php.
◆ $password
sspmod_sqlauth_Auth_Source_SQL::$password |
|
private |
The password we should connect to the database with.
Definition at line 29 of file SQL.php.
◆ $query
sspmod_sqlauth_Auth_Source_SQL::$query |
|
private |
The query we should use to retrieve the attributes for the user.
The username and password will be available as :username and :password.
Definition at line 37 of file SQL.php.
◆ $username
sspmod_sqlauth_Auth_Source_SQL::$username |
|
private |
The username we should connect to the database with.
Definition at line 23 of file SQL.php.
The documentation for this class was generated from the following file:
- libs/composer/vendor/simplesamlphp/simplesamlphp/modules/sqlauth/lib/Auth/Source/SQL.php