Skip to content

Conversation

@mdeboer
Copy link
Contributor

@mdeboer mdeboer commented May 27, 2021

This PR register aliases for arguments to make autowiring a lot easier with multiple instances of say JWS builders. The accompanying Symfony documentation on the subject can be found here: https://symfony.com/doc/current/service_container/autowiring.html#dealing-with-multiple-implementations-of-the-same-type

For example this allows you to define JWS builders named foo and bar and choose which one to autowire by their variable name and type. For example argument JWSBuilder $fooJwsBuilder will autowire the foo JWS builder and JWSBuilder $barJwsBuilder will autowire the bar JWS builder.

This also works for other services. Here is a list of suffixes and their types given that a configuration has been named foo:

Class Argument
Jose\Bundle\JoseFramework\Services\ClaimCheckerManager $fooClaimCheckerManager
Jose\Bundle\JoseFramework\Services\HeaderCheckerManager $fooHeaderCheckerManager
Jose\Component\Encryption\JWEBuilder $fooJweBuilder
Jose\Component\Encryption\JWEDecrypter $fooJweDecrypter
Jose\Component\Encryption\JWELoader $fooJweLoader
Jose\Component\Encryption\Serializer\JWESerializerManager $fooJweSerializer
Jose\Component\NestedToken\NestedTokenBuilder $fooNestedTokenBuilder
Jose\Component\NestedToken\NestedTokenLoader $fooNestedTokenLoader
Jose\Component\Encryption\JWSBuilder $fooJwsBuilder
Jose\Component\Encryption\JWSLoader $fooJwsLoader
Jose\Component\Signature\Serializer\JWSSerializerManager $fooJwsSerializer
Jose\Component\Encryption\JWSVerifier $fooJwsVerifier
Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement\JWKSetSource\JWKSetSource $fooKeySet
Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement\JWKSource\JWKSource $fooKey

@mdeboer
Copy link
Contributor Author

mdeboer commented Jun 13, 2021

I have merged the upstream changes in this PR and added a link to the Symfony documentation on the subject: https://symfony.com/doc/current/service_container/autowiring.html#dealing-with-multiple-implementations-of-the-same-type

Hopefully this can be merged to save people from having to define their own aliases when using Symfony DI.

If you have any questions, feel free to ask 👍🏻

@Spomky Spomky merged commit 44760c6 into web-token:v2.2 Jun 13, 2021
@Spomky
Copy link
Member

Spomky commented Jun 13, 2021

Great. Many thanks. That's a very nice addition!
Looks like I need to get rid of Travis CI pipelines that are broken. I also need to think of the futur of this framework. It's time to remove hacks, deprecated methods and implement PHP8 new features.

@mdeboer
Copy link
Contributor Author

mdeboer commented Jun 15, 2021

If you need any help, let me know. Busy schedule but I might find time to help out now and then 👍🏻

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants