Related to cakephp/authorization#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 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 cakephp/authorization#265
Per a recent community discussion it would be helpful for some apps to be able to obtain an instance of
AuthenticationServiceInterfaceand/or the currently configuredAuthenticationServicefrom the service container.Currently there is no way to add the
AuthenticationServiceas a dependency to userland Services registered in the service container because theServerRequestis added to the container after the user's container registration code has run. This means that the only avenue for accessing the instantiatedAuthenticationServiceis 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.