I am using this LexikJWTAuthenticationBundle with FosUserBundle.
I have this in security.yml:
firewalls:
app:
pattern: ^/api
stateless: true
anonymous: true
lexik_jwt: ~
with the following access_control:
- { path: ^/api/user/action1, roles: IS_AUTHENTICATED_FULLY }
- { path: ^/api/user/action2, roles: IS_AUTHENTICATED_ANONYMOUSLY }
The behavior that I expected for / api / user / action 2 has access regardless of what is inside the request header. However, I get 401 when the authorization identifier is installed but is not valid (this is normal with a valid token or no authorization media at all).
My use case is that I need to check my controller if the user is logged in, but if not, I still want this anonymous user to be able to access the route.