Skip to content

Commit

Permalink
change getString to getOptionalString where a default is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Jul 2, 2024
1 parent fbf1a21 commit ab2c25d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 2 additions & 4 deletions modules/silauth/src/Auth/Source/system/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use SimpleSAML\Module\silauth\Auth\Source\auth\IdBroker;
use SimpleSAML\Module\silauth\Auth\Source\config\ConfigManager;
use SimpleSAML\Configuration;
use SimpleSAML\Module\silauth\Auth\Source\models\FailedLoginIpAddress;
use \SimpleSAML\Configuration;
use Throwable;

class System
Expand Down Expand Up @@ -46,7 +44,7 @@ protected function isRequiredConfigPresent(): bool
* HTTP_HOST value (provided by the user's request) is used to
* build a trusted URL (see SimpleSaml\Module::authenticate()).
*/
$baseURL = $globalConfig->getString('baseurlpath', '');
$baseURL = $globalConfig->getOptionalString('baseurlpath', '');
$avoidsSecurityHole = (preg_match('#^https?://.*/$#D', $baseURL) === 1);
if (!$avoidsSecurityHole) {
$this->logError('isRequiredConfigPresent failed: baseurlpath (' . $baseURL . ') does not meet requirements');
Expand Down
9 changes: 4 additions & 5 deletions modules/sildisco/public/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
require_once('../public/_include.php');

use SAML2\Constants;
use SimpleSAML\Utils\Auth as Auth;
use SimpleSAML\Utils\Config\Metadata as Metadata;
use SimpleSAML\Utils\Crypto as Crypto;
use SimpleSAML\Utils\HTTP as HTTP;
use SimpleSAML\Utils\Config\Metadata as Metadata;

// load SimpleSAMLphp, configuration and metadata
$config = \SimpleSAML\Configuration::getInstance();
Expand Down Expand Up @@ -135,7 +134,7 @@
));
}

$metaArray['NameIDFormat'] = $idpmeta->getString(
$metaArray['NameIDFormat'] = $idpmeta->getOptionalString(
'NameIDFormat',
'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'
);
Expand Down Expand Up @@ -193,10 +192,10 @@
}
}

$technicalContactEmail = $config->getString('technicalcontact_email', false);
$technicalContactEmail = $config->getOptionalString('technicalcontact_email', false);
if ($technicalContactEmail && $technicalContactEmail !== '[email protected]') {
$techcontact['emailAddress'] = $technicalContactEmail;
$techcontact['name'] = $config->getString('technicalcontact_name', null);
$techcontact['name'] = $config->getOptionalString('technicalcontact_name', null);
$techcontact['contactType'] = 'technical';
$metaArray['contacts'][] = Metadata::getContact($techcontact);
}
Expand Down

0 comments on commit ab2c25d

Please sign in to comment.