Skip to content

Mark the exik_jwt_authentication.encoder.default service as autowire default for JWTEncoderInterface #256

@weaverryan

Description

@weaverryan

First, congrats on 2.0! I'm looking forward to checkout out all the changes!

On KnpU, since we use this bundle, I just had one user mention a small change in 2.0 that I think we can make smoother. Specifically, we use autowiring on a service that has JWTEncoderInterface as an argument. With 2.0, this gives the following exception:

Unable to autowire argument of type "Lexik\Bundle\JWTAuthenticationBundle\Encoder\JWTEncoderInterface" for the service "app.security.jwt_token_authenticator". Multiple services exist for this interface (lexik_jwt_authentication.encoder.default, lexik_jwt_authentication.encoder.lcobucci).

Could we mark the lexik_jwt_authentication.encoder.default as the correct autowiring service for this interface? We would just need an autowiring_types key added to that service (http://symfony.com/doc/current/components/dependency_injection/autowiring.html) - this is done in other places, like MonologBundle to mark @logger as the default LoggerInterface service.

Thanks!

Activity

chalasr

chalasr commented on Oct 20, 2016

@chalasr
Collaborator

@weaverryan Really, thank you very much for the help you given on this major version.
I'm glad to see you upgrading and I hope it will not be too much work.

About the autowiring types, it's indeed something good to have that I totally missed 👍
As you spotted the change has been made. I just tagged a v2.0.1 so you should be able to get it.

I have to remind you that this bundle now has a built-in Guard authenticator, greatly inspired from the one of your KnpUniversity lesson and presentation (I'm pretty sure it is the very same that the DIC was not able to autowire :))

Feedbacks from you and your collaborators will be greatly appreciated.

Closing as fixed in #257. Thank you!

weaverryan

weaverryan commented on Oct 20, 2016

@weaverryan
Author

Wow, that was so fast! And I already replied to the user (who just posted the comment this morning!). You rock :).

I have an issue internally to pull down 2.0.1 with our tutorial and make sure things are smooth - that'll be my chance to really test out the new version. I'm also excited to look at the authenticator - I will probably at least add a note so that users know that this is an option (versus building their own, which is a nice exercise, but not necessarily the best actual solution).

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @weaverryan@chalasr

        Issue actions

          Mark the exik_jwt_authentication.encoder.default service as autowire default for JWTEncoderInterface · Issue #256 · lexik/LexikJWTAuthenticationBundle