简体   繁体   中英

iOS authentication with Symfony2 and FOSUserBundle

I have developped a Symfony2 website which is using FOSUserBundle .

I am developping an iOS app which is linked to my website through AFNetworking requests and JSON responses.

I am just missing the user authentication so that when a user opens the app he has to login (if not remembered) and then on each AFNetworking request I can pass the user info (an id, a token, a username/password, ...) so that the response is secured and personalized.

I have spent the past days looking for the right solution and I have seen so many different (complicated) ways of doing it. But from what I understand I only miss 2 steps:

  1. Send a request from iOS app to Symfony2 with username/password and return true if the user matches

  2. Add the username/password (stored with SSKeychain as I understood) to every AFNetworking request.

Is it correct ? And how would I implement the following then:

  • Test in the Symfony2 controller if username/password is correct and return true or an authToken in JSON

  • Make that AFNetworking requests are accessible under the security firewall with given username/password or auth token in parameters and find the user in database to send him back his own data.

Any help on this would be very much appreciated.

FOSAuthServerBundle was indeed the perfect bundle to add authentication to a Symfony2 project from an iOS app.

A good tutorial to implement it can be found here:

http://blog.tankist.de/blog/2013/07/16/oauth2-explained-part-1-principles-and-terminology/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM