rack-openid 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ffa1c0c3b3e9d62ad033405c449ca5bbe6289734
4
+ data.tar.gz: fa39ead3431fa078dba08042948b0b45bd681a46
5
+ SHA512:
6
+ metadata.gz: ffdb2ac397a554858029744ac48855745fccffdb4b49c410255a8f857e3a92fe97ebb2e43a95c73d752189cf2c3d41e63ec98884aba7ae9fecdec60104ba077a
7
+ data.tar.gz: 72a9a6834c6584cc39b592aab031023324ca3cfe7122f5ed5ba09605847b7805c57057a7e2bcebb9a11a43223c81684f91eaba063ed48e2b5fd9f3ebd038b48f
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class OpenID
3
+ VERSION = "1.4.0"
4
+ end
5
+ end
data/lib/rack/openid.rb CHANGED
@@ -117,14 +117,14 @@ module Rack #:nodoc:
117
117
 
118
118
  consumer = ::OpenID::Consumer.new(session, @store)
119
119
  identifier = params['identifier'] || params['identity']
120
- immediate = params['immediate'] == 'true'
121
120
 
122
121
  begin
123
122
  oidreq = consumer.begin(identifier)
124
123
  add_simple_registration_fields(oidreq, params)
125
124
  add_attribute_exchange_fields(oidreq, params)
126
125
  add_oauth_fields(oidreq, params)
127
- url = open_id_redirect_url(req, oidreq, params["trust_root"], params["return_to"], params["method"], immediate)
126
+
127
+ url = open_id_redirect_url(req, oidreq, params)
128
128
  return redirect_to(url)
129
129
  rescue ::OpenID::OpenIDError, Timeout::Error => e
130
130
  env[RESPONSE] = MissingResponse.new
@@ -181,9 +181,9 @@ module Rack #:nodoc:
181
181
  env["REQUEST_URI"] = request_uri
182
182
  end
183
183
 
184
- def realm_url(req)
184
+ def scheme_with_host_and_port(req, host = nil)
185
185
  url = req.scheme + "://"
186
- url << req.host
186
+ url << (host || req.host)
187
187
 
188
188
  scheme, port = req.scheme, req.port
189
189
  if scheme == "https" && port != 443 ||
@@ -194,8 +194,17 @@ module Rack #:nodoc:
194
194
  url
195
195
  end
196
196
 
197
+ def realm(req, domain = nil)
198
+ if domain
199
+ scheme_with_host_and_port(req, domain)
200
+ else
201
+ scheme_with_host_and_port(req)
202
+ end
203
+
204
+ end
205
+
197
206
  def request_url(req)
198
- url = realm_url(req)
207
+ url = scheme_with_host_and_port(req)
199
208
  url << req.script_name
200
209
  url << req.path_info
201
210
  url << "?#{req.query_string}" if req.query_string.to_s.length > 0
@@ -206,7 +215,13 @@ module Rack #:nodoc:
206
215
  [303, {"Content-Type" => "text/html", "Location" => url}, []]
207
216
  end
208
217
 
209
- def open_id_redirect_url(req, oidreq, trust_root, return_to, method, immediate)
218
+ def open_id_redirect_url(req, oidreq, options)
219
+ trust_root = options["trust_root"]
220
+ return_to = options["return_to"]
221
+ method = options["method"]
222
+ immediate = options["immediate"] == "true"
223
+
224
+ realm = realm(req, options["realm_domain"])
210
225
  request_url = request_url(req)
211
226
 
212
227
  if return_to
@@ -218,7 +233,7 @@ module Rack #:nodoc:
218
233
 
219
234
  method = method.to_s.downcase
220
235
  oidreq.return_to_args['_method'] = method unless method == "get"
221
- oidreq.redirect_url(trust_root || realm_url(req), return_to || request_url, immediate)
236
+ oidreq.redirect_url(trust_root || realm, return_to || request_url, immediate)
222
237
  end
223
238
 
224
239
  def add_simple_registration_fields(oidreq, fields)
metadata CHANGED
@@ -1,101 +1,75 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-openid
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease:
6
- segments:
7
- - 1
8
- - 3
9
- - 1
10
- version: 1.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
7
+ - Michael Grosser
13
8
  - Joshua Peek
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-02-25 00:00:00 -06:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-10-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rack
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 19
30
- segments:
31
- - 1
32
- - 1
33
- - 0
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
34
20
  version: 1.1.0
35
21
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: ruby-openid
39
22
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 27
46
- segments:
47
- - 2
48
- - 1
49
- - 8
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.1.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: ruby-openid
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
50
34
  version: 2.1.8
51
35
  type: :runtime
52
- version_requirements: *id002
53
- description: " Provides a more HTTPish API around the ruby-openid library\n"
54
- email: josh@joshpeek.com
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: 2.1.8
42
+ description:
43
+ email: michael@grosser.it
55
44
  executables: []
56
-
57
45
  extensions: []
58
-
59
46
  extra_rdoc_files: []
60
-
61
- files:
47
+ files:
62
48
  - lib/rack/openid.rb
63
49
  - lib/rack/openid/simple_auth.rb
64
- - LICENSE
65
- - README.rdoc
66
- has_rdoc: true
67
- homepage: http://github.com/josh/rack-openid
68
- licenses: []
69
-
50
+ - lib/rack/openid/version.rb
51
+ homepage: https://github.com/grosser/rack-openid
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
70
55
  post_install_message:
71
56
  rdoc_options: []
72
-
73
- require_paths:
57
+ require_paths:
74
58
  - lib
75
- required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 3
81
- segments:
82
- - 0
83
- version: "0"
84
- required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- hash: 3
90
- segments:
91
- - 0
92
- version: "0"
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
93
69
  requirements: []
94
-
95
70
  rubyforge_project:
96
- rubygems_version: 1.5.2
71
+ rubygems_version: 2.0.6
97
72
  signing_key:
98
- specification_version: 3
73
+ specification_version: 4
99
74
  summary: Provides a more HTTPish API around the ruby-openid library
100
75
  test_files: []
101
-
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 Joshua Peek
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,70 +0,0 @@
1
- = Rack::OpenID
2
-
3
- Provides a more HTTPish API around the ruby-openid library.
4
-
5
- === Usage
6
-
7
- You trigger an OpenID request similar to HTTP authentication. From your app, return a "401 Unauthorized" and a "WWW-Authenticate" header with the identifier you would like to validate.
8
-
9
- On competition, the OpenID response is automatically verified and assigned to
10
- <tt>env["rack.openid.response"]</tt>.
11
-
12
- === Rack Example
13
-
14
- MyApp = lambda { |env|
15
- if resp = env["rack.openid.response"]
16
- case resp.status
17
- when :success
18
- ...
19
- when :failure
20
- ...
21
- else
22
- [401, {"WWW-Authenticate" => 'OpenID identifier="http://example.com/"'}, []]
23
- end
24
- }
25
-
26
- use Rack::OpenID
27
- run MyApp
28
-
29
- === Sinatra Example
30
-
31
- # Session needs to be before Rack::OpenID
32
- use Rack::Session::Cookie
33
-
34
- require 'rack/openid'
35
- use Rack::OpenID
36
-
37
- get '/login' do
38
- erb :login
39
- end
40
-
41
- post '/login' do
42
- if resp = request.env["rack.openid.response"]
43
- if resp.status == :success
44
- "Welcome: #{resp.display_identifier}"
45
- else
46
- "Error: #{resp.status}"
47
- end
48
- else
49
- headers 'WWW-Authenticate' => Rack::OpenID.build_header(
50
- :identifier => params["openid_identifier"]
51
- )
52
- throw :halt, [401, 'got openid?']
53
- end
54
- end
55
-
56
- enable :inline_templates
57
-
58
- __END__
59
-
60
- @@ login
61
- <form action="/login" method="post">
62
- <p>
63
- <label for="openid_identifier">OpenID:</label>
64
- <input id="openid_identifier" name="openid_identifier" type="text" />
65
- </p>
66
-
67
- <p>
68
- <input name="commit" type="submit" value="Sign in" />
69
- </p>
70
- </form>