I installed identity plugin.
- custom a servicefactory
class AuthenticationServiceFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
{
$dbAdapter = $container->get(AdapterInterface::class);
$authAdapter = new CredentialTreatmentAdapter(
$dbAdapter,
'user',
'username',
'passwd',
'SHA1(CONCAT(?, salt)) AND valid=1',
);
return new AuthenticationService(null, $authAdapter);
}
}
- config as following in the module.config.php
'service_manager' => [
'factories' => [
AuthenticationService::class => AuthenticationServiceFactory::class, //it works after I added this line !!!!
AuthenticationServiceInterface::class => AuthenticationServiceFactory::class, //
AuthManager::class => AuthManagerFactory::class, //use in bootstrap
Redis::class => CommonRedisFactory::class, //
],
],
- as well I config something in the global.php
'session_containers' => [
Laminas\Session\Container::class,
],
'session_storage' => [
'type' => Laminas\Session\Storage\SessionArrayStorage::class,
],
'session_config' => [
'cache_expire' => 60 * 24 * 30,
'cookie_httponly' => true,
'cookie_lifetime' => 86400 * 30,
'gc_maxlifetime' => 86400 * 30,
'name' => 'hcs_erp',
'remember_me_seconds' => 86400 * 30,
'use_cookies' => true,
],
'session_manager' => [
'config' => [
'class' => Laminas\Session\Config\SessionConfig::class,
'options' => [
'name' => 'hcs_erp',
],
],
'storage' => Laminas\Session\Storage\SessionArrayStorage::class,
'validators' => [
Laminas\Session\Validator\RemoteAddr::class,
Laminas\Session\Validator\HttpUserAgent::class,
],
],
When I login with username and password, it works well. However it expired in a very short time, almost 1 hour, then I need to login again, it is very inconvinient.
I don’t know where the problem is.