For a hybrid SSO scenario using the Facebook iOS SDK, what's the best way generating a password/key for our own custom user records?
So my intention is to have a login in my iOS app that allows for either our standard email/pwd registration, or login with Facebook. We are also creating rest services to get application info for a given user, e.g. https://url/getPosts/[userId]?userPwd=foo
I’ve implemented SSO with fb in a web application before but I have some concerns about the security of authentication in a iOS client scenario. The key difference from what I’ve done before is that in a web app, I was making a server to server call to Facebook to get the access token so I was reasonably assured that the user was authenticated and the web server made privileged calls to the database. In the iOS case, I have the mobile client app making the Facebook iOS authentication request itself and the server has to somehow trust that this user from the client app is indeed authenticated against the matching user record in our database.
My question is how do I generate a durable and secret unique key from the iOS SDK so that I can create and associate a matching user record in our database for users that authenticate only with Facebook. I want this to be seamless so the user would not have to manually fill out another form, and we would just automatically create this matching user record in our db.
I could insert a record into my own users table when they fbDidLogin with Facebook, using the Facebook Id as the unique identifier, and the fb access token as the pseudo password/key for my own user record. I would have to validate the access token with Facebook to make sure it’s valid before saving it as a password for the user (the user would never see this password, it would just be passed by the client app during api calls). That way when the user makes a call to our own rest api via the iPhone app we can authenticate and authorize using this secret/pwd/key.
An alternative that would make this whole question moot is to just handle the authorization logic on the client app, and check that there is a valid fb session before making calls to our own apis which I secure with just a single application-wide secret, but that doesn’t seem as secure since getting that one secret gives authorization to data on all users. I’d rather authorize at an individual user level. Is that the right choice? Am I being paranoid about iOS security?
The fb access token expires so that might not seem durable, however if I enable offline access that token won’t expire but creates a scarier looking oauth dialog window. An alternative to the access token is to hash the fb Id with an application secret key on the iOS client, and use that as the Facebook user’s password in our db. However, that again is a single secret key that could perhaps be reverse compiled from the iOS client app?
- iOS facebook check if friends have app installed
- How to write UI tests covering login with Facebook in Xcode?
- Facebook SDK changes to Login in Pop-up view
- Facebook SDK sign in with Swift 3 iOS 10
- unable to get the access token through in iphone sdk
- iOS Facebook SDK - get list of Friends connected with App
3 Solutions Collect From Internet About “For a hybrid SSO scenario using the Facebook iOS SDK, what's the best way generating a password/key for our own custom user records?”
Design for Facebook authentication in an iOS app that also accesses a secured web service
This post helped me undesrtand it more. If I am not mistaken, the flow goes like this:
- User authenticates in iOS app
- iOS app takes auth token, sends it to the rails app
- Rails app takes auth token and sends it to graph.facebook.com/?auth_token=XXX to get back the user if authentication was successful.
- Rails app takes the user info and matches/creates user in own database table. Sends some kind of authentication key back to iOS app.
- iOS app saves the authentication key so it can use it to communicate with the rails app.
Let me know if I am missing anything.
Have you looked at the iOS docs for Single Sign On (SSO)? https://developers.facebook.com/docs/guides/mobile/#ios
You can share an app ID across mobile, canvas and web site and the same user auth works for each environment.
Facebook Platform provides a number of ways to use the above OAuth flows in different app types, including Websites, Apps on Facebook.com, Mobile and Desktop Apps.
You just need to insert users Facebook key to your database to know if its authenticated with Facebook. Use OAuth at ios side authenticate user take users secret key send it to your rest web-service and save it with users other info.
- How to list the folders at a specific path from an Amazon S3 bucket, in Objective C?
- How can I make a weak protocol reference in 'pure' Swift (without @objc)
- Submitting an update to the App Store from a different project?
- Cordova ios error building Images.xcassets
- Fast switching between videos using AVFoundation
- UICollectionView Cell Spacing based on device sceen size
- iOS App Crashes on Phone but works fine on simulator
- CCAdvancedMenu boundaryRect
- Code Sign error, How to switch an Xcode Project over to another Mac?
- Cocoapods with Xcode 6 and 10.10 Yosemite
- How to enumerate a slice using the original indices?
- ARKit Place a SCNNode facing the camera
- NSMutableAttributedString initWithData: causing EXC_BAD_ACCESS on rotation
- Subclass of GKGraphNode costToNode method never getting called
- Trying to convert Firebase timestamp to NSDate in Swift