Skip to content

Commit

Permalink
gss.discovery.manual.mapping.regex.normalized
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Oct 30, 2023
1 parent 315e544 commit a87e5db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/UserDiscoveryModules/ManualUserMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ManualUserMapping implements IUserDiscoveryModule {
private string $idpParameter;
private string $file;
private bool $useRegularExpressions;
private bool $normalizedKey;

public function __construct(
IConfig $config,
Expand All @@ -53,6 +54,7 @@ public function __construct(
$this->idpParameter = $config->getSystemValueString('gss.discovery.manual.mapping.parameter', '');
$this->file = $config->getSystemValueString('gss.discovery.manual.mapping.file', '');
$this->useRegularExpressions = $config->getSystemValueBool('gss.discovery.manual.mapping.regex', false);
$this->normalizedKey = $config->getSystemValueBool('gss.discovery.manual.mapping.regex.normalized', true);

$this->logger->debug('Init ManualUserMapping');
$this->logger->debug('IdP Parameter: ' . $this->idpParameter);
Expand Down Expand Up @@ -83,7 +85,7 @@ public function getLocation(array $data): string {
// dictionary contains regular expressions
if (!empty($key) && is_array($dictionary) && $this->useRegularExpressions) {
foreach ($dictionary as $regex => $nextcloudNode) {
$this->logger->debug('Testing regex: "' . $regex . '"');
$this->logger->debug('Testing regex="' . $regex . '", key="' . $key . '"');
if (preg_match($regex, $key) === 1) {
$this->logger->debug('Regex matched');
$location = $nextcloudNode;
Expand Down Expand Up @@ -134,6 +136,10 @@ private function getKey($data) {
$this->logger->debug('Could not find idpParamter: ' . $this->idpParameter);
}

if (!$this->normalizedKey) {
return $key;
}

return $this->normalizeKey($key);
}

Expand Down

0 comments on commit a87e5db

Please sign in to comment.