lexikjwtauthbundle

How to add Login to swagger UI with API PLATFORM (symfony 4)?

风格不统一 提交于 2021-02-11 13:48:00
问题 I installed & configured LexikJWTAuthenticationBundle, it works fine but I've got a small problem. I have include the Authorization button for put the JWT token, the problem is the only way I can have my token is to use this commands: curl -X POST -H "Content-Type: application/json" http://localhost:8000/api/login_check -d '{"username":"johndoe","password":"test"}' It send my the token and I put it in the API, OK. First problem: When I try this request with POSTMAN I get an error : Unable to

LexikJWT get user profile by token

ⅰ亾dé卋堺 提交于 2020-12-06 07:21:04
问题 Using LexikJWTAuthenticationBundle, FOSRest, FOSUser how do I get authenticated user profile by token. Is it possible? So let's say user is already authenticated via LexikJWT and I have an api endpoint like /api/profile where I send the token and I expect to get specified user data. I'm using for frontend ReactJS with Redux. 回答1: This is an example of how to get your user by a service when the user is already authenticated: class UserService { /** @var TokenStorageInterface */ private

Invalid JSON Message while using LexikJWTAuthenticationBundle

余生长醉 提交于 2020-01-03 03:00:45
问题 I have a Symfony 4 project where I need to perform secure authentication using LexikJWTAuthenticationBundle. I implemented the bundle by following its documentation and I get this error when I execute the following command: curl -X POST -H "Content-Type: application/json" http://localhost:8000/api/login_check -d '{"username":"johndoe","password":"test"}' Error message : Invalid JSON This error is of type Bad Request (400) and it takes place at the time of the json_decode in the file : Symfony

Why my jwt tokens never expire?

做~自己de王妃 提交于 2020-01-02 12:21:13
问题 I've inherited a Symfony project that uses this controller to authenticate users: class TokenController extends FOSRestController { public function postTokensAction(Request $request) { $username = $request->request->get('username'); $password = $request->request->get('password'); $user = $this->get('fos_user.user_manager') ->findUserByUsername($username); if (!$user) { throw $this->createNotFoundException(); } $passwordEncoder = $this->get('security.password_encoder'); if(!$passwordEncoder-

Why my jwt tokens never expire?

橙三吉。 提交于 2020-01-02 12:20:56
问题 I've inherited a Symfony project that uses this controller to authenticate users: class TokenController extends FOSRestController { public function postTokensAction(Request $request) { $username = $request->request->get('username'); $password = $request->request->get('password'); $user = $this->get('fos_user.user_manager') ->findUserByUsername($username); if (!$user) { throw $this->createNotFoundException(); } $passwordEncoder = $this->get('security.password_encoder'); if(!$passwordEncoder-

401 JWT Token not found

守給你的承諾、 提交于 2019-12-22 17:57:17
问题 I provided two versions of the security.yaml file. The second version according to API Platform documentation. API Platform sends to the creation a custom user provider. For the second option security.yaml recommended at API Platform docs, I need to create two additional files. I did not attach them to the topic, but will do it if necessary. But I think that problem it is in JWT. Environment: node v8.9.4 chrome 64.0.3282.119 Ubuntu 16.04 axios version: 0.16.2 Vue.js 2.4.2 vue-axios 2.0.2 api

Lexik JWT Token not found

六月ゝ 毕业季﹏ 提交于 2019-12-22 07:04:50
问题 I've seen similar questions but still can't get this to work. I'm new with Symfony and I'm using Lexik JWT bundle with symfony3 for API authentication, and a login form for web authentication. I get the token ok but when I try to use it I get 401 - Bad authentication. I've read it can be an apache problem so I'm trying with PHP's built-in web server, but still no luck. Here's my security.yml file: security: encoders: AppBundle\Entity\User: algorithm: bcrypt # http://symfony.com/doc/current

Symfony3 JWT with LexikJWTAuthenticationBundle returns 404 on Preflight OPTIONS

ⅰ亾dé卋堺 提交于 2019-12-13 18:09:15
问题 Description: I'm working with the LexikJWTAuthenticationBundle and trying to generate a JWT token with credentials sent from my Ionic2 App. Generating the token works fine with Curl and with Postman. curl -X POST http://localhost:8000/api/login_check -d _username=root -d _password=root However, Ionic2 sends a preflight OPTIONS request before actually sending the POST request with the credentials. This is misunderstood by Symfony3 and sends back a 404. Console Error From Ionic2: OPTIONS http:/

The `lexik_jwt_authentication.on_jwt_created` is not present in Symfony's profiler

陌路散爱 提交于 2019-12-13 03:36:04
问题 I've added this listener acme_api.event.jwt_created_listener: class: AppBundle\EventListener\JWTCreatedListener tags: - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated } but the event is not dispatched (is not visible) from symfony's profiler. I am trying to use it to customize the token expiration time. The method onJWTCreated is not called! 回答1: As shown in your previous question Why my jwt tokens never expire?, you are not using the

Lexik JWT Authentification with Sf4 : Uncaught Exception: Unable to find the controller for path “/login_check”

丶灬走出姿态 提交于 2019-12-11 17:42:52
问题 I followed the Sf4 sandbox to install JWT Auth, but still I have this response : 2019-01-03T18:39:27+01:00 [info] Matched route "login_check". 2019-01-03T18:39:27+01:00 [info] Populated the TokenStorage with an anonymous Token. 2019-01-03T18:39:27+01:00 [warning] Unable to look for the controller as the "_controller" parameter is missing. 2019-01-03T18:39:27+01:00 [critical] Uncaught Exception: Unable to find the controller for path "/login_check". The route is wrongly configured. [Thu Jan 3