sinatra-google-auth 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,4 +5,5 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem 'turn'
8
+ gem 'sinatra'
8
9
  end
data/README.md CHANGED
@@ -93,12 +93,12 @@ end
93
93
 
94
94
  Configure your Google OpenID endpoint via setting the ENV var `GOOGLE_AUTH_URL`
95
95
 
96
- $ export GOOGLE_AUTH_URL=http://myurl.com/openid
96
+ $ export GOOGLE_AUTH_DOMAIN=heroku.com
97
97
 
98
98
  or before requiring
99
99
 
100
100
  ```ruby
101
- ENV['GOOGLE_AUTH_URL'] = 'http://myurl.com/openid'
101
+ ENV['GOOGLE_AUTH_URL'] = 'heroku.com'
102
102
 
103
103
  require 'sinatra'
104
104
  require 'sinatra/google-auth'
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module GoogleAuth
3
- VERSION = '0.0.8'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
- require 'omniauth-openid'
1
+ require 'omniauth-google-apps'
2
+ require 'openid/store/filesystem'
2
3
 
3
4
  module Sinatra
4
5
  module GoogleAuth
@@ -9,11 +10,11 @@ module Sinatra
9
10
  end
10
11
 
11
12
  def call(env)
12
- if env['rack.session']["user"] || env['REQUEST_PATH'] =~ /^\/auth\/google/
13
+ if env['rack.session']["user"] || env['REQUEST_PATH'] =~ /^\/auth\/google_apps/
13
14
  @app.call(env)
14
15
  else
15
16
  env['rack.session']['google-auth-redirect'] = env['REQUEST_PATH']
16
- return [301, {'Content-Type' => 'text/html', 'Location' => '/auth/google'}, []]
17
+ return [301, {'Content-Type' => 'text/html', 'Location' => '/auth/google_apps'}, []]
17
18
  end
18
19
  end
19
20
  end
@@ -23,9 +24,9 @@ module Sinatra
23
24
  unless session["user"]
24
25
  session['google-auth-redirect'] = request.path
25
26
  if settings.absolute_redirect?
26
- redirect "/auth/google"
27
+ redirect "/auth/google_apps"
27
28
  else
28
- redirect to "/auth/google"
29
+ redirect to "/auth/google_apps"
29
30
  end
30
31
  end
31
32
  end
@@ -47,10 +48,13 @@ module Sinatra
47
48
  end
48
49
 
49
50
  def self.registered(app)
50
- raise "Must supply ENV var GOOGLE_AUTH_URL" unless ENV['GOOGLE_AUTH_URL']
51
+ raise "Must supply ENV var GOOGLE_AUTH_DOMAIN" unless ENV['GOOGLE_AUTH_DOMAIN']
51
52
  app.helpers GoogleAuth::Helpers
52
53
  app.use ::Rack::Session::Cookie, :secret => secret
53
- app.use ::OmniAuth::Strategies::OpenID, :name => "google", :identifier => ENV['GOOGLE_AUTH_URL']
54
+ app.use ::OmniAuth::Builder do
55
+ provider :google_apps, domain: ENV['GOOGLE_AUTH_DOMAIN']
56
+ end
57
+
54
58
  app.set :absolute_redirect, false
55
59
 
56
60
  app.get "/auth/:provider/callback" do
@@ -15,5 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Sinatra::GoogleAuth::VERSION
17
17
 
18
- gem.add_dependency 'omniauth-openid'
18
+ gem.add_dependency 'omniauth-google-apps'
19
+ gem.add_dependency 'oa-openid'
19
20
  end
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+
3
+ require 'sinatra'
4
+ require 'sinatra/google-auth'
5
+
6
+ get '*' do
7
+ authenticate
8
+ 'hello'
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+
3
+ require 'sinatra'
4
+ require 'sinatra/google-auth'
5
+
6
+ get '*' do
7
+ authenticate
8
+ 'hello'
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+
3
+ require 'sinatra/base'
4
+ require 'sinatra/google-auth'
5
+
6
+ class App < Sinatra::Base
7
+ register Sinatra::GoogleAuth
8
+ use Sinatra::GoogleAuth::Middleware
9
+
10
+ get '*' do
11
+ 'hello'
12
+ end
13
+ end
14
+
15
+ run App
data/test/user_test.ru ADDED
@@ -0,0 +1,19 @@
1
+ require 'bundler'
2
+
3
+ require 'sinatra'
4
+ require 'sinatra/google-auth'
5
+
6
+ class App < Sinatra::Base
7
+ register Sinatra::GoogleAuth
8
+
9
+ def on_user(info)
10
+ puts info.inspect
11
+ end
12
+
13
+ get '*' do
14
+ authenticate
15
+ 'hello'
16
+ end
17
+ end
18
+
19
+ run App
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.8
4
+ version: 1.0.0
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-06-13 00:00:00.000000000Z
12
+ date: 2012-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: omniauth-openid
16
- requirement: &70306476335880 !ruby/object:Gem::Requirement
15
+ name: omniauth-google-apps
16
+ requirement: &70101722473520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70306476335880
24
+ version_requirements: *70101722473520
25
+ - !ruby/object:Gem::Dependency
26
+ name: oa-openid
27
+ requirement: &70101722472800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70101722472800
25
36
  description: Drop-in google auth for sinatra apps
26
37
  email:
27
38
  - christopher.continanza@gmail.com
@@ -38,6 +49,10 @@ files:
38
49
  - lib/sinatra/google-auth.rb
39
50
  - lib/sinatra/google-auth/version.rb
40
51
  - sinatra-google-auth.gemspec
52
+ - test/classic_sytle.rb
53
+ - test/classic_sytle.ru
54
+ - test/modular_middleware.ru
55
+ - test/user_test.ru
41
56
  homepage: ''
42
57
  licenses: []
43
58
  post_install_message:
@@ -62,4 +77,8 @@ rubygems_version: 1.8.10
62
77
  signing_key:
63
78
  specification_version: 3
64
79
  summary: Helpers and routes for google open-id authentication for Sinatra.
65
- test_files: []
80
+ test_files:
81
+ - test/classic_sytle.rb
82
+ - test/classic_sytle.ru
83
+ - test/modular_middleware.ru
84
+ - test/user_test.ru