Skip to content
Snippets Groups Projects
Commit 456e7d43 authored by Demian Katz's avatar Demian Katz
Browse files

Merge pull request #644 from vufind-org/pre-login-hook

Added preLoginCheck() method to determine ChoiceAuth strategy before …
parents 08c9faba 47cd7eb5
No related merge requests found
...@@ -78,6 +78,23 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, ...@@ -78,6 +78,23 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
return $this->config; 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. * Set configuration.
* *
......
...@@ -123,6 +123,21 @@ class ChoiceAuth extends AbstractBase ...@@ -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. * Attempt to authenticate the current user. Throws exception if login fails.
* *
......
...@@ -549,6 +549,10 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface ...@@ -549,6 +549,10 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface
*/ */
public function login($request) 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: // Validate CSRF for form-based authentication methods:
if (!$this->getAuth()->getSessionInitiator(null) if (!$this->getAuth()->getSessionInitiator(null)
&& !$this->csrf->isValid($request->getPost()->get('csrf')) && !$this->csrf->isValid($request->getPost()->get('csrf'))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment