Per a recent community discussion it would be helpful for some apps to be able to obtain an instance of AuthenticationServiceInterface and/or the currently configured AuthenticationService from the service container.
Currently there is no way to add the AuthenticationService as a dependency to userland Services registered in the service container because the ServerRequest is added to the container after the user's container registration code has run. This means that the only avenue for accessing the instantiated AuthenticationService is via a request attribute.
If the service were available via DI, that Service class could list it as a dependency when configuring the application service container and then call it directly from within the service. This provides greater type safety and less (direct) reliance on the HTTP request object.
Related to https://github.com/cakephp/authorization/issues/265
Per a recent community discussion it would be helpful for some apps to be able to obtain an instance of
AuthenticationServiceInterface
and/or the currently configuredAuthenticationService
from the service container.Currently there is no way to add the
AuthenticationService
as a dependency to userland Services registered in the service container because theServerRequest
is added to the container after the user's container registration code has run. This means that the only avenue for accessing the instantiatedAuthenticationService
is via a request attribute.If the service were available via DI, that Service class could list it as a dependency when configuring the application service container and then call it directly from within the service. This provides greater type safety and less (direct) reliance on the HTTP request object.