easy-rack-open-id 0.2.0 → 0.2.1
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/VERSION +1 -1
- data/easy-rack-open-id.gemspec +2 -2
- data/lib/easy_rack_open_id_processing.rb +29 -30
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/easy-rack-open-id.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{easy-rack-open-id}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sam Schenkman-Moore"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-30}
|
13
13
|
s.description = %q{You supply OpenIDs, this keeps anyone but people with access to those ids from getting through. You don't even have to make a form. :)}
|
14
14
|
s.email = %q{samsm@samsm.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class EasyRackOpenIDProcessing
|
2
|
-
|
2
|
+
|
3
3
|
attr_accessor :env, :options
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(app, options ={})
|
6
6
|
@app = app
|
7
7
|
@options = options
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def call(env)
|
11
11
|
@env = env
|
12
12
|
if logout_path == path
|
@@ -24,24 +24,24 @@ class EasyRackOpenIDProcessing
|
|
24
24
|
open_id_login
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def asset?
|
29
29
|
0 == path.index(asset_prefix)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def asset_prefix
|
33
33
|
'/easy-rack-openid-assets'
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def gem_public_path
|
37
37
|
File.dirname(__FILE__) + '/../public/'
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def open_id_login
|
41
41
|
if resp = env["rack.openid.response"]
|
42
42
|
case resp.status
|
43
43
|
when :success
|
44
|
-
|
44
|
+
|
45
45
|
# Load in any registration data gathered
|
46
46
|
profile_data = {}
|
47
47
|
# merge the SReg data and the AX data into a single hash of profile data
|
@@ -50,9 +50,8 @@ class EasyRackOpenIDProcessing
|
|
50
50
|
profile_data.merge! data_response.from_success_response( resp ).data
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
profile_data['identifier'] = resp.identity_url
|
55
|
-
# require 'ruby-debug' ; debugger
|
56
55
|
#... save id and registration and forward to ...
|
57
56
|
self.verified_identity = profile_data
|
58
57
|
forward_to(protected_path)
|
@@ -72,11 +71,11 @@ class EasyRackOpenIDProcessing
|
|
72
71
|
end
|
73
72
|
end
|
74
73
|
end
|
75
|
-
|
74
|
+
|
76
75
|
def path
|
77
76
|
env['REQUEST_PATH']
|
78
77
|
end
|
79
|
-
|
78
|
+
|
80
79
|
def present_login_options
|
81
80
|
if login_path
|
82
81
|
forward_to(login_path)
|
@@ -93,11 +92,11 @@ class EasyRackOpenIDProcessing
|
|
93
92
|
ok(form)
|
94
93
|
end
|
95
94
|
end
|
96
|
-
|
95
|
+
|
97
96
|
def forward_to(url)
|
98
97
|
[302, {'Location' => url}, ["Forwarding to #{url}"]]
|
99
98
|
end
|
100
|
-
|
99
|
+
|
101
100
|
def allowed?
|
102
101
|
if allowed_identifiers
|
103
102
|
allowed_identifiers.include? verified_identifier
|
@@ -107,34 +106,34 @@ class EasyRackOpenIDProcessing
|
|
107
106
|
verified_identifier
|
108
107
|
end
|
109
108
|
end
|
110
|
-
|
109
|
+
|
111
110
|
def identity_match
|
112
111
|
options[:identity_match]
|
113
112
|
end
|
114
|
-
|
113
|
+
|
115
114
|
def allowed_identifiers
|
116
115
|
options[:allowed_identifiers]
|
117
116
|
end
|
118
|
-
|
117
|
+
|
119
118
|
def logout_path
|
120
119
|
options[:logout_path] || '/logout'
|
121
120
|
end
|
122
|
-
|
121
|
+
|
123
122
|
def logout
|
124
123
|
self.verified_identity = nil
|
125
124
|
if after_logout_path
|
126
125
|
forward_to(after_logout_path)
|
127
126
|
end
|
128
127
|
end
|
129
|
-
|
128
|
+
|
130
129
|
def after_logout_path
|
131
130
|
options[:after_logout_path]
|
132
131
|
end
|
133
|
-
|
132
|
+
|
134
133
|
def login_path
|
135
134
|
options[:login_path]
|
136
135
|
end
|
137
|
-
|
136
|
+
|
138
137
|
def identitifier_to_verify
|
139
138
|
@identitifier_to_verify ||=
|
140
139
|
if env["rack.request.query_hash"] && env["rack.request.query_hash"]["openid_identifier"]
|
@@ -149,7 +148,7 @@ class EasyRackOpenIDProcessing
|
|
149
148
|
end
|
150
149
|
end
|
151
150
|
end
|
152
|
-
|
151
|
+
|
153
152
|
def valid_identifier?
|
154
153
|
uri = URI.parse(identitifier_to_verify.to_s.strip)
|
155
154
|
uri = URI.parse("http://#{uri}") unless uri.scheme
|
@@ -159,35 +158,35 @@ class EasyRackOpenIDProcessing
|
|
159
158
|
# raise InvalidOpenId.new("#{url} is not an OpenID URL")
|
160
159
|
false
|
161
160
|
end
|
162
|
-
|
161
|
+
|
163
162
|
def verified_identity=(hash)
|
164
163
|
session['verified_identity'] = hash
|
165
164
|
end
|
166
|
-
|
165
|
+
|
167
166
|
def verified_identity
|
168
167
|
session['verified_identity']
|
169
168
|
end
|
170
|
-
|
169
|
+
|
171
170
|
def verified_identifier
|
172
171
|
verified_identity && verified_identity['identifier']
|
173
172
|
end
|
174
|
-
|
173
|
+
|
175
174
|
def session
|
176
175
|
env['rack.session']
|
177
176
|
end
|
178
|
-
|
177
|
+
|
179
178
|
def protected_path=(path)
|
180
179
|
session['return_to'] = path
|
181
180
|
end
|
182
|
-
|
181
|
+
|
183
182
|
def protected_path
|
184
183
|
session['return_to'] || default_return_to
|
185
184
|
end
|
186
|
-
|
185
|
+
|
187
186
|
def default_return_to
|
188
187
|
options[:default_return_to] || '/'
|
189
188
|
end
|
190
|
-
|
189
|
+
|
191
190
|
def ok(text, content_type = 'text/html')
|
192
191
|
[200,{"Content-Type" => content_type, 'Content-Length'=> text.length},[text]]
|
193
192
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-rack-open-id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Schenkman-Moore
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-30 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|