diff --git a/module/VuFind/src/VuFind/Auth/AbstractBase.php b/module/VuFind/src/VuFind/Auth/AbstractBase.php index 5bd3e0ddb6985928a12dbb14eef52b0c2d7159b6..dbd40e8a1a60544ef614f403d87bfb883e631e6d 100644 --- a/module/VuFind/src/VuFind/Auth/AbstractBase.php +++ b/module/VuFind/src/VuFind/Auth/AbstractBase.php @@ -78,6 +78,23 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, return $this->config; } + /** + * Inspect the user's request prior to processing a login request; this is + * essentially an event hook which most auth modules can ignore. See + * ChoiceAuth for a use case example. + * + * @param \Zend\Http\PhpEnvironment\Request $request Request object. + * + * @throws AuthException + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function preLoginCheck($request) + { + // By default, do no checking. + } + /** * Set configuration. * diff --git a/module/VuFind/src/VuFind/Auth/ChoiceAuth.php b/module/VuFind/src/VuFind/Auth/ChoiceAuth.php index c141aa3cc9ba90147303d13cb9267c175f4c1214..bec8dade3b8638e46e21702bca5799d998aede17 100644 --- a/module/VuFind/src/VuFind/Auth/ChoiceAuth.php +++ b/module/VuFind/src/VuFind/Auth/ChoiceAuth.php @@ -123,6 +123,21 @@ class ChoiceAuth extends AbstractBase ); } + /** + * Inspect the user's request prior to processing a login request; this is + * essentially an event hook which most auth modules can ignore. See + * ChoiceAuth for a use case example. + * + * @param \Zend\Http\PhpEnvironment\Request $request Request object. + * + * @throws AuthException + * @return void + */ + public function preLoginCheck($request) + { + $this->setStrategyFromRequest($request); + } + /** * Attempt to authenticate the current user. Throws exception if login fails. * diff --git a/module/VuFind/src/VuFind/Auth/Manager.php b/module/VuFind/src/VuFind/Auth/Manager.php index dfa1b4404f11be0231e51e18067a94189551ee1d..da5dc330c3dd314e53822d924eeded2c7fa29ce1 100644 --- a/module/VuFind/src/VuFind/Auth/Manager.php +++ b/module/VuFind/src/VuFind/Auth/Manager.php @@ -549,6 +549,10 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface */ public function login($request) { + // Allow the auth module to inspect the request (used by ChoiceAuth, + // for example): + $this->getAuth()->preLoginCheck($request); + // Validate CSRF for form-based authentication methods: if (!$this->getAuth()->getSessionInitiator(null) && !$this->csrf->isValid($request->getPost()->get('csrf'))