Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions module/VuFind/src/VuFind/Auth/EmailAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class EmailAuthenticator implements \VuFind\I18n\Translator\TranslatorAwareInter
* @param \VuFind\Mailer\Mailer $mailer Mailer
* @param PhpRenderer $viewRenderer View Renderer
* @param UserIpReader $userIpReader User IP address reader
* @param \VuFind\Config\Config $config Configuration
* @param array $config Configuration
* @param AuthHashServiceInterface $authHashService AuthHash database service
*/
public function __construct(
Expand All @@ -79,7 +79,7 @@ public function __construct(
protected \VuFind\Mailer\Mailer $mailer,
protected PhpRenderer $viewRenderer,
protected UserIpReader $userIpReader,
protected \VuFind\Config\Config $config,
protected array $config,
protected AuthHashServiceInterface $authHashService
) {
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public function sendAuthenticationLink(
$templateParams = []
) {
// Make sure we've waited long enough
$recoveryInterval = $this->config->Authentication->recover_interval ?? 60;
$recoveryInterval = $this->config['Authentication']['recover_interval'] ?? 60;
$sessionId = $this->sessionManager->getId();

if (
Expand Down Expand Up @@ -145,7 +145,7 @@ public function sendAuthenticationLink(
$viewParams['url'] = $serverHelper(
$urlHelper($linkRoute, $routeParams, ['query' => $urlParams])
);
$viewParams['title'] = $this->config->Site->title;
$viewParams['title'] = $this->config['Site']['title'] ?? '';

$message = $this->viewRenderer->render($template, $viewParams);
$from = $this->getEmailSenderAddress($this->config, $email);
Expand Down Expand Up @@ -236,7 +236,7 @@ public function sendAuthenticationCode(
$templateParams = []
): int {
// Make sure we've waited long enough
$recoveryInterval = $this->config->Authentication->recover_interval ?? 60;
$recoveryInterval = $this->config['Authentication']['recover_interval'] ?? 60;
$sessionId = $this->sessionManager->getId();

if (
Expand All @@ -260,7 +260,7 @@ public function sendAuthenticationCode(

$viewParams = $templateParams;
$viewParams['code'] = $otp;
$viewParams['title'] = $this->config->Site->title ?? '';
$viewParams['title'] = $this->config['Site']['title'] ?? '';

$message = $this->viewRenderer->render($template, $viewParams);
$from = $this->getEmailSenderAddress($this->config, $email);
Expand Down Expand Up @@ -310,7 +310,7 @@ public function verifyAuthenticationCode(
throw $e;
}
// Check the maximum attempt limit:
$maxAttempts = max($this->config->Authentication->otp_max_attempts ?? 3, 1);
$maxAttempts = max($this->config['Authentication']['otp_max_attempts'] ?? 3, 1);
if ($attempts > $maxAttempts) {
throw new AuthException('authentication_error_expired');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __invoke(
$container->get(\VuFind\Mailer\Mailer::class),
$container->get('ViewRenderer'),
$container->get(\VuFind\Net\UserIpReader::class),
$container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigObject('config'),
$container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigArray('config'),
$container->get(\VuFind\Db\Service\PluginManager::class)
->get(\VuFind\Db\Service\AuthHashServiceInterface::class)
);
Expand Down
15 changes: 7 additions & 8 deletions module/VuFind/src/VuFind/Auth/LoginTokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use Laminas\Session\SessionManager;
use Laminas\View\Renderer\RendererInterface;
use Psr\Log\LoggerAwareInterface;
use VuFind\Config\Config;
use VuFind\Config\Feature\EmailSettingsTrait;
use VuFind\Cookie\CookieManager;
use VuFind\Db\Entity\UserEntityInterface;
Expand Down Expand Up @@ -104,7 +103,7 @@ class LoginTokenManager implements LoggerAwareInterface, TranslatorAwareInterfac
/**
* LoginToken constructor.
*
* @param Config $config Configuration
* @param array $config Configuration
* @param UserServiceInterface $userService User database service
* @param LoginTokenServiceInterface $loginTokenService Login Token database service
* @param CookieManager $cookieManager Cookie manager
Expand All @@ -114,7 +113,7 @@ class LoginTokenManager implements LoggerAwareInterface, TranslatorAwareInterfac
* @param callable $browscapCB Callback for creating Browscap
*/
public function __construct(
protected Config $config,
protected array $config,
protected UserServiceInterface $userService,
protected LoginTokenServiceInterface $loginTokenService,
protected CookieManager $cookieManager,
Expand Down Expand Up @@ -273,7 +272,7 @@ public function deleteUserLoginTokens($userId)
*/
public function getCookieLifetime(): int
{
return (int)($this->config->Authentication->persistent_login_lifetime ?? 14);
return (int)($this->config['Authentication']['persistent_login_lifetime'] ?? 14);
}

/**
Expand Down Expand Up @@ -332,7 +331,7 @@ protected function createOrRotateToken(
$userId = $user->getId();
try {
if ($series) {
$lenient = ($this->config->Authentication->lenient_token_rotation ?? true);
$lenient = ($this->config['Authentication']['lenient_token_rotation'] ?? true);
$this->loginTokenService->deleteBySeries($series, $lenient ? $currentTokenId : null);
$this->debug("Updating login token $token series $series for user {$userId}");
} else {
Expand Down Expand Up @@ -364,16 +363,16 @@ protected function createOrRotateToken(
*/
protected function sendLoginTokenWarningEmail(UserEntityInterface $user)
{
if (!($this->config->Authentication->send_login_warnings ?? true)) {
if (!($this->config['Authentication']['send_login_warnings'] ?? true)) {
return;
}
$title = $this->config->Site->title ?? '';
$title = $this->config['Site']['title'] ?? '';
if ($toAddr = $user->getEmail()) {
$message = $this->viewRenderer->render(
'Email/login-warning.phtml',
compact('title')
);
$subject = $this->config->Authentication->persistent_login_warning_email_subject
$subject = $this->config['Authentication']['persistent_login_warning_email_subject']
?? 'persistent_login_warning_email_subject';

try {
Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Auth/LoginTokenManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __invoke(

$dbServiceManager = $container->get(\VuFind\Db\Service\PluginManager::class);
return new $requestedName(
$container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigObject('config'),
$container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigArray('config'),
$dbServiceManager->get(UserServiceInterface::class),
$dbServiceManager->get(LoginTokenServiceInterface::class),
$container->get(\VuFind\Cookie\CookieManager::class),
Expand Down
36 changes: 18 additions & 18 deletions module/VuFind/src/VuFind/Auth/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Manager implements IdentityProviderInterface, LoggerAwareInterface
/**
* Constructor.
*
* @param Config $config VuFind configuration
* @param array $config VuFind configuration
* @param UserServiceInterface $userService User database service
* @param UserSessionPersistenceInterface $userSession User session persistence service
* @param SessionManager $sessionManager Session manager
Expand All @@ -134,7 +134,7 @@ class Manager implements IdentityProviderInterface, LoggerAwareInterface
* @param AuditEventServiceInterface $auditEventService Event database service
*/
public function __construct(
protected Config $config,
protected array $config,
protected UserServiceInterface $userService,
protected UserSessionPersistenceInterface $userSession,
protected SessionManager $sessionManager,
Expand All @@ -148,7 +148,7 @@ public function __construct(
) {
// Initialize active authentication setting (defaulting to Database
// if no setting passed in):
$method = $this->getPreAuthenticationData()['authMethod'] ?? $config->Authentication->method ?? 'Database';
$method = $this->getPreAuthenticationData()['authMethod'] ?? $config['Authentication']['method'] ?? 'Database';
// Set the active authentication method and force it legal:
$this->setAuthMethod($method, true);
}
Expand Down Expand Up @@ -204,7 +204,7 @@ protected function makeAuth(string $method): AuthInterface
throw new \Exception("Illegal authentication method: $method");
}
$auth = $this->pluginManager->get($method);
$auth->setConfig($this->config);
$auth->setConfig(new Config($this->config));
return $auth;
}

Expand All @@ -231,7 +231,7 @@ public function supportsCreation(?string $authMethod = null): bool
*/
public function supportsRecovery(?string $authMethod = null, ?string $target = null): bool
{
return ($this->config->Authentication->recover_password ?? false)
return ($this->config['Authentication']['recover_password'] ?? false)
&& $this->getAuth($authMethod)->supportsPasswordRecovery($target);
}

Expand Down Expand Up @@ -269,7 +269,7 @@ public function getPasswordRecoveryData(array $params): ?array
*/
public function supportsEmailChange(?string $authMethod = null): bool
{
return $this->config->Authentication->change_email ?? false;
return $this->config['Authentication']['change_email'] ?? false;
}

/**
Expand All @@ -282,7 +282,7 @@ public function supportsEmailChange(?string $authMethod = null): bool
*/
public function supportsPasswordChange(?string $authMethod = null): bool
{
return ($this->config->Authentication->change_password ?? false)
return ($this->config['Authentication']['change_password'] ?? false)
&& $this->getAuth($authMethod)->supportsPasswordChange();
}

Expand All @@ -296,7 +296,7 @@ public function supportsPasswordChange(?string $authMethod = null): bool
*/
public function supportsConnectingLibraryCard(?string $authMethod = null): bool
{
return ($this->config->Catalog->auth_based_library_cards ?? false)
return ($this->config['Catalog']['auth_based_library_cards'] ?? false)
&& $this->getAuth($authMethod)->supportsConnectingLibraryCard();
}

Expand All @@ -309,10 +309,10 @@ public function supportsConnectingLibraryCard(?string $authMethod = null): bool
*/
public function supportsPersistentLogin(?string $authMethod = null): bool
{
if (!empty($this->config->Authentication->persistent_login)) {
if (!empty($this->config['Authentication']['persistent_login'])) {
return in_array(
strtolower($authMethod ?? $this->getSelectedAuthMethod() ?? ''),
explode(',', strtolower($this->config->Authentication->persistent_login))
explode(',', strtolower($this->config['Authentication']['persistent_login']))
);
}
return false;
Expand All @@ -325,7 +325,7 @@ public function supportsPersistentLogin(?string $authMethod = null): bool
*/
public function getPersistentLoginLifetime(): int
{
return $this->config->Authentication->persistent_login_lifetime ?? 14;
return $this->config['Authentication']['persistent_login_lifetime'] ?? 14;
}

/**
Expand Down Expand Up @@ -516,7 +516,7 @@ public function loginEnabled(): bool
{
if (null === $this->hideLogin) {
// Assume login is enabled unless explicitly turned off:
$this->hideLogin = ($this->config->Authentication->hideLogin ?? false);
$this->hideLogin = ($this->config['Authentication']['hideLogin'] ?? false);

if (!$this->hideLogin) {
try {
Expand Down Expand Up @@ -544,7 +544,7 @@ public function loginEnabled(): bool
public function ajaxEnabled(): bool
{
// Assume ajax is enabled unless explicitly turned off:
return $this->config->Authentication->enableAjax ?? true;
return $this->config['Authentication']['enableAjax'] ?? true;
}

/**
Expand All @@ -555,7 +555,7 @@ public function ajaxEnabled(): bool
public function dropdownEnabled(): bool
{
// Assume dropdown is disabled unless explicitly turned on:
return $this->config->Authentication->enableDropdown ?? false;
return $this->config['Authentication']['enableDropdown'] ?? false;
}

/**
Expand Down Expand Up @@ -740,7 +740,7 @@ public function checkForExpiredCredentials(): bool
*/
public function inPrivacyMode(): bool
{
return $this->config->Authentication->privacy ?? false;
return $this->config['Authentication']['privacy'] ?? false;
}

/**
Expand Down Expand Up @@ -838,7 +838,7 @@ public function updateEmail(UserEntityInterface $user, string $email): void
{
// Depending on verification setting, either do a direct update or else
// put the new address into a pending state.
if ($this->config->Authentication->verify_email ?? false) {
if ($this->config['Authentication']['verify_email'] ?? false) {
// If new email address is the current address, just reset any pending
// email address:
$user->setPendingEmail($email === $user->getEmail() ? '' : $email);
Expand Down Expand Up @@ -996,7 +996,7 @@ public function login(Request $request): ?UserEntityInterface
// Attempt catalog login so that any bad credentials are cleared before further processing
// (avoids e.g. multiple login attempts by account AJAX checks).
if (
($this->config->Catalog->checkILSCredentialsOnLogin ?? true)
($this->config['Catalog']['checkILSCredentialsOnLogin'] ?? true)
&& $this->ilsAuthenticator
&& $this->allowsUserIlsLogin()
&& ($catUsername = $user->getCatUsername())
Expand Down Expand Up @@ -1225,7 +1225,7 @@ protected function updateUser(UserEntityInterface $user, ?string $authMethod): v
*/
public function allowsUserIlsLogin(): bool
{
return $this->config->Catalog->allowUserLogin ?? true;
return $this->config['Catalog']['allowUserLogin'] ?? true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Auth/ManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __invoke(
throw new \Exception('Unexpected options passed to factory.');
}
// Load dependencies:
$config = $container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigObject('config');
$config = $container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigArray('config');
$dbServiceManager = $container->get(\VuFind\Db\Service\PluginManager::class);
$userService = $dbServiceManager->get(\VuFind\Db\Service\UserServiceInterface::class);
$sessionManager = $container->get(\Laminas\Session\SessionManager::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use PHPUnit\Framework\InvalidArgumentException;
use PHPUnit\Framework\MockObject\Exception;
use VuFind\Auth\EmailAuthenticator;
use VuFind\Config\Config;
use VuFind\Db\Entity\AuthHashEntityInterface;
use VuFind\Db\Service\AuthHashServiceInterface;
use VuFind\Mailer\Mailer;
Expand Down Expand Up @@ -89,7 +88,7 @@ protected function getEmailAuthenticator(
$mailer ?? $this->createStub(Mailer::class),
$renderer ?? $this->createStub(PhpRenderer::class),
$userIpReader ?? $this->createStub(UserIpReader::class),
new Config($config),
$config,
$authHashService ?? $this->createStub(AuthHashServiceInterface::class)
);
$authenticator->setTranslator($this->getMockTranslator([]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use Laminas\Session\SessionManager;
use PHPUnit\Framework\MockObject\MockObject;
use VuFind\Auth\LoginTokenManager;
use VuFind\Config\Config;
use VuFind\Cookie\CookieManager;
use VuFind\Db\Entity\LoginTokenEntityInterface;
use VuFind\Db\Entity\UserEntityInterface;
Expand Down Expand Up @@ -193,7 +192,7 @@ protected function getCookieManager(array $cookies): CookieManager
*/
protected function getLoginToken($cookieManager, $tokenTable, $userTable, $browscapOk)
{
$config = new Config([]);
$config = [];
$saveHandler = $this->createMock(SaveHandlerInterface::class);
$sessionManager = $this->createMock(SessionManager::class);
$sessionManager->method('getSaveHandler')->willReturn($saveHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use VuFind\Auth\Manager;
use VuFind\Auth\PluginManager;
use VuFind\Auth\UserSessionPersistenceInterface;
use VuFind\Config\Config;
use VuFind\Db\Entity\UserEntityInterface;
use VuFind\Db\Service\UserServiceInterface;

Expand Down Expand Up @@ -561,7 +560,6 @@ protected function getManager(
?SessionManager $sessionManager = null,
?PluginManager $pm = null
): Manager {
$config = new Config($config);
$cookies = new \VuFind\Cookie\CookieManager([]);
$csrf = new \VuFind\Validator\SessionCsrf(
[
Expand Down