Closed RobertRajcool closed 8 years ago
We have already experienced issues like this one and the bundle is not concerned at all.
Something in your environment makes your symfony application doesn't receive the authorization
header, it may be apache (see this note in the documentation), mod_rewrite (see https://github.com/lexik/LexikJWTAuthenticationBundle/issues/168 and #148 for instance), ...
Anyway, the information you give doesn't make me able to identify any possible issue.
A first step for identifying your problem can be to check if the current Request
object contains the authorization header.
i send Request like that from js
headers.append(Authorization
, Bearer ${tokenvalue}
)
whether its correct??
i'm try to send request by using angular2-jwt i got Token is missing Error
Yes, the request trace you are showing looks good, that's why I think the problem comes from your server. Try to send a simple cURL request to avoid the doubt of a problem in your javascript:
curl -H "Authorization: Bearer TOKENHERE" URLHERE
GET /app_dev.php/api/dashboard/welcome HTTP/1.1 Host: angulartest Connection: keep-alive Authorization: Token eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJ1c2VybmFtZSI6IlRlc3RVc2VyIiwiZXhwIjoiMTQ3ODM1NTc1NSIsImlhdCI6IjE0NzgyNjkzNTUifQ.pyhMwnysi5Nm9ZT2iePWnTDUCkGbXCp6eiil9M_AAJY6dz_TQP_mwTo5TEzFnBEC5xxPc7ZQE2XSoKdcjwQxC3HffAqCHHP2hxA_cEvxeevMfgUA4f9ot5-UXSjVseOdrBB0A-5yfhB8EkdLY9_ZA_EOZES3X3p9HJ4U2DrpMc0SEudPZNgEzD_1r7lEvW8iGom7rNzhcnAjgdus9ktzhQtHxjFXPHpr34PND5UuwvAt0slJLhIswmTDoLhqqb9MK_CFya2Vs661e1doexsdY3xcXuOdcgUqQUq-x6btPDDOjSRI5JQN5XbDHbx-j9Pluv5TS5Ou0vUyXJQ3F4BUKmlc7YoeOJFk6qvHa5EDx0ffyTAZCt5bjT7nMpMY19sLfwVVnofFUIGfcn87r74dZVkxIpPF1wp3aShthB5DUAzAEMY-ZdtEZGn_sYSaHJMWzH_uPd03wEmwmz0us0GllG9ccbycf6p0ECmHf4US8BEI5LkF0iJvOnkTtfQQ-qh6ws3l2Zy0v-071YrJ6y2YUHTOZNNmZFRNL92RQvSh8BvcSqfmUT2j0Uf2HR7yTZSeL8JIopoBsixTDSdcIT0QYQmdI1RIcGmgnaYdO59faPANKitl_9wlg5lJyX7CS0OAiiIB7yQ4atj8vohNl_3LQHP0UDfg7ffKe9wpSHj28BQ User-Agent: Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 content-type: application/json Accept: /_ Referer: http://angulartest/dashboard/companyusers Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8
okay i will check through curl
curl -X POST http://localhost:8000/api/login_check -d _username=johndoe -d _password=test
{"error":{"code":404,"message":"Not Found","exception":[{"message":"Unable to find the controller for path \"\/api\/login_check\". The route is wrongly configured.","class":"Symfony\Component\HttpKernel\Exception\NotFoundHttpException","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"\/home\/robert\/Projects\/ServerProjects\/Projects\/Angular2Symfony\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php","line":133,"args":[]},{"namespace":"Symfony\Component\HttpKernel","short_class":"HttpKernel","class":"Symfony\Component\HttpKernel\HttpKernel","type":"->","function":"handleRaw","file":"\/home\/robert\/Projects\/ServerProjects\/Projects\/Angular2Symfony\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php","line":64,"args":[["object","Symfony\Component\HttpFoundation\Request"],["string","1"]]},{"namespace":"Symfony\Component\HttpKernel","short_class":"HttpKernel","class":"Symfony\Component\HttpKernel\HttpKernel","type":"->","function":"handle","file":"\/home\/robert\/Projects\/ServerProjects\/Projects\/Angular2Symfony\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/DependencyInjection\/ContainerAwareHttpKernel.php","line":69,"args":[["object","Symfony\Component\HttpFoundation\Request"],["string","1"],["boolean",true]]},{"namespace":"Symfony\Component\HttpKernel\DependencyInjection","short_class":"ContainerAwareHttpKernel","class":"Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel","type":"->","function":"handle","file":"\/home\/robert\/Projects\/ServerProjects\/Projects\/Angular2Symfony\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/Kernel.php","line":185,"args":[["object","Symfony\Component\HttpFoundation\Request"],["string","1"],["boolean",true]]},{"namespace":"Symfony\Component\HttpKernel","short_class":"Kernel","class":"Symfony\Component\HttpKernel\Kernel","type":"->","function":"handle","file":"\/home\/robert\/Projects\/ServerProjects\/Projects\/Angular2Symfony\/web\/app_dev.php","line":28,"args":[["object","Symfony\Component\HttpFoundation\Request"]]}]}]}}
http://127.0.0.1:8000/api/login_check
Unable to find the controller for path "/api/login_check". The route is wrongly configured.
Looks like there is a problem in your security configuration. Can you please paste the content of your security.yml
here?
security: providers: in_memory: memory: users: ryan: password: ryanpass roles: 'ROLE_USER' admin: password: kitten roles: 'ROLE_ADMIN'
encoders:
Symfony\Component\Security\Core\User\User: plaintext
firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
api:
pattern: ^/api
stateless: true
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
access_control:
- { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
Fine on my side. I guess you removed some firewalls from the configuration pasted in your previous comment, and I think the problem precisely comes from them.
For instance, if you have a main
firewall (provided by default), try to move it at the end of your firewall section (or just remove it for testing), it should fix this issue.
Unable to find the controller for path "/api/login_check". The route is wrongly configured.
still i got this error
Yeah, I think you didn't pasted your full security configuration (I guess it misses a part of your firewalls) and there is a problem into. Sorry but I can't do anything with the information I have.
i Attaach security.yml file please check that one
Your configuration works well on my side:
Please consider forking https://github.com/chalasr/lexik-jwt-authentication-sandbox for reproducing your issue.
okay thanks will ping u
Its works thanks @chalasr
You're welcome @Lawrancecool. Closing this as fixed.
@chalasr How to configure security.yml for fos userbundle for example: providers: fos_userbundle: id: fos_user.user_provider.username
GET /app_dev.php/api/dashboard/welcome HTTP/1.1 Host: angulartest Connection: keep-alive authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJ1c2VybmFtZSI6IlRlc3RVc2VyIiwiZXhwIjoiMTQ3ODM0NzY2NyIsImlhdCI6IjE0NzgyNjEyNjcifQ.Lx5iAjC5EWUE66k1Vn0VXqoLLHbOLM7ZqbevQpZ-Ahq62-yLMAwchDeBjH9dQzrQ1orfdGSxw1rFLE7zVtTPz1bgJJlqKegsn0FZvhPsiBVQoKFk-P47wUrKoCY0W213TM8qpgP8KFJtgMbJN1TBf4ign7Kz4_ihhfYXSj1sdARuCdFkDVmqRhPjuI7A1S1OKBSNwzNKountUODEv7p4Snx-z5qeJHWyBv9rWtC1vALsb0WeEsrq4XtM3I6mhKqdpQcFaVw8-5RfMmmX6LDyoPVpBoGqTQM89XcDpEnF1240pJ_fimbi2nYuNO0NT4Z6gvs9ob-TD9uuNvdOPJ3IFsT6by3BcQIyVeB_DCkY7TsljC4wbbZI8grcR4hagSE27GrdJgWznxlvi0puWYztV-uATPuEWMQZHsXIYvcBrLySyNzuoLJC9LDXoZEI5j6MXy0uhb0Ram7sj1LlRCQyMRHQeDQp1nvzzjsGt_JlxLml5aYftF-W3-7s7ESfq92JDxVF-hwbsahP1H9wlhxTMt0anWNwSEkhTWuROeOOv5x1p30K6uxyCz60LokPuGW3Na6lvlNxaBZCaU51pU24-K6-fB2iQaH0A9zW1KVlH1pUxWynMJ7sdQeloAnBKIyk_wBDkGWdXn657btnJ_aAEDPDVMjmEpZKeICc9_d--8U User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 content-type: application/json Accept: / Referer: http://angulartest/dashboard/companyusers Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8 Cookie: XDEBUG_SESSION=18226