adjust to recent merged changes

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2021-01-26 14:38:51 +01:00
parent c06679fa74
commit b13a9983e2
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
6 changed files with 10 additions and 9 deletions

View File

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

View File

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

View File

@ -100,7 +100,12 @@ class UserData {
* base64-encoded binary string representing e.g. the objectGUID. Otherwise * 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); $candidate = base64_decode($uid, true);
if($candidate === false) { if($candidate === false) {
return $uid; return $uid;

View File

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

View File

@ -287,9 +287,4 @@ class UserBackendTest extends TestCase {
$this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname', 'quota' => '']); $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']
} }

View File

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