Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from auxbuss/master

Update for latest gem updates
  • Loading branch information...
commit bb33cbf41af1cacb6b4b93f83a35cc0e09ce279f 2 parents cf374d7 + aa78957
Charlie Park authored
Showing with 25 additions and 14 deletions.
  1. +1 −0  .gitignore
  2. +22 −12 README.md
  3. +2 −2 app.rb
1  .gitignore
View
@@ -0,0 +1 @@
+database.db
34 README.md
View
@@ -1,38 +1,48 @@
# Omniauth for Sinatra
-This is a template for launching Sinatra apps quickly and easily, using [OmniAuth](https://github.com/intridea/omniauth) as the authentication protocol. It differs from most of the "use Twitter with Sinatra" code bases, as it incorporates sessions and a User model in the database. This means your user should remain logged in as long as your server stays live.
+This is a template for launching Sinatra apps quickly and easily,
+using [OmniAuth](https://github.com/intridea/omniauth) as the authentication protocol.
+It differs from most of the "use Twitter with Sinatra" code bases, as it incorporates
+sessions and a `User` model in the database. This means your user should remain logged
+in as long as your server stays live.
The instructions here assume you're using Twitter, but you can use any auth provider handled by OmniAuth.
-Most of the actual code here is simply a port/mashup of Ryan Bates's example from [RailsCasts #241: Simple OmniAuth](http://railscasts.com/episodes/241-simple-omniauth) and the OmniAuth readme.
-
-Once you have your auth codes, getting a new Sinatra app with authentication working is simply a matter of copying the app.rb file from here into a new directory, pasting in your auth codes, and then starting in on your app's code. It just works.
+Most of the actual code here is simply a port/mashup of Ryan Bates's example from [RailsCasts #241:
+Simple OmniAuth](http://railscasts.com/episodes/241-simple-omniauth) and the OmniAuth readme.
+Once you have your auth codes, getting a new Sinatra app with authentication working is simply a matter
+of copying the `app.rb` file from here into a new directory, pasting in your auth codes, and then starting
+in on your app's code. It just works.
## Getting Started Instructions
### 1. Install Omniauth and the other required gems
- gem install omniauth
-
-You'll also need to install data_mapper and dm-sqlite-adapter if you don't have them in your system.
-
+ gem install omniauth omniauth-twitter dm-core dm-sqlite-adapter dm-migrations sinatra
### 2. Get your Twitter Auth Keys
-At Twitter, [register for a new app](https://dev.twitter.com/apps/new). Note the Consumer Key and Consumer Secret strings it gives you.
+At Twitter, [register for a new app](https://dev.twitter.com/apps/new).
+Note the _Consumer Key_ and _Consumer Secret_ strings it gives you.
### 3. Enter your Auth Keys into the app.rb file
-The file app.rb has a place for your CONSUMER_KEY and CONSUMER_SECRET. Just replace them, and you're set. Fire up your local server ('ruby app.rb') and you can see your log-in setup.
+The file `app.rb` has a place for your `CONSUMER_KEY` and `CONSUMER_SECRET`. Just replace them, and you're
+set. Fire up your local server via `ruby app.rb` and you can see your log-in setup.
## A Minor Note
-Note that **you cannot use shotgun to test your app**, as you'll need sessions to persist in order to stay logged in, and shotgun restarts the server on every request. Starting your app with 'ruby app.rb' should work with no problems.
+Note that if you want to use shotgun or reloader while testing your app, then you'll need to set
+`:session_secret` in your configure block:
+ configure :development, :testing do
+ set :session_secret, "random string"
+ end
## Feedback Is Awesome
-I'd really love to hear any suggestions you have on how to improve this. On Twitter, I'm [@charliepark](https://twitter.com/charliepark/). By e-mail, I'm charlie@monotask.com.
+I'd really love to hear any suggestions you have on how to improve this. On Twitter,
+I'm [@charliepark](https://twitter.com/charliepark/). By e-mail, I'm charlie@monotask.com.
4 app.rb
View
@@ -1,4 +1,4 @@
-%w(rubygems oa-oauth dm-core dm-sqlite-adapter dm-migrations sinatra).each { |dependency| require dependency }
+%w(omniauth omniauth-twitter dm-core dm-sqlite-adapter dm-migrations sinatra).each { |dependency| require dependency }
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/database.db")
@@ -67,4 +67,4 @@ def current_user
session[:user_id] = nil
redirect '/'
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.