Skip to content

Feature request: Make Authentication service available via DI in the Middleware #646

@jamisonbryant

Description

@jamisonbryant

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions