-
Notifications
You must be signed in to change notification settings - Fork 75
GuardAuthenticator implementation for Symfony 2.8 and later #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ck and add use-statements of classes used in the docblocks
Hey @joshcanhelp, when do you expect to be able to take a look at this PR? 🙂 |
@niels-nijens - At first glance, this looks great! Just to clarify ... this is adding another way to authenticate? Do you have some sample code for how this would be used? Also, thank you for the tests, much appreciated! Let me know on the above and I'll pull this down and take a look. As long as there aren't any breaking changes (doesn't look like it) and this is Symfony 3 compatible (looks like it is based on CI), then we should be fine to merge this in. I'll look into the Snyk CI check failing on my end. |
any help needed to get this PR merged? |
@A-Marwan - I'd like to know a little more about what this is actually adding or improving. |
@joshcanhelp This PR adds a Guard for authentication. Using the The PR (seems to) adds the neccesary Would be great if you can merge this and release a new version, together with the other PR's you've merged today. |
hi @joshcanhelp , anything else you need? :) |
@darthf1 - Thanks for the run-down, I appreciate it. I'll take some time next week to walk through it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work here! A few minor things that I didn't want to comment over and over:
- Let's use the short array syntax
[]
instead ofarray()
- Let's switch anything that's
authZero
toauth0
But my main concern is ... how is this guard meant to be used. There are a lot of User
mentions throughout but, if you're protesting an API, this is a client acting on behalf of a user, not a user themself proving authentication. This makes it seem like an ID token is being used to call an API which, in general, is not a good idea.
Can you give an example of how this would be used? The main thing I would look for is the API audience being passed in so it can be validated and, then, we're sure that the token is meant for the API using this authenticator. The tests mock the service so I can't see that happening.
Thanks again!
Hopefully @niels-nijens can help with your comments on the code. I can make some of the changes but I'm not that skilled in PHP testing. @joshcanhelp Regarding your concerns; the reason there's a lot of references to 'User', is because of assumptions made a long time ago by Symfony regarding security, that a The implementation of this merge request is actually really easy, you only need to change (in relation to the current implementation) the
Becomes:
Now Symfony's |
Sorry, due to vacation I wasn't able to respond earlier. I'll make the changes based on your feedback today, @joshcanhelp. |
… JwtGuardAuthenticator
@darthf1 Thanks for answering some of @joshcanhelp's questions. 👍 @joshcanhelp I think I addressed all the feedback you had. |
@darthf1 - Thanks from me as well! Great explanation. @niels-nijens - This looks great. I'll give it one more pass this week and get the CI passing this week. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @niels-nijens! Thank you so much for your hard work on this.
The current
SimplePreAuthenticator
implementation is deprecated since Symfony 4.2. The guard authentication system provides more flexibility to eg. more verbose responses concerning authentication. And it makes this bundle (better) forward-compatible with Symfony 5 and later.This PR adds the following:
JwtGuardAuthenticator
class with service definition to use in thesecurity.y(a)ml
.JwtUserProvider
which adheres to theJWTUserProviderInterface
. It offers a basic user provider implementation by reading the information from the token and transforming it to a SymfonyUser
.JWTUserProviderInterface::loadUserByJWT
.At the moment the
JwtGuardAuthenticator
returns JSON responses, but I guess not everyone would want that.If you'd like to provide more flexibility, I'm willing to extract that part from the guard authenticator.
References
Testing
Instead of following chapter "Set up the SecurityProvider" of the Symfony API: Authorization guide add the following configuration to the
security.y(a)ml
:Optionally, chapter "Set up the User and UserProvider" can also be skipped by configuring the
JwtUserProvider
.Checklist
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors