/blog/2015/04/how-to-add-jwt-authentication-to-a-cakephp-3-rest-api/ #156
Replies: 47 comments 60 replies
-
Saleh Souzanchi [DISQUS]: thank for this post, very Perfect |
Beta Was this translation helpful? Give feedback.
-
Bayezid Alam [DISQUS]: So helpful, Thanks a lot, waiting for more :-) |
Beta Was this translation helpful? Give feedback.
-
André Teixeira [DISQUS]: Bravo! ;) |
Beta Was this translation helpful? Give feedback.
-
Massimo Frascati [DISQUS]: Hi, thanks a lot for the tutorial, it's really great! :) |
Beta Was this translation helpful? Give feedback.
-
Kevin Wong [DISQUS]: Hi Bravo, firstly i'd like to say thank you very much for this 4 part series tutorial, most importantly because it really WORKS, and secondly it really helped to build a basic framework much needed by most real world applications. It really takes away the complexity from most basic framework requirements (REST and Authentication) and allows us to focus more quickly on actual business requirements and logic. I have followed this tutorial and managed to get things working using CakePHP 3, Postman, and the CRUD and JWT plugins you recommended. This has become my server-side API. On the client side I am building a PhoneGAP application that sends REST requests. My question has to do with my next step in my application development, how can I integrate social login into my application? I suppose this question spans both the PhoneGap application I am building and also the Server side API / application that I have built based on your tutorial. A specific platform answer (e.g. phonegap and cakephp) would be great, otherwise, if you could help put me in the right direction, or share some words of wisdom, I (as well as others) would really appreciate it. I'm relatively new to the world of authentication so I am not sure where to go. Some specific points of confusion: |
Beta Was this translation helpful? Give feedback.
-
lukas strassel [DISQUS]: Hello there, thanks for this tutorial! I've some question on the security of this approach... I think I didn't understand how this encryption works :/ What makes this application secure against someone capturing the package and simply use |
Beta Was this translation helpful? Give feedback.
-
Diego Carrera [DISQUS]: Hello Bravo, thanks for the awesome tutorial, just one question. |
Beta Was this translation helpful? Give feedback.
-
Sam Bown [DISQUS]: This Tutorial is by far the best REST API Tutorial as far as CakePHP is concerned. Just awesome. |
Beta Was this translation helpful? Give feedback.
-
Sam Bown [DISQUS]: Love this tutorial. I am confused in this section though. |
Beta Was this translation helpful? Give feedback.
-
Curtis Gibby [DISQUS]: Great tutorial. I never would have gotten through the process of adding JWT to my application without it. One bit of feedback: in the "/token action" section, wouldn't it make sense to add an "expiration_time" to the response data, so that token consumers can know when they'll have to come back for a fresh token? Or is the "now + 604800 seconds" pretty standard for JWT authorization? |
Beta Was this translation helpful? Give feedback.
-
Jack [DISQUS]: Thank you so much for writing this tutorial. It is extremely helpful in my development. I have a question, if I wanted to use 'email' rather than 'username' to check the db, how would I modify the app? I'm using an already existing database that uses 'email' instead of 'username' for the users credentials? Also, the database uses 'pin' instead of 'password', how could I modify the structure to accommodate for the changes in database structure? Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Chris Malpass [DISQUS]: This is a really great tutorial. I have done everything as shown, but am unable to use GET with the Authorization header to retrieve data. I am, however, able to use the _token parameter in the URL. I have tried all of the suggested formatting for the header Authorization: Bearer TOKEN_GOES_HERE in both raw and form based rest clients. I can't seem to get the header based token submission to work. Any ideas about what I've done wrong? |
Beta Was this translation helpful? Give feedback.
-
Monsur Hoq [DISQUS]: In my case:
|
Beta Was this translation helpful? Give feedback.
-
Pim Brouwers [DISQUS]: Honestly, what an amazing tutorial series. Can't emphasize this enough. Thank you hundred times. Just wanted to shut out to anyone taking this, finding that the Auth component returns false for each "identify()" call. MAKE SURE your database column which stores the password is long enough, ie: varchar(255) -- cake will throw no errors indicating that this is a problem if it isn't sufficient in length and ALL of your subsequent authorization attempts with the correct password will fail. |
Beta Was this translation helpful? Give feedback.
-
avinashjoshi [DISQUS]: Can you guide us to using or generating a refresh token and using that to generate a new access token & keep a user authenticated? |
Beta Was this translation helpful? Give feedback.
-
Anupal [DISQUS]: If i use it along Acl Plugin, does it need any changes in Api/AppController ??
|
Beta Was this translation helpful? Give feedback.
-
Lennard [DISQUS]: How would i only find results that belong to the user, e.g. my cocktails table has a column called account. I want to match the account of the user to the account of the cocktail? |
Beta Was this translation helpful? Give feedback.
-
Jonathan Lafleur [DISQUS]: Hi, I just ran into an issue with Apache stripping away Authorization header, you need to define a new header while enabling JWT (5. Enabling JWT Authentication, line 38)
Then you can trigger with that new header instead of Authorization |
Beta Was this translation helpful? Give feedback.
-
Pramila Manandhar [DISQUS]: Hi, how can i change the json response for expired token?? |
Beta Was this translation helpful? Give feedback.
-
Borhan Safa [DISQUS]: I have been following this tutorial from the beginning, everything was working fine but I am getting the following error on 'Verify Token Request' section. Now I am stuck and could not move further.
Looking for help from anyone. |
Beta Was this translation helpful? Give feedback.
-
Prabhat Bhardwaj [DISQUS]: when i use wrong token it should say invalid token but it says
How can i fix it |
Beta Was this translation helpful? Give feedback.
-
jose caceres [DISQUS]: Hello, thanks for the tutorial, one question. How can I get the ID of the user that has been authorized in the action? For example I need to log the user that executed a particular action |
Beta Was this translation helpful? Give feedback.
-
Anuj Sharma [DISQUS]: How can I store the Token to database? Also a tutorial on generating token secret just like other services will be appreciable for new users. In my application, I want user to be able to create App and generate access token for that app. |
Beta Was this translation helpful? Give feedback.
-
arun saini [DISQUS]: Hi Bravo, Thank you for this post. I have some different requirement. I need to save registration data in two different tables. Also need to create one more field in users table and other details in profiles table. how can I save data in both the tables with validation on both table fields. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Alomgir Hossen [DISQUS]: Thanks for this JWT post. |
Beta Was this translation helpful? Give feedback.
-
Alomgir Hossen [DISQUS]: Thanks Bro, |
Beta Was this translation helpful? Give feedback.
-
Gustavo Gonçalves [DISQUS]: Why JWT-Auth breaks unauthorizedRedirect? (For JWT-Auth to work, i need to set |
Beta Was this translation helpful? Give feedback.
-
Nate T Schreiner [DISQUS]: I know this tutorial is old but I hope I can still get a reply. I'm following along with the code and I don't see any use of the ADmad/cakephp-jwt-auth repository? The only specific command I'm seeing is this `JWT::encode()` function call but that does not come from the repository I linked in this comment. Is ADmad/cakephp-jwt-auth neccasry for this demo and if so where and what function does it play? |
Beta Was this translation helpful? Give feedback.
-
MAURO DA SILVA ALEXANDRE [DISQUS]: 6y old content, but helped me a lot nowadays |
Beta Was this translation helpful? Give feedback.
-
Hi, I tried to implement this tutorial using CakePHP 4 and found something strange. Example:
Specs:
I know the title says it's for CakePHP 3. |
Beta Was this translation helpful? Give feedback.
-
How to add JWT Authentication to a CakePHP 3 REST API
https://www.bravo-kernel.com/blog/2015/04/how-to-add-jwt-authentication-to-a-cakephp-3-rest-api/
Beta Was this translation helpful? Give feedback.
All reactions