sinatra-google-auth 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -0
- data/lib/sinatra/google-auth.rb +2 -1
- data/lib/sinatra/google-auth/version.rb +1 -1
- data/sinatra-google-auth.gemspec +2 -0
- metadata +13 -3
- data/lib/sinatra/gooogle-auth.rb +0 -40
data/README.md
CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
|
|
22
22
|
The gem exposes a single `authenticate` helper that protects the endpoint with
|
23
23
|
Google OpenID authentication.
|
24
24
|
|
25
|
+
Configure your google openid endpoint via setting the ENV var: GOOGLE_AUTH_URL
|
26
|
+
|
25
27
|
### Classic-Style Apps
|
26
28
|
|
27
29
|
```ruby
|
data/lib/sinatra/google-auth.rb
CHANGED
@@ -21,9 +21,10 @@ module Sinatra
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.registered(app)
|
24
|
+
raise "Must supply ENV var GOOGLE_AUTH_URL" unless ENV['GOOGLE_AUTH_URL']
|
24
25
|
app.helpers GoogleAuth::Helpers
|
25
26
|
app.use ::Rack::Session::Cookie, :secret => ENV['SESSION_SECRET'] || SecureRandom.hex(64)
|
26
|
-
app.use ::OmniAuth::Strategies::OpenID, :name => "google", :identifier =>
|
27
|
+
app.use ::OmniAuth::Strategies::OpenID, :name => "google", :identifier => ENV['GOOGLE_AUTH_URL']
|
27
28
|
|
28
29
|
app.get "/auth/:provider/callback" do
|
29
30
|
handle_authentication_callback
|
data/sinatra-google-auth.gemspec
CHANGED
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.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,18 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-04-10 00:00:00.000000000Z
|
13
|
-
dependencies:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-openid
|
16
|
+
requirement: &70364815507680 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70364815507680
|
14
25
|
description: Drop-in google auth for sinatra apps
|
15
26
|
email:
|
16
27
|
- christopher.continanza@gmail.com
|
@@ -26,7 +37,6 @@ files:
|
|
26
37
|
- lib/sinatra-google-auth.rb
|
27
38
|
- lib/sinatra/google-auth.rb
|
28
39
|
- lib/sinatra/google-auth/version.rb
|
29
|
-
- lib/sinatra/gooogle-auth.rb
|
30
40
|
- sinatra-google-auth.gemspec
|
31
41
|
homepage: ''
|
32
42
|
licenses: []
|
data/lib/sinatra/gooogle-auth.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'omniauth-openid'
|
2
|
-
|
3
|
-
module Sinatra
|
4
|
-
module GoogleAuth
|
5
|
-
|
6
|
-
module Helpers
|
7
|
-
def authenticate
|
8
|
-
unless session["user"]
|
9
|
-
redirect to "/auth/google"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def handle_authentication_callback
|
14
|
-
unless session["user"]
|
15
|
-
user_info = request.env["omniauth.auth"].info
|
16
|
-
session["user"] = Array(user_info.email).first.downcase
|
17
|
-
end
|
18
|
-
|
19
|
-
redirect to "/"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.registered(app)
|
24
|
-
app.helpers GoogleAuth::Helpers
|
25
|
-
app.use ::Rack::Session::Cookie, :secret => ENV['SESSION_SECRET'] || SecureRandom.hex(64)
|
26
|
-
app.use ::OmniAuth::Strategies::OpenID, :name => "google", :identifier => ENV['GOOGLE_AUTH_URL']"http://heroku.com/openid"
|
27
|
-
|
28
|
-
app.get "/auth/:provider/callback" do
|
29
|
-
handle_authentication_callback
|
30
|
-
end
|
31
|
-
|
32
|
-
app.post "/auth/:provider/callback" do
|
33
|
-
handle_authentication_callback
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
register GoogleAuth
|
39
|
-
end
|
40
|
-
|