Skip to content

Commit eb10e44

Browse files
committed
adjust to recent merged changes
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 1edd3ce commit eb10e44

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

lib/Controller/SAMLController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function assertionConsumerService(): Http\RedirectResponse {
354354
$this->userBackend->initializeHomeDir($user->getUID());
355355
}
356356
} catch (NoUserFoundException $e) {
357-
throw new \InvalidArgumentException('User is not valid');
357+
throw new \InvalidArgumentException('User "' . $this->userBackend->getCurrentUserId() . '" is not valid');
358358
} catch (\Exception $e) {
359359
$this->logger->logException($e, ['app' => $this->appName]);
360360
$response = new Http\RedirectResponse($this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.notProvisioned'));

lib/UserBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ public function getCurrentUserId() {
490490
$this->userData->setAttributes($this->session->get('user_saml.samlUserData') ?? []);
491491
$uid = $this->userData->getEffectiveUid();
492492
if($uid !== '' && $this->userExists($uid)) {
493-
$uid = $this->testEncodedObjectGUID($uid);
493+
$uid = $this->userData->testEncodedObjectGUID($uid);
494494

495495
$this->session->set('last-password-confirm', strtotime('+4 year', time()));
496496
return $uid;

lib/UserData.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ protected function extractSamlUserId(): string {
100100
* base64-encoded binary string representing e.g. the objectGUID. Otherwise
101101
*
102102
*/
103-
protected function testEncodedObjectGUID(string $uid): string {
103+
public function testEncodedObjectGUID(string $uid): string {
104+
if (preg_match('/[^a-zA-Z0-9=+\/]/', $uid) !== 0) {
105+
// certainly not encoded
106+
return $uid;
107+
}
108+
104109
$candidate = base64_decode($uid, true);
105110
if($candidate === false) {
106111
return $uid;

tests/unit/Controller/SAMLControllerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use OCP\IUserSession;
4040
use PHPUnit\Framework\MockObject\MockObject;
4141
use OCP\Security\ICrypto;
42-
use PHPUnit\Framework\MockObject\MockObject;
4342
use Test\TestCase;
4443

4544
class SAMLControllerTest extends TestCase {

tests/unit/UserBackendTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,4 @@ public function testUpdateAttributesQuotaDefaultFallback() {
287287
$this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname', 'quota' => '']);
288288
}
289289

290-
['aaabbbcc@aa.bbbccdd.eee.ff', 'aaabbbcc@aa.bbbccdd.eee.ff'],
291-
['aaabbbcccaa.bbbccdddeee', 'aaabbbcccaa.bbbccdddeee']
292-
293-
294-
295290
}

tests/unit/UserDataTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function objectGuidProvider() {
5858
['EDE70D16-B9D5-4E9A-ABD7-614D17246E3F', 'EDE70D16-B9D5-4E9A-ABD7-614D17246E3F'],
5959
['Tm8gY29udmVyc2lvbgo=', 'Tm8gY29udmVyc2lvbgo='],
6060
['ASfjU2OYEd69ZgAVF4pePA==', '53E32701-9863-DE11-BD66-0015178A5E3C'],
61+
['aaabbbcc@aa.bbbccdd.eee.ff', 'aaabbbcc@aa.bbbccdd.eee.ff'],
62+
['aaabbbcccaa.bbbccdddeee', 'aaabbbcccaa.bbbccdddeee']
6163
];
6264
}
6365

0 commit comments

Comments
 (0)