Skip to content

Commit

Permalink
adding the MAILSETTINGS['notify_nro'] constant which allows blocking …
Browse files Browse the repository at this point in the history
…sending mails to NRO admins - useful during testing of the infrastructure
  • Loading branch information
twoln committed Mar 20, 2024
1 parent 7c84e28 commit 6016b3c
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 296 deletions.
3 changes: 3 additions & 0 deletions config/Master-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ class Master
'certfilename' => NULL,
'keyfilename' => NULL,
'keypass' => NULL,
'notify_nro' => false, // normally should be set to TRUE abd causes
// notifications being sent to NRO admins when
// important changes are made
];
/**
* List of all supported languages in CAT. Comment some if you want to disable them
Expand Down
12 changes: 7 additions & 5 deletions core/Federation.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,11 @@ public function newIdP($type, $ownerId, $level, $mail = NULL, $bestnameguess = N
$productShort,
$productLong);
/// organisation
$retval = $user->sendMailToUser(sprintf(_("%s in your federation was created"), common\Entity::$nomenclature_participant), $message);
if ($retval === FALSE) {
$this->loggerInstance->debug(2, "Mail to federation admin was NOT sent!\n");
if (\config\Master::MAILSETTINGS['notify_nro']) {
$retval = $user->sendMailToUser(sprintf(_("%s in your federation was created"), common\Entity::$nomenclature_participant), $message);
if ($retval === FALSE) {
$this->loggerInstance->debug(2, "Mail to federation admin was NOT sent!\n");
}
}
}

Expand Down Expand Up @@ -395,8 +397,8 @@ public function requestCertificate($user, $csr, $expiryDays)
$reqserial = $newReq->sendRequestToCa($csr, $revocationPin, $expiryDays);
$this->loggerInstance->writeAudit($user, "NEW", "Certificate request - NRO: ".$this->tld." - serial: ".$reqserial." - subject: ".$csr['SUBJECT']);
$reqQuery = "INSERT INTO federation_servercerts "
."(federation_id, ca_name, request_serial, distinguished_name, status, revocation_pin) "
."VALUES (?, 'eduPKI', ?, ?, 'REQUESTED', ?)";
."(federation_id, ca_name, request_serial, distinguished_name, status, revocation_pin) "
."VALUES (?, 'eduPKI', ?, ?, 'REQUESTED', ?)";
$this->databaseHandle->exec($reqQuery, "siss", $this->tld, $reqserial, $csr['SUBJECT'], $revocationPin);
}

Expand Down
16 changes: 10 additions & 6 deletions web/admin/edit_participant_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@
sprintf(_("the %s %s / %s / (previously known as) '%s' has deleted all properties and is starting over freshly. This means that its not recognisable by its name any more, and it may assume a different name in the future. You will get another mail if and when the name change happens."), $ui->nomenclatureParticipant, strtoupper($myInstOriginal->federation), $myInstOriginal->identifier, $myInstOriginal->name) . "\n\n" .
$bye;
$fed = new core\Federation($myInstOriginal->federation);
foreach ($fed->listFederationAdmins() as $id) {
$user = new core\User($id);
$user->sendMailToUser(sprintf(_("%s: Significant Changes made to %s"), \config\Master::APPEARANCE['productname'], $ui->nomenclatureParticipant), $text);
if (\config\Master::MAILSETTINGS['notify_nro']) {
foreach ($fed->listFederationAdmins() as $id) {
$user = new core\User($id);
$user->sendMailToUser(sprintf(_("%s: Significant Changes made to %s"), \config\Master::APPEARANCE['productname'], $ui->nomenclatureParticipant), $text);
}
}
header("Location: edit_idp.php?inst_id=$instId&wizard=true");
exit;
Expand Down Expand Up @@ -101,9 +103,11 @@
$text .= $bye;
// (currently, send hard-wired to NRO - future: for linked insts, check eduroam DBv2 and send to registered admins directly)
$fed = new core\Federation($myInstOriginal->federation);
foreach ($fed->listFederationAdmins() as $id) {
$user = new core\User($id);
$user->sendMailToUser(sprintf(_("%s: Significant Changes made to %s"), \config\Master::APPEARANCE['productname'], $ui->nomenclatureParticipant), $text);
if (\config\Master::MAILSETTINGS['notify_nro']) {
foreach ($fed->listFederationAdmins() as $id) {
$user = new core\User($id);
$user->sendMailToUser(sprintf(_("%s: Significant Changes made to %s"), \config\Master::APPEARANCE['productname'], $ui->nomenclatureParticipant), $text);
}
}
}

Expand Down
Loading

0 comments on commit 6016b3c

Please sign in to comment.