Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gss.discovery.manual.mapping.regex.framed #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading