ruby-on-railsrubyrestdeviseactiveresource

Authentication with an Existing External API


I am building a Ruby on Rails (Rails - v4.2.3 & Ruby 2.2.2) App which consumes an existing REST API. The aforementioned API is written in PHP. I need help regarding how to manage the authentication?

On searching through various forums I came across these two gems

  1. https://github.com/lynndylanhurley/devise_token_auth
  2. https://github.com/gonzalo-bulnes/simple_token_authentication

The problem I am facing with both is that they require my app to have a users model configured (using Devise).

However My app is primarily a front end for the Existing REST API, so if I do configure my own User model, I will end up with two Data Stores (One for the APP I make and the other for the existing API).

I wish to consume the external API and not have any native models for my APP.

I believe I can use ActiveResource for this (I need more reputation points to post a link to the gem, sorry I cannot do that right now, I am new to StackOverflow):

However I am not sure how to go about managing the security of the application. More specifically what measures can I take to prevent the authentication information from being viewed in plaintext while it is being transmitted to my API server for authentication?

Thank You.


Solution

  • Use HTTPS on your API. If your external API is using HTTPS then user info wouldn't be sent in plaintext from your rails app.

    Don't forget to use HTTPS for your rails app too, as that is more important.