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

Support s.role parameter in Summon code

- Resolves VUFIND-475
parent a7db6613
No related merge requests found
...@@ -178,3 +178,13 @@ enabled = true ...@@ -178,3 +178,13 @@ enabled = true
; Set this to true in order to enable "next" and "previous" links to navigate ; Set this to true in order to enable "next" and "previous" links to navigate
; through the current result set from within the record view. ; through the current result set from within the record view.
next_prev_navigation = false next_prev_navigation = false
; Users will see more records if Summon is set to "authenticated" mode. It is
; up to you to determine how to identify authenticated users in compliance with
; your Summon contract. Authentication is disabled by default; you can turn on
; settings below to activate it based on various conditions.
[Auth]
; set to true to authenticate Summon based on user's login status within VuFind:
check_login = false
; set to a regular expression for matching valid IPs to activate IP whitelisting:
;ip_range = "/1\.2\.3\.[0-2]?[0-9]?[0-9]/"
\ No newline at end of file
...@@ -132,11 +132,50 @@ class SummonBackendFactory implements FactoryInterface ...@@ -132,11 +132,50 @@ class SummonBackendFactory implements FactoryInterface
? $this->summonConfig->General->timeout : 30; ? $this->summonConfig->General->timeout : 30;
$client->setOptions(array('timeout' => $timeout)); $client->setOptions(array('timeout' => $timeout));
$connector = new Connector($id, $key, array(), $client); $options = array('authedUser' => $this->isAuthed());
$connector = new Connector($id, $key, $options, $client);
$connector->setLogger($this->logger); $connector->setLogger($this->logger);
return $connector; return $connector;
} }
/**
* Is the current user of the Summon connector authenticated?
*
* @return bool
*/
protected function isAuthed()
{
// Check based on login status
if (isset($this->summonConfig->Auth->check_login)
&& $this->summonConfig->Auth->check_login
) {
$authManager = $this->serviceLocator->get('VuFind\AuthManager');
if ($authManager->isLoggedIn()) {
return true;
}
}
// Check based on IP range
if (isset($this->summonConfig->Auth->ip_range)) {
$request = $this->serviceLocator->get('Request');
$match = preg_match(
$this->summonConfig->Auth->ip_range,
$request->getServer()->get('REMOTE_ADDR')
);
if ($match === false) {
throw new \Exception(
'Bad regular expression in Summon.ini [Auth] ip_range setting.'
);
}
if ($match) {
return true;
}
}
// If we got this far, we're not authenticated.
return false;
}
/** /**
* Create the Summon query builder. * Create the Summon query builder.
* *
......
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