Skip to content

Service override #206

@garak

Description

@garak

Checklist

  • I have looked into the Readme and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

The subject was already raised in #147 but it's still present. Sadly, I see many interfaces, but the services are injected using the concrete class names (and the classes themselves are final), so decoration is still impossible.

You should instead inject the interfaces and leverage service aliases to keep the current behaviour. This way, the user can implement the interface with a custom class and then decorate the service.

Describe the ideal solution

For example, the Auth0\Symfony\Security\Authenticator class should be like the following

<?php

namespace Auth0\Symfony\Security;

use Auth0\Symfony\Contracts\Security\AuthenticatorInterface;
use Auth0\Symfony\Contracts\ServiceInterface;
use Auth0\Symfony\Contracts\Security\AuthenticatorInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
// [...]

final class Authenticator extends AbstractAuthenticator implements AuthenticatorInterface
{
    public function __construct(
        public array $configuration,
        public ServiceInterface $service,  // <-- this is currently "Service" instead
        private RouterInterface $router,
        private LoggerInterface $logger,
    ) {
    }

    // [...]
}

Alternatives and current workarounds

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions