Hello,
my goal is to use multiple “Zend\Authentication\AuthenticationService” implementations in one Zend Expresse application.
I have one module ("Api) for handling REST API requests and another module (Frontend) for providing a UI.
In the “Api” module I want to use "Basic Aut"h Authentication like this: (from the docs)
return [
'aliases' => [
// Change the alias value for Authentication adapter and
// UserRepository adapter
AuthenticationInterface::class => Adapter\BasicAccess::class,
UserRepositoryInterface::class => UserRepository\Htpasswd::class,
],
'factories' => [
AuthenticationMiddleware::class => AuthenticationMiddlewareFactory::class,
Adapter\BasicAccess::class => Adapter\BasicAccessFactory::class,
UserRepository\Htpasswd::class => UserRepository\HtpasswdFactory::class,
UserRepository\PdoDatabase::class => UserRepository\PdoDatabaseFactory::class
],
];
In the Frontend (UI) module the authentication should be via normal form POST data (username, password) and with a session.
Both work (separated), but NOT together,
In the config (ConfigProvider) of each module I can assign an"AuthenticationService::class" implementation factory. But only (excactly) 1 Implementation for the whole application. (because all ConfigProvider are merged; last ConfigProvider with the Factory overwrites all other before).
My first appoach was to implement an abstract factory to create the various AuthenticationService, but in the factory I need the request to decide which one, but the requesr is not available at htis point (using superglobals is NOT a solution).
Is there a way to solve this?