TouchID Authentication with Worklight
Chethan Kumar S.N 270002JC73 Comment (1) Visits (4686)
Apple finally opened up the very popular Touch Id authentication feature to developers in iOS 8.
Now, we can use Touch ID to authenticate parts of the application seamlessly and securely.
Wondering of using Touch ID authentication in worklight applications instead of the very bland username and password?
Is is difficult? Does it require lots of steps?
Absolutely not !! Its really really simple.
Now that I have got you exited :) , lets dive right into the code.
Lets pick up the adapter based authentication Worklight sample and integrate Touch Id into it so that you can see how easy it is to integrate into existing worklight applications which are secured with Worklight Security.
Lets first look at the client app side changes.
To make our life more easier, there are a bunch of cordova plugins which will allow us to do the Touch ID validation through a simple js call.
We will use one from here - http
In the index.html, we will comment out the input fileds which takes in username and password. We no longer need them!
Next, copy the TouchID.js to the js folder.
In Xcode drag and drop the Touch ID class (TouchID.h and TouchID.m) into the classes folder and add them to Target membership and copy if required.
Next, in the Sing
modify the function that makes the call to Single step adapter so that it only makes the call to the adapter only if the Touch ID authentication passes.
Here is the API which will invoke the Touch ID scanner and says if the fingerprint is authentic or not.
'Scan your fingerprint please',
If the authentication succeeds, then we should call the adapter procedure to submit the auth
After this, add the appropriate entry in config.xml
<param name="ios-package" value="TouchID" />
And we also need to modify the cordova_plugins.js to add the reference to the TouchID.js.
Phew!, that completes the client side changes.
Now, at the adapter side, the changes are very trivial.
Since, the touch ID validation happens at client end rather than server side, we need not check anything and straight away set the user Identity.
The userId in the userIdentity json could be any type of identification that we choose. It could be username that we collect or the device ID or any other identification we can capture.
Now all that is left is to actually run it and see it action.
Launch the app and then try to get the very secrect data from the adapter. It should now prompt for Touch ID authetication.
Give it the proper fingerprint and watch as it creates the userIdentity and get the data from the adapter. Since we have the user identity created, the subsequent requests are not prompted for authentication.
[Note that you should have already setup touch ID on your device to use it for authentication]
Here is the video which shows you the app in action and if you like to run the app yourself, here is the proj