diff --git a/lib/Controller/SlaveController.php b/lib/Controller/SlaveController.php index 905c49f..af17f76 100644 --- a/lib/Controller/SlaveController.php +++ b/lib/Controller/SlaveController.php @@ -8,7 +8,7 @@ namespace OCA\GlobalSiteSelector\Controller; -use OC\Authentication\Token\IToken; +use OC\Authentication\Token\IProvider; use OCA\GlobalSiteSelector\AppInfo\Application; use OCA\GlobalSiteSelector\Exceptions\LocalFederatedShareException; use OCA\GlobalSiteSelector\Exceptions\MasterUrlException; @@ -31,6 +31,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\OCSController; +use OCP\Authentication\Token\IToken; use OCP\IConfig; use OCP\IRequest; use OCP\ISession; @@ -64,6 +65,7 @@ public function __construct( private readonly GlobalScaleService $globalScaleService, private readonly GlobalShareService $globalShareService, private readonly IConfig $config, + private readonly IProvider $authTokenProvider, private readonly LoggerInterface $logger, ) { parent::__construct($appName, $request); @@ -200,6 +202,13 @@ public function autoLogin(string $jwt): RedirectResponse { $this->logger->debug('all good. creating session'); $this->userSession->createSessionToken($this->request, $uid, $uid, null, IToken::REMEMBER); + // ignore the need of password validation on slaves + $token = $this->authTokenProvider->getToken($this->session->getId()); + $scope = $token->getScopeAsArray(); + $scope[IToken::SCOPE_SKIP_PASSWORD_VALIDATION] = true; + $token->setScope($scope); + $this->authTokenProvider->updateToken($token); + $this->slaveService->updateUserById($uid); $this->logger->debug('userdata updated on lus'); diff --git a/tests/unit/lib/Controller/SlaveControllerTest.php b/tests/unit/lib/Controller/SlaveControllerTest.php index 25f1fbf..2d85e7f 100644 --- a/tests/unit/lib/Controller/SlaveControllerTest.php +++ b/tests/unit/lib/Controller/SlaveControllerTest.php @@ -8,6 +8,7 @@ namespace OCA\GlobalSiteSelector\Tests\Unit\Controller; +use OC\Authentication\Token\IProvider; use OCA\GlobalSiteSelector\AppInfo\Application; use OCA\GlobalSiteSelector\Controller\SlaveController; use OCA\GlobalSiteSelector\GlobalSiteSelector; @@ -42,6 +43,7 @@ class SlaveControllerTest extends TestCase { private GlobalShareService $globalShareService; private SlaveService $slaveService; private IConfig $config; + private IProvider $tokenProvider; public function setUp(): void { parent::setUp(); @@ -63,6 +65,7 @@ public function setUp(): void { $this->globalScaleService = $this->createMock(GlobalScaleService::class); $this->globalShareService = $this->createMock(GlobalShareService::class); $this->config = $this->createMock(IConfig::class); + $this->tokenProvider = $this->createMock(IProvider::class); } /** @@ -87,6 +90,7 @@ private function getInstance(array $mockMathods = []) { $this->globalScaleService, $this->globalShareService, $this->config, + $this->tokenProvider, $this->logger ] )->onlyMethods($mockMathods)->getMock();