Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Securing RESTful API in Google App Engine

I'm trying to figure out how to implement the following authentication flow:

  1. The user accesses a web application (most likely to be written using Ruby on Rails) and authenticates (e.g., username/password).
  2. The client consumes data via AJAX provided by a RESTful API built on Google App Engine (Python, webapp2).

enter image description here

Requirements:

  1. Only users authenticated in the web application (Rails) should be able to access the API hosted on App Engine.
  2. Users can have different roles in the web application (Rails), and the API (App Engine) needs to know what roles are associated to the given user to restrict access to certain data.
  3. The client should be able to call the API (App Engine) directly via AJAX, without routing all requests through the web application (Rails).

I'm looking for suggestions on how to implement such workflow. Should I use OAuth (or OAuth2) for accessing the API? Should the OAuth provider live on App Engine and the web application (Rails) ask the API for a token on behalf of the user? If so, what is the best way to allow only the web application (Rails) to request OAuth tokens? Or should I consider a completely different strategy?

Any suggestions are greatly appreciated. I'm also looking for suggestions of libraries to implement OAuth in the context above.

like image 846
Leo Avatar asked Jul 24 '12 10:07

Leo


People also ask

Is in Google App Engine application run in secure sandbox environment?

In the standard environment, your application runs on a lightweight instance inside of a sandbox. This sandbox restricts what your application can do. For example, the sandbox only allows your app to use a limited set of binary libraries, and your app cannot write to disk.

Does Google have REST API?

To use the Fitness REST API, you need a Google Account. If you already have an account, then you're all set. You may also want to create a separate Google Account for testing purposes.


1 Answers

I suggest you use caution if you are considering implementing an API built on the Google App Engine using OAuth for your security layer. I am currently involved in a project that is struggling to solve exactly this problem. The OAuth layer over the GAE is still new and considered by Google to be "experimental". Google's documentation is minimal at this point. What there is begins here. I wish you the best if you try to proceed, and I will do my best to offer help if you do.

like image 155
Drew Stoddard Avatar answered Sep 30 '22 00:09

Drew Stoddard