Browse Source

adjust to recent merged changes

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
master
Arthur Schiwon 1 year ago
parent
commit
b13a9983e2
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
  1. 2
      lib/Controller/SAMLController.php
  2. 2
      lib/UserBackend.php
  3. 7
      lib/UserData.php
  4. 1
      tests/unit/Controller/SAMLControllerTest.php
  5. 5
      tests/unit/UserBackendTest.php
  6. 2
      tests/unit/UserDataTest.php

2
lib/Controller/SAMLController.php

@ -354,7 +354,7 @@ class SAMLController extends Controller {
$this->userBackend->initializeHomeDir($user->getUID());
}
} catch (NoUserFoundException $e) {
throw new \InvalidArgumentException('User is not valid');
throw new \InvalidArgumentException('User "' . $this->userBackend->getCurrentUserId() . '" is not valid');
} catch (\Exception $e) {
$this->logger->logException($e, ['app' => $this->appName]);
$response = new Http\RedirectResponse($this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.notProvisioned'));

2
lib/UserBackend.php

@ -490,7 +490,7 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
$this->userData->setAttributes($this->session->get('user_saml.samlUserData') ?? []);
$uid = $this->userData->getEffectiveUid();
if($uid !== '' && $this->userExists($uid)) {
$uid = $this->testEncodedObjectGUID($uid);
$uid = $this->userData->testEncodedObjectGUID($uid);
$this->session->set('last-password-confirm', strtotime('+4 year', time()));
return $uid;

7
lib/UserData.php

@ -100,7 +100,12 @@ class UserData {
* base64-encoded binary string representing e.g. the objectGUID. Otherwise
*
*/
protected function testEncodedObjectGUID(string $uid): string {
public function testEncodedObjectGUID(string $uid): string {
if (preg_match('/[^a-zA-Z0-9=+\/]/', $uid) !== 0) {
// certainly not encoded
return $uid;
}
$candidate = base64_decode($uid, true);
if($candidate === false) {
return $uid;

1
tests/unit/Controller/SAMLControllerTest.php

@ -39,7 +39,6 @@ use OCP\IUser;
use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
use OCP\Security\ICrypto;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class SAMLControllerTest extends TestCase {

5
tests/unit/UserBackendTest.php

@ -287,9 +287,4 @@ class UserBackendTest extends TestCase {
$this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname', 'quota' => '']);
}
['aaabbbcc@aa.bbbccdd.eee.ff', 'aaabbbcc@aa.bbbccdd.eee.ff'],
['aaabbbcccaa.bbbccdddeee', 'aaabbbcccaa.bbbccdddeee']
}

2
tests/unit/UserDataTest.php

@ -58,6 +58,8 @@ class UserDataTest extends TestCase {
['EDE70D16-B9D5-4E9A-ABD7-614D17246E3F', 'EDE70D16-B9D5-4E9A-ABD7-614D17246E3F'],
['Tm8gY29udmVyc2lvbgo=', 'Tm8gY29udmVyc2lvbgo='],
['ASfjU2OYEd69ZgAVF4pePA==', '53E32701-9863-DE11-BD66-0015178A5E3C'],
['aaabbbcc@aa.bbbccdd.eee.ff', 'aaabbbcc@aa.bbbccdd.eee.ff'],
['aaabbbcccaa.bbbccdddeee', 'aaabbbcccaa.bbbccdddeee']
];
}

Loading…
Cancel
Save