Skip to content

Commit

Permalink
Merge pull request #15 from GEANT/dv_log_as_debug
Browse files Browse the repository at this point in the history
use debug again
  • Loading branch information
dnmvisser authored Jul 19, 2023
2 parents f62a098 + bb531c2 commit a502401
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions lib/AccountLinker/Store/SQLStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function matchIdentifiableAttributes()
// @todo Check if IDP gives identifiable attributes AT ALL (should be at least one!). Otherwise throw error back to IDP
$count = 0;
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
SimpleSAML_Logger::stats('AccountLinker: Checking for attribute \''.$row['name'].'\'');
SimpleSAML_Logger::debug('AccountLinker: Checking for attribute \''.$row['name'].'\'');
if (isset($this->_attributes[$row['name']])) {
$count++;
//$stmt2 = $dbh->prepare("SELECT a.account_id, a.attributeproperty_id
Expand All @@ -213,17 +213,17 @@ public function matchIdentifiableAttributes()
$stmt3 = $dbh->prepare("SELECT name FROM attributeproperties WHERE attributeproperty_id=:attribute_id");
$stmt3->execute(array(':attribute_id' => $return[1]));
$attribute_name = $stmt3->fetchColumn();
SimpleSAML_Logger::stats('AccountLinker: Found match on attribute \''.$attribute_name .'\' for account id '. $return[0]);
SimpleSAML_Logger::debug('AccountLinker: Found match on attribute \''.$attribute_name .'\' for account id '. $return[0]);
$this->_accountId = $return[0];
return $this->_accountId;
}
}
SimpleSAML_Logger::stats('AccountLinker: Attribute \''.$row['name'].'\' not found in metadata/datastore');
SimpleSAML_Logger::debug('AccountLinker: Attribute \''.$row['name'].'\' not found in metadata/datastore');
}

if ($count === 0) {
$error = 'Could not find any of the attributes to determine who you are';
SimpleSAML_Logger::stats('AccountLinker: EXCEPTION '.$error);
SimpleSAML_Logger::debug('AccountLinker: EXCEPTION '.$error);
#throw new Exception('AccountLinking '.$error );
$this->_handleException();
}
Expand Down Expand Up @@ -333,14 +333,14 @@ public function saveAttributes()
$accountId = $this->_getAccountId();
foreach ($insertValues as $attributePropertyId => $value) {
if (count($value) === 1) {
SimpleSAML_Logger::stats('AccountLinker: Inserting '.$attributeMapping[$attributePropertyId].' => \''.$value[0] . '\'');
SimpleSAML_Logger::debug('AccountLinker: Inserting '.$attributeMapping[$attributePropertyId].' => \''.$value[0] . '\'');
$query .= "(".$accountId.","
.$attributePropertyId.","
.$dbh->quote($value[0])."),";
} else {
// multivalue attribute
foreach ($value as $val) {
SimpleSAML_Logger::stats('AccountLinker: Inserting '.$attributeMapping[$attributePropertyId].' => \''.$val.'\'');
SimpleSAML_Logger::debug('AccountLinker: Inserting '.$attributeMapping[$attributePropertyId].' => \''.$val.'\'');
$query .= "(".$accountId.","
.$attributePropertyId.","
.$dbh->quote($val)."),";
Expand Down Expand Up @@ -412,7 +412,7 @@ public function saveSpEntityId()
':user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? ''
));

SimpleSAML_Logger::stats('AccountLinker: Returning user_id '.$userId);
SimpleSAML_Logger::debug('AccountLinker: Returning user_id '.$userId);
return $userId;
}

Expand All @@ -424,7 +424,7 @@ public function saveSpEntityId()
*/
public function addIdentifiableAttributes()
{
SimpleSAML_Logger::stats('AccountLinker: adding default id attributes for entityid_id: '. $this->_getEntityidId());
SimpleSAML_Logger::debug('AccountLinker: adding default id attributes for entityid_id: '. $this->_getEntityidId());
$dbh = $this->_getStore();
$stmt = $dbh->prepare("INSERT INTO idattributes (attribute_id, entity_id, aorder) VALUES (:attribute_id,:entity_id, :aorder)");
$stmt->execute(array(
Expand Down Expand Up @@ -457,7 +457,7 @@ private function _handleException()
'idp_entityID' => $this->getEntityId()
);
$queryString = $this->_ehsURL.'?'.http_build_query($data);
SimpleSAML_Logger::stats('TAL EHS:'.$queryString);
SimpleSAML_Logger::debug('TAL EHS:'.$queryString);
SimpleSAML_Utilities::redirect($queryString);
}

Expand Down
16 changes: 8 additions & 8 deletions lib/Auth/Process/AccountLinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,32 @@ public function process(&$request)

$this->_store->setRequest($request);

SimpleSAML_Logger::stats('AccountLinker: === BEGIN === ');
SimpleSAML_Logger::debug('AccountLinker: === BEGIN === ');

if ($this->_store->hasEntityId()) {
SimpleSAML_Logger::stats('AccountLinker: entityid '.$this->_store->getEntityId().' is already known here');
SimpleSAML_Logger::stats('AccountLinker: SP entityid '.$this->_store->getSpEntityId() );
SimpleSAML_Logger::debug('AccountLinker: entityid '.$this->_store->getEntityId().' is already known here');
SimpleSAML_Logger::debug('AccountLinker: SP entityid '.$this->_store->getSpEntityId() );
if (!$this->_store->matchIdentifiableAttributes()) {
SimpleSAML_Logger::stats('AccountLinker: no account match found, adding account');
SimpleSAML_Logger::debug('AccountLinker: no account match found, adding account');
$this->_store->addAccount();
$newAccount = true;
}
} else {
SimpleSAML_Logger::stats('AccountLinker: entityid does not exist, adding it');
SimpleSAML_Logger::debug('AccountLinker: entityid does not exist, adding it');
$this->_store->addEntityId();
$this->_store->addIdentifiableAttributes();
SimpleSAML_Logger::stats('AccountLinker: entityid does not exist, adding account');
SimpleSAML_Logger::debug('AccountLinker: entityid does not exist, adding account');
$this->_store->addAccount();
}

SimpleSAML_Logger::stats('AccountLinker: Inserting attributes');
SimpleSAML_Logger::debug('AccountLinker: Inserting attributes');

if ($this->_store->saveAttributes()) {
$request['Attributes'][$this->_accountIdPrefix.':user_id'] = array(
$this->_store->saveSpEntityId()
);

SimpleSAML_Logger::stats('AccountLinker: === END === ');
SimpleSAML_Logger::debug('AccountLinker: === END === ');
}

}
Expand Down

0 comments on commit a502401

Please sign in to comment.