Implementing JSON Login in Symfony 6.4 #61673
-
I am trying to implement authentication for my API's by having a JSON based login. I am using the documentation provided here: https://symfony.com/doc/6.4/security.html#json-login. However the authentication mechanism fails to set the #[CurrentUser] and my Login Controller has NULL for the $user object. My config/packages/security.yaml
The User provider is an entity class and the attribute is "uuid". The entity has been generated using the MAKER bundle. My Login Controller class is as follows
When I access the route using Curl I var_dump the $user object and its set to NULL. According to the documentation the Security bundle is expected to pick up the username and passwword from the JSON payload based on the following entries in the security.yaml
It is then supposed to find a matching user in the user entity by querying the uuid property based on the following entry in the security.yaml
Followed by passing the $userto the controller specified in the security.yaml
Im my case the $user object is set to NULL. Wondering if I have misconfigured anything. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment · 3 replies
-
Your |
Beta Was this translation helpful? Give feedback.
Your
main
firewall pattern is^/api/
so it won’t match/user/login
.