Skip to content

Commit

Permalink
Add log message for new users without a distinguished_name value.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrencegf committed Apr 7, 2020
1 parent 8e14a82 commit e49003e
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions src/Service/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ public static function printCertInfo()
</tr>';
}
$idp = Util::getSessionVar('idp');
$idp_display_name = Util::getSessionVar('idp_display_name');
if (Util::isEduGAINAndGetCert()) {
$idplist = Util::getIdpList();
if (!$idplist->isREFEDSRandS($idp)) {
Expand Down Expand Up @@ -2472,28 +2471,25 @@ public static function gotUserSuccess()
$clientparams = json_decode(Util::getSessionVar('clientparams'), true);
$callbackuri = Util::getSessionVar('callbackuri');

if (
($status == DBService::$STATUS['STATUS_NEW_USER']) &&
((strlen($callbackuri) > 0) ||
(isset($clientparams['code'])))
) {
// Extra check for new users: see if any HTML entities
// are in the user name. If so, send an email alert.
// Log new users with possibly empty distinguished_name values
if ($status == DBService::$STATUS['STATUS_NEW_USER']) {
$dn = Util::getSessionVar('distinguished_name');
$dn = static::reformatDN(preg_replace('/\s+email=.+$/', '', $dn));
$htmldn = Util::htmlent($dn);
if (strcmp($dn, $htmldn) != 0) {
Util::sendErrorAlert(
'New user DN contains HTML entities',
"htmlentites(DN) = $htmldn\n"
);
$log->info('New User' . ((strlen($dn) == 0) ? ' without a distinguished_name.' : '.'));
// If HTML entities are in the distinguished_name, send an alert.
if (
(strlen($dn) > 0) &&
((strlen($callbackuri) > 0) ||
(isset($clientparams['code'])))
) {
$dn = static::reformatDN(preg_replace('/\s+email=.+$/', '', $dn));
$htmldn = Util::htmlent($dn);
if (strcmp($dn, $htmldn) != 0) {
Util::sendErrorAlert(
'New user DN contains HTML entities',
"htmlentites(DN) = $htmldn\n"
);
}
}
}

// For a new user, or if the user got new attributes, just log it.
// Then proceed to the Main Page.
if ($status == DBService::$STATUS['STATUS_NEW_USER']) {
$log->info('New User.');
} elseif ($status == DBService::$STATUS['STATUS_USER_UPDATED']) {
$log->info('User IdP attributes changed.');
}
Expand Down

0 comments on commit e49003e

Please sign in to comment.