Skip to content

Commit

Permalink
Create an enum list of configuration options that are allowed to be o…
Browse files Browse the repository at this point in the history
…verriden.
  • Loading branch information
ioigoume committed Jan 9, 2025
1 parent b659110 commit d147818
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Cas/ServiceValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use SimpleSAML\Configuration;
use SimpleSAML\Logger;
use SimpleSAML\Module\casserver\Codebooks\OverrideConfigPropertiesEnum;

/**
* Validates if a CAS service can use server
Expand Down Expand Up @@ -93,7 +94,15 @@ public function checkServiceURL(string $service): ?Configuration
'matchingUrl' => $legalUrl,
'serviceUrl' => $service,
];
if ($configOverride) {
if ($configOverride !== null) {
// We need to remove all the unsupported configuration keys
$supportedProperties = array_column(OverrideConfigPropertiesEnum::cases(), 'value');
$configOverride = array_filter(
$configOverride,
static fn($property) => \in_array($property, $supportedProperties, true),
ARRAY_FILTER_USE_KEY,
);
// Merge the configurations
$serviceConfig = array_merge($serviceConfig, $configOverride);
}
return Configuration::loadFromArray($serviceConfig);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function __construct(
? Configuration::getConfig('module_casserver.php') : $casConfig;
// Saml Validate Responsder
$this->samlValidateResponder = new SamlValidateResponder();
// Service Validator needs the generic casserver configuration. We do not need
// Service Validator needs the generic casserver configuration.
$this->serviceValidator = new ServiceValidator($this->casConfig);
$this->authSource = $source ?? new Simple($this->casConfig->getValue('authsource'));
$this->httpUtils = $httpUtils ?? new Utils\HTTP();
Expand Down

0 comments on commit d147818

Please sign in to comment.