Storing User Authentication Data in the Cloud

I’m exploring building a web app with a “shared-nothing” architecture. (Are we calling these “cloud apps” yet?)

I was looking at user authentication in Merb using merb-auth and started wondering if user authentication data could be saved in the cloud. It seems to fit the limitations of cloud data storage, especially Amazon SimpleDB. User authentication data is typically only written once (when a user registers) and only read once per session (when a user logs in). It’s also schema-less, which is intriguing, because one could add user attributes over time as needs develop.

I found a recent project on GitHub where Dan Mayer built a Merb example app using DataMapper and SimpleDB.

As a first step, it needs the Ruby aws-sdb gem. Then I grabbed Dan Mayer’s example from the GitHub repository.

sudo gem install aws-sdb
git clone git://github.com/danmayer/merb-simpledb-dm_example.git

I changed the file /config/dependencies.rb to update to “merb_gems_version” from “1.0.4″ to “1.0.7.1″ (the Merb version on my machine). It ran successfully:

cd merb-simpledb-dm_example/
merb

I generated a default “Hello World” Merb app and compared it to merb-simpledb-dm_example to see what Dan Mayer had done (thanks Mac OS X FileMerge). Here’s what he added:

lib/simpledb_adapter.rb

with a require 'lib/simpledb_adapter.rb' in the config/init.rb file.

The code for simpledb_adapter.rb is pretty much the same as a project on GitHub by Jeremy Boles named dm-adapter-simpledb combined with a Migration module from a project by Edward Ocampo-Gooding named dm-simpledb.

You’ll need to have an Amazon Web Services account set up for Amazon SimpleDB. You can read my blog entry Setting Up Amazon SimpleDB for User Authentication for details.

You set up access to Amazon SimpleDB in the config/database.yml file:

  adapter: simpledb
  database: 'default'
  access_key_id: '1_your_access_key_1'
  secret_access_key: 'b_your_secret_key_b'
  domain: 'your_app_development'
  base_url: 'http://sdb.amazon.com'

There’s nothing to do beyond that. Just fire it up and it runs.

One Response to “Storing User Authentication Data in the Cloud”

  1. Setting Up Amazon SimpleDB for User Authentication « Yax Development Journal Says:

    [...] to try out the Merb example app using DataMapper and SimpleDB that I describe in my blog entry Storing User Authentication Data in the Cloud. Possibly related posts: (automatically generated)Amazon’s SimpleDB – Nice concept that took [...]

Leave a Reply