diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2020-04-22 16:52:10 +0300 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-01-26 16:32:19 +0300 |
commit | a7aabdd71f7fd92bacb2ccd603ba1d9b4b7263a0 (patch) | |
tree | da581dd13961ac880acc2b67b54691ff9e25fcae /lib/UserResolver.php | |
parent | 9ed277dc1f6ca60d75ec6293bcde647dce3a5733 (diff) |
introduces a single point of saml attribute interpretations
- solved code duplication on uid mapping attribute determiniation
- a single point for user id normalization
- slightly reduces logic in the Controller
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/UserResolver.php')
-rw-r--r-- | lib/UserResolver.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/UserResolver.php b/lib/UserResolver.php index f355e1de..8a0c43b1 100644 --- a/lib/UserResolver.php +++ b/lib/UserResolver.php @@ -46,7 +46,11 @@ class UserResolver { if($this->userManager->userExists($rawUidCandidate)) { return $rawUidCandidate; } - $sanitized = $this->sanitizeUserIdCandidate($rawUidCandidate); + try { + $sanitized = $this->sanitizeUserIdCandidate($rawUidCandidate); + } catch(\InvalidArgumentException $e) { + $sanitized = ''; + } if($this->userManager->userExists($sanitized)) { return $sanitized; } @@ -78,6 +82,9 @@ class UserResolver { $this->userManager->search($search); } + /** + * @throws \InvalidArgumentException + */ protected function sanitizeUserIdCandidate(string $rawUidCandidate): string { //FIXME: adjusted copy of LDAP's Access::sanitizeUsername(), should go to API $sanitized = trim($rawUidCandidate); |