mozilla/datazilla — pull request #47 by jeads (2012-07-02 17:30:34+00:00)
Title: Twolegged oauth

This branch implements two legged OAuth 1.0 in the following way.

1.) Added two columns to datazilla.datasource: consumer_key and consumer_secret. These columns will contain NULL for non-objectstore contenttypes. The columns hold the OAuth consumer key/secret combination for a given project's objectstore.

2.) In models.DataSource consumer_key and consumer_secret were added as attributes.

3.) Added a decorator to views.py, oauth_required, that implements a two legged OAuth service provider. It accesses the key/secret associated with the given project through `dm.sources['objectstore'].datasource`

4.) Added a new manage command, post_json, that implements the OAuth consumer. It takes options for the consumer key/secret but defaults to using settings.OAUTH_CONSUMER_KEY and settings.OAUTH_CONSUMER_SECRET. These can be set in local.py. To test, copy the key/secret from your test project in datazilla.datasource to local.py. The following example illustrates how to use the command:

`python manage.py post_json --project jeads --host s4n2.qa.phx1.mozilla.com --file /home/jeads/sample_data.json`

NOTE: you will need to restart memcached for these new attributes to be available.

5.) Added python-oauth2 (Which actually implements oauth 1.0) to requirements/pure.txt and ran bin/generate-vendor-lib.py to populate the related vendor files.

I have a couple open ended questions which might require some conversation to answer.

Where should the code that implements the construction of the oauth consumer key/secret live?
The most convenient place would be in the create_project manage.py command but this would leave the process exposed. There are a couple pieces of random data in the key/secret so maybe it's not a problem...

Once we agree on this branch we should update https://github.com/mozilla/datazilla_client to add support for the OAuth consumers. We will need to contact groups intending to use datazilla and confirm that they can install oauth2 in their production environments. We will also need to send them their project's consumer key/secret data.

We will also need to add special handling to talos if python-oauth2 cannot be distributed in the production environment.