sinatra-google-auth 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in sinatra-google-auth.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'turn'
8
+ end
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
- # Sinatra::Google::Auth
2
-
3
- Drop
1
+ # Sinatra::GoogleAuth
4
2
 
3
+ Drop-in authentication for Sinatra with Google's OpenID endpoint.
5
4
 
6
5
  ## Installation
7
6
 
@@ -22,12 +21,10 @@ Or install it yourself as:
22
21
  The gem exposes a single `authenticate` helper that protects the endpoint with
23
22
  Google OpenID authentication.
24
23
 
25
- Configure your google openid endpoint via setting the ENV var: GOOGLE_AUTH_URL
26
-
27
24
  ### Classic-Style Apps
28
25
 
29
26
  ```ruby
30
- require 'sinatra/base
27
+ require 'sinatra'
31
28
  require 'sinatra/google-auth'
32
29
 
33
30
  get '*' do
@@ -40,7 +37,7 @@ end
40
37
  ### Modular Apps
41
38
 
42
39
  ```ruby
43
- require 'sinatra/base
40
+ require 'sinatra/base'
44
41
  require 'sinatra/google-auth'
45
42
 
46
43
  class App < Sinatra::Base
@@ -53,7 +50,33 @@ class App < Sinatra::Base
53
50
  end
54
51
  ```
55
52
 
53
+ ## Configuration
54
+
55
+ ### Google Endpoint
56
+
57
+ Configure your Google OpenID endpoint via setting the ENV var `GOOGLE_AUTH_URL`
58
+
59
+ $ export GOOGLE_AUTH_URL=http://myurl.com/openid
60
+
61
+ or before requiring
62
+
63
+ ```ruby
64
+ ENV['GOOGLE_AUTH_URL'] = 'http://myurl.com/openid'
65
+
66
+ require 'sinatra'
67
+ require 'sinatra/google-auth'
68
+ ```
69
+
70
+ ### Session Secret
71
+
72
+ Configure your session secret by setting `SESSION_SECRET` or `SECURE_KEY` ENV vars.
73
+
74
+
75
+ $ export SESSION_SECRET='super secure secret'
76
+
77
+ The 'SecureKey' add-on sets the `SECURE_KEY` variable for you and automatically rotates it.
56
78
 
79
+ $ heroku addons:add securekey
57
80
 
58
81
 
59
82
  ## Contributing
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module GoogleAuth
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -20,10 +20,14 @@ module Sinatra
20
20
  end
21
21
  end
22
22
 
23
+ def self.secret
24
+ ENV['SESSION_SECRET'] || ENV['SECURE_KEY'] || 'please change me'
25
+ end
26
+
23
27
  def self.registered(app)
24
28
  raise "Must supply ENV var GOOGLE_AUTH_URL" unless ENV['GOOGLE_AUTH_URL']
25
29
  app.helpers GoogleAuth::Helpers
26
- app.use ::Rack::Session::Cookie, :secret => ENV['SESSION_SECRET'] || SecureRandom.hex(64)
30
+ app.use ::Rack::Session::Cookie, :secret => secret
27
31
  app.use ::OmniAuth::Strategies::OpenID, :name => "google", :identifier => ENV['GOOGLE_AUTH_URL']
28
32
 
29
33
  app.get "/auth/:provider/callback" do
@@ -38,4 +42,3 @@ module Sinatra
38
42
 
39
43
  register GoogleAuth
40
44
  end
41
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-google-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-10 00:00:00.000000000Z
12
+ date: 2012-04-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth-openid
16
- requirement: &70364815507680 !ruby/object:Gem::Requirement
16
+ requirement: &70278697564720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70364815507680
24
+ version_requirements: *70278697564720
25
25
  description: Drop-in google auth for sinatra apps
26
26
  email:
27
27
  - christopher.continanza@gmail.com