oa-openid 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +37 -0
- data/lib/omniauth/openid.rb +7 -1
- data/lib/omniauth/strategies/google_apps.rb +16 -0
- data/lib/omniauth/strategies/open_id.rb +20 -17
- metadata +108 -39
- data/lib/omniauth/strategies/google.rb +0 -7
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
= OmniAuth::OpenID
|
2
|
+
|
3
|
+
OpenID strategies for the OmniAuth gem.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
To get just OpenID functionality:
|
8
|
+
|
9
|
+
gem install oa-openid
|
10
|
+
|
11
|
+
For the full auth suite:
|
12
|
+
|
13
|
+
gem install omniauth
|
14
|
+
|
15
|
+
== Stand-Alone Example
|
16
|
+
|
17
|
+
Use the strategy as a middleware in your application:
|
18
|
+
|
19
|
+
require 'omniauth/openid'
|
20
|
+
require 'openid/store/filesystem'
|
21
|
+
|
22
|
+
use OmniAuth::Strategies::OpenID, OpenID::Store::Filesystem.new('/tmp')
|
23
|
+
|
24
|
+
Then simply direct users to '/auth/open_id' to prompt them for their OpenID identifier. You may also pre-set the identifier by passing an <tt>identifier</tt> parameter to the URL (Example: <tt>/auth/open_id?identifier=google.com</tt>).
|
25
|
+
|
26
|
+
== OmniAuth Builder
|
27
|
+
|
28
|
+
If OpenID is one of several authentication strategies, use the OmniAuth Builder:
|
29
|
+
|
30
|
+
require 'omniauth/openid'
|
31
|
+
require 'omniauth/basic' # for Campfire
|
32
|
+
require 'openid/store/filesystem'
|
33
|
+
|
34
|
+
use OmniAuth::Builder do
|
35
|
+
provider :open_id, OpenID::Store::Filesystem.new('/tmp')
|
36
|
+
provider :campfire
|
37
|
+
end
|
data/lib/omniauth/openid.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'omniauth/openid'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class GoogleApps < OmniAuth::Strategies::OpenID
|
6
|
+
def initialize(app, store = nil, options = {})
|
7
|
+
options[:name] ||= 'google_apps'
|
8
|
+
super(app, store, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def identifier
|
12
|
+
options[:domain] || request['domain']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,10 +1,18 @@
|
|
1
1
|
require 'rack/openid'
|
2
|
+
require 'gapps_openid'
|
3
|
+
require 'omniauth/openid'
|
2
4
|
|
3
5
|
module OmniAuth
|
4
6
|
module Strategies
|
5
7
|
class OpenID
|
6
8
|
include OmniAuth::Strategy
|
7
9
|
|
10
|
+
attr_accessor :options
|
11
|
+
|
12
|
+
# Should be 'openid_url'
|
13
|
+
# @see http://github.com/intridea/omniauth/issues/issue/13
|
14
|
+
IDENTIFIER_URL_PARAMETER = 'identifier'
|
15
|
+
|
8
16
|
AX = {
|
9
17
|
:email => 'http://axschema.org/contact/email',
|
10
18
|
:name => 'http://axschema.org/namePerson',
|
@@ -20,8 +28,8 @@ module OmniAuth
|
|
20
28
|
def initialize(app, store = nil, options = {})
|
21
29
|
super(app, options[:name] || :open_id)
|
22
30
|
@options = options
|
23
|
-
@options[:required] ||= [AX[:email], AX[:
|
24
|
-
@options[:optional] ||= [AX[:
|
31
|
+
@options[:required] ||= [AX[:email], AX[:first_name], AX[:last_name], 'email', 'fullname']
|
32
|
+
@options[:optional] ||= [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname']
|
25
33
|
@store = store
|
26
34
|
end
|
27
35
|
|
@@ -41,7 +49,7 @@ module OmniAuth
|
|
41
49
|
end
|
42
50
|
|
43
51
|
def identifier
|
44
|
-
request[
|
52
|
+
request[IDENTIFIER_URL_PARAMETER]
|
45
53
|
end
|
46
54
|
|
47
55
|
def request_phase
|
@@ -53,21 +61,17 @@ module OmniAuth
|
|
53
61
|
response = openid.call(env)
|
54
62
|
case env['rack.openid.response']
|
55
63
|
when Rack::OpenID::MissingResponse, Rack::OpenID::TimeoutResponse
|
56
|
-
fail
|
64
|
+
fail!(:connection_failed)
|
57
65
|
else
|
58
66
|
response
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
62
70
|
def get_identifier
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
OmniAuth::Form.build('OpenID Authentication') do
|
68
|
-
text_field('OpenID Identifier', 'identifier')
|
69
|
-
end.to_response
|
70
|
-
end
|
71
|
+
OmniAuth::Form.build('OpenID Authentication') do
|
72
|
+
label_field('OpenID Identifier', IDENTIFIER_URL_PARAMETER)
|
73
|
+
input_field('url', IDENTIFIER_URL_PARAMETER)
|
74
|
+
end.to_response
|
71
75
|
end
|
72
76
|
|
73
77
|
def callback_phase
|
@@ -76,12 +80,11 @@ module OmniAuth
|
|
76
80
|
openid = Rack::OpenID.new(lambda{|env| [200,{},[]]}, @store)
|
77
81
|
openid.call(env)
|
78
82
|
resp = env.delete('rack.openid.response')
|
79
|
-
|
80
|
-
when :failure
|
81
|
-
fail!(:invalid_credentials)
|
82
|
-
when :success
|
83
|
+
if resp && resp.status == :success
|
83
84
|
request['auth'] = auth_hash(resp)
|
84
85
|
@app.call(env)
|
86
|
+
else
|
87
|
+
fail!(:invalid_credentials)
|
85
88
|
end
|
86
89
|
end
|
87
90
|
|
@@ -120,4 +123,4 @@ module OmniAuth
|
|
120
123
|
end
|
121
124
|
end
|
122
125
|
end
|
123
|
-
end
|
126
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oa-openid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Michael Bleigh
|
@@ -14,85 +15,149 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-16 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - "="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
+
hash: 23
|
27
28
|
segments:
|
28
29
|
- 0
|
29
30
|
- 0
|
30
|
-
-
|
31
|
-
version: 0.0.
|
31
|
+
- 4
|
32
|
+
version: 0.0.4
|
33
|
+
requirement: *id001
|
34
|
+
name: oa-core
|
35
|
+
prerelease: false
|
32
36
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 17
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 1
|
47
|
+
- 1
|
48
|
+
version: 1.1.1
|
49
|
+
requirement: *id002
|
35
50
|
name: rack-openid
|
36
51
|
prerelease: false
|
37
|
-
|
52
|
+
type: :runtime
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
38
56
|
requirements:
|
39
57
|
- - ">="
|
40
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
41
60
|
segments:
|
42
61
|
- 0
|
43
62
|
version: "0"
|
63
|
+
requirement: *id003
|
64
|
+
name: ruby-openid-apps-discovery
|
65
|
+
prerelease: false
|
44
66
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
67
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
48
|
-
|
49
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
68
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
50
70
|
requirements:
|
51
71
|
- - ">="
|
52
72
|
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
53
74
|
segments:
|
54
|
-
-
|
55
|
-
|
56
|
-
|
57
|
-
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirement: *id004
|
78
|
+
name: rake
|
79
|
+
prerelease: false
|
58
80
|
type: :development
|
59
|
-
version_requirements: *id003
|
60
81
|
- !ruby/object:Gem::Dependency
|
61
|
-
|
62
|
-
|
63
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
82
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
64
84
|
requirements:
|
65
|
-
- -
|
85
|
+
- - ~>
|
66
86
|
- !ruby/object:Gem::Version
|
87
|
+
hash: 15
|
67
88
|
segments:
|
68
89
|
- 0
|
69
|
-
|
90
|
+
- 0
|
91
|
+
- 8
|
92
|
+
version: 0.0.8
|
93
|
+
requirement: *id005
|
94
|
+
name: mg
|
95
|
+
prerelease: false
|
70
96
|
type: :development
|
71
|
-
version_requirements: *id004
|
72
97
|
- !ruby/object:Gem::Dependency
|
73
|
-
|
74
|
-
|
75
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
76
100
|
requirements:
|
77
|
-
- -
|
101
|
+
- - ~>
|
78
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 27
|
79
104
|
segments:
|
105
|
+
- 1
|
106
|
+
- 3
|
80
107
|
- 0
|
81
|
-
version:
|
108
|
+
version: 1.3.0
|
109
|
+
requirement: *id006
|
110
|
+
name: rspec
|
111
|
+
prerelease: false
|
82
112
|
type: :development
|
83
|
-
version_requirements: *id005
|
84
113
|
- !ruby/object:Gem::Dependency
|
85
|
-
|
114
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ~>
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 19
|
120
|
+
segments:
|
121
|
+
- 1
|
122
|
+
- 3
|
123
|
+
- 4
|
124
|
+
version: 1.3.4
|
125
|
+
requirement: *id007
|
126
|
+
name: webmock
|
86
127
|
prerelease: false
|
87
|
-
|
128
|
+
type: :development
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
88
132
|
requirements:
|
89
|
-
- -
|
133
|
+
- - ~>
|
90
134
|
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
91
136
|
segments:
|
92
137
|
- 0
|
93
|
-
|
138
|
+
- 5
|
139
|
+
- 4
|
140
|
+
version: 0.5.4
|
141
|
+
requirement: *id008
|
142
|
+
name: rack-test
|
143
|
+
prerelease: false
|
144
|
+
type: :development
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ~>
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 1
|
152
|
+
segments:
|
153
|
+
- 1
|
154
|
+
- 4
|
155
|
+
- 3
|
156
|
+
version: 1.4.3
|
157
|
+
requirement: *id009
|
158
|
+
name: json
|
159
|
+
prerelease: false
|
94
160
|
type: :development
|
95
|
-
version_requirements: *id006
|
96
161
|
description: OpenID strategies for OmniAuth.
|
97
162
|
email: michael@intridea.com
|
98
163
|
executables: []
|
@@ -103,7 +168,7 @@ extra_rdoc_files: []
|
|
103
168
|
|
104
169
|
files:
|
105
170
|
- lib/omniauth/openid.rb
|
106
|
-
- lib/omniauth/strategies/
|
171
|
+
- lib/omniauth/strategies/google_apps.rb
|
107
172
|
- lib/omniauth/strategies/open_id.rb
|
108
173
|
- README.rdoc
|
109
174
|
- LICENSE.rdoc
|
@@ -118,23 +183,27 @@ rdoc_options: []
|
|
118
183
|
require_paths:
|
119
184
|
- lib
|
120
185
|
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
121
187
|
requirements:
|
122
188
|
- - ">="
|
123
189
|
- !ruby/object:Gem::Version
|
190
|
+
hash: 3
|
124
191
|
segments:
|
125
192
|
- 0
|
126
193
|
version: "0"
|
127
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
|
+
none: false
|
128
196
|
requirements:
|
129
197
|
- - ">="
|
130
198
|
- !ruby/object:Gem::Version
|
199
|
+
hash: 3
|
131
200
|
segments:
|
132
201
|
- 0
|
133
202
|
version: "0"
|
134
203
|
requirements: []
|
135
204
|
|
136
205
|
rubyforge_project:
|
137
|
-
rubygems_version: 1.3.
|
206
|
+
rubygems_version: 1.3.7
|
138
207
|
signing_key:
|
139
208
|
specification_version: 3
|
140
209
|
summary: OpenID strategies for OmniAuth.
|