Skip to content
Snippets Groups Projects
Unverified Commit a30c0417 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files
parent 3cc613e9
No related branches found
No related tags found
No related merge requests found
...@@ -8,27 +8,24 @@ ...@@ -8,27 +8,24 @@
* *
* @package SimpleSAMLphp * @package SimpleSAMLphp
*/ */
class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase
{
/** /**
* The DSN we should connect to. * The DSN we should connect to.
*/ */
private $dsn; private $dsn;
/** /**
* The username we should connect to the database with. * The username we should connect to the database with.
*/ */
private $username; private $username;
/** /**
* The password we should connect to the database with. * The password we should connect to the database with.
*/ */
private $password; private $password;
/** /**
* The query we should use to retrieve the attributes for the user. * The query we should use to retrieve the attributes for the user.
* *
...@@ -36,14 +33,14 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { ...@@ -36,14 +33,14 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
*/ */
private $query; private $query;
/** /**
* Constructor for this authentication source. * Constructor for this authentication source.
* *
* @param array $info Information about this authentication source. * @param array $info Information about this authentication source.
* @param array $config Configuration. * @param array $config Configuration.
*/ */
public function __construct($info, $config) { public function __construct($info, $config)
{
assert(is_array($info)); assert(is_array($info));
assert(is_array($config)); assert(is_array($config));
...@@ -77,7 +74,8 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { ...@@ -77,7 +74,8 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
* *
* @return PDO The database connection. * @return PDO The database connection.
*/ */
private function connect() { private function connect()
{
try { try {
$db = new PDO($this->dsn, $this->username, $this->password); $db = new PDO($this->dsn, $this->username, $this->password);
} catch (PDOException $e) { } catch (PDOException $e) {
...@@ -87,7 +85,6 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { ...@@ -87,7 +85,6 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$driver = explode(':', $this->dsn, 2); $driver = explode(':', $this->dsn, 2);
$driver = strtolower($driver[0]); $driver = strtolower($driver[0]);
...@@ -120,7 +117,8 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { ...@@ -120,7 +117,8 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
* @param string $password The password the user wrote. * @param string $password The password the user wrote.
* @return array Associative array with the users attributes. * @return array Associative array with the users attributes.
*/ */
protected function login($username, $password) { protected function login($username, $password)
{
assert(is_string($username)); assert(is_string($username));
assert(is_string($password)); assert(is_string($password));
...@@ -134,7 +132,7 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { ...@@ -134,7 +132,7 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
} }
try { try {
$res = $sth->execute(array('username' => $username, 'password' => $password)); $sth->execute(array('username' => $username, 'password' => $password));
} catch (PDOException $e) { } catch (PDOException $e) {
throw new Exception('sqlauth:' . $this->authId . throw new Exception('sqlauth:' . $this->authId .
': - Failed to execute query: ' . $e->getMessage()); ': - Failed to execute query: ' . $e->getMessage());
...@@ -165,7 +163,7 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { ...@@ -165,7 +163,7 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
foreach ($data as $row) { foreach ($data as $row) {
foreach ($row as $name => $value) { foreach ($row as $name => $value) {
if ($value === NULL) { if ($value === null) {
continue; continue;
} }
...@@ -189,5 +187,4 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { ...@@ -189,5 +187,4 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase {
return $attributes; return $attributes;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment