If you use the Mobile Boilerplate in Bluemix, how can we use Strongloop as a custom authentication backend to integrate with Mobile Client Access? Is there any tutorial or sample code on this?
Answer by Dave Cariello (2901) | Mar 21, 2016 at 09:56 AM
We have a helloTodoAdvanced sample hosted on github that can show you how to do this. We also have an article currently being reviewed, so I will update this thread once that is released.
You'll notice in our Node.js code that we use the MCA Token Validation strategy to protect our node server endpoints.
Once the MCA passport strategy is defined, we can use the line:
passport.authenticate('mca-backend-strategy', {session: false})
to protect any node endpoint, as done on line 46 for delete and line 54 for some custom push notifications.
This ensures that any successful request contains a valid auth header that can only be generated by the mobile SDK. If you configure MCA to require Facebook login, you will need to develop your client side mobile app to require successful Facebook login before making any requests to these protected endpoints or they will fail.
Hi Dave, the sample uses facebook for authenticating with the mobile client access. If we use custom authentication using Strongloop, how would that work?
@beezeetim, after adding the passport.authenticate...
line to your Node.js code, whatever authentication you have configured on your Bluemix MCA tile will be used when your mobile app attempts to hit that endpoint. See Using a custom identity provider to authenticate users to understand how to configure custom auth with your Bluemix MCA tile and your mobile app.