ruby-openid 2.1.2 → 2.1.4

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.

Potentially problematic release.


This version of ruby-openid might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,78 +1,11 @@
1
- Fri Jun 27 15:39:14 PDT 2008 Kevin Turner <kevin@janrain.com>
2
- tagged 2.1.2
1
+ Fri Dec 19 11:50:10 PST 2008 cygnus@janrain.com
2
+ tagged 2.1.4
3
3
 
4
- Fri Jun 27 15:38:05 PDT 2008 Kevin Turner <kevin@janrain.com>
5
- * update version to 2.1.2
4
+ Fri Dec 19 11:48:25 PST 2008 cygnus@janrain.com
5
+ * Version: 2.1.4
6
6
 
7
- Fri Jun 27 15:01:35 PDT 2008 Kevin Turner <kevin@janrain.com>
8
- * util: remove call to srand
9
-
10
- From the Ruby FAQ:
11
-
12
- 9.2 How do random number seeds work?
13
-
14
- It depends. In Ruby versions prior to 1.5.2, the random number generator had
15
- (by default) a constant seed, and so would produce the same series of numbers
16
- each time a program was run. If you needed less deterministic behaviors, you
17
- called srand to set up a less predictable seed.
18
-
19
- Newer Rubys (Rubies?) have a different behavior. If rand is called without a
20
- prior call to srand, Ruby will generate its own random(ish) seed. Successive
21
- runs of a program that does not use srand will generate different sequences of
22
- random numbers. To get the old, predictable, behavior (perhaps for testing),
23
- call srand with a constant seed.
7
+ Fri Dec 19 11:42:47 PST 2008 cygnus@janrain.com
8
+ * Normalize XRIs when doing discovery in accordance with the OpenID 2 spec
24
9
 
25
- Fri Jun 27 13:34:43 PDT 2008 Kevin Turner <kevin@janrain.com>
26
- * LICENSE: htmltokenizer is (c) 2004 Ben Giddings
27
-
28
- Fri Jun 27 13:32:09 PDT 2008 Kevin Turner <kevin@janrain.com>
29
- * Yadis.html_yadis_location: catch HTMLTokenizerError
30
-
31
- Fri Jun 27 13:24:13 PDT 2008 Kevin Turner <kevin@janrain.com>
32
- * htmltokenizer: define HTMLTokenizerError to raise
33
-
34
- Fri Jun 27 13:18:38 PDT 2008 Kevin Turner <kevin@janrain.com>
35
- * htmltokenizer: Don't raise OpenIDError from htmltokenizer (it's not in the OpenID module namespace) #255
36
-
37
- Wed Jun 25 17:31:26 PDT 2008 Kevin Turner <kevin@janrain.com>
38
- * OpenID::Server::CheckIDRequest.answer: document return type
39
-
40
- Wed Jun 25 17:06:35 PDT 2008 Kevin Turner <kevin@janrain.com>
41
- * TrustRoot.check_sanity: don't fail if the trust root is not parseable
42
-
43
- Wed Jun 25 16:31:30 PDT 2008 Kevin Turner <kevin@janrain.com>
44
- * Message.from_http_response: accept 206 code
45
-
46
- Wed Jun 25 14:14:05 PDT 2008 Kevin Turner <kevin@janrain.com>
47
- * move OpenID::VERSION definition in openid.rb, for #256
48
-
49
- Wed Jun 25 13:55:18 PDT 2008 Kevin Turner <kevin@janrain.com>
50
- * Add admin/gettlds.py to ease updating of TLD list in trust root validation
51
-
52
- Wed Jun 25 13:50:22 PDT 2008 Kevin Turner <kevin@janrain.com>
53
- * TrustRoot.TOP_LEVEL_DOMAINS: updated
54
-
55
- Fri Jun 13 14:18:04 PDT 2008 Kevin Turner <kevin@janrain.com>
56
- * xrds.rb: fix stray colon
57
-
58
- Fri Jun 13 13:41:58 PDT 2008 Kevin Turner <kevin@janrain.com>
59
- * Yadis::get_canonical_id: case-insensitive comparison
60
-
61
- Porting a patch from =wil:
62
-
63
- 1. There should only be a single CanonicalID in each XRD (in the latest XRI
64
- resolution spec), so I made it use the first CID found instead of the last.
65
-
66
- 2. Use case-insensitive comparison when comparing CanonicalIDs.
67
-
68
- Wed Jun 11 15:24:12 PDT 2008 Kevin Turner <kevin@janrain.com>
69
- * Accept response code 206 from fetcher results. Fixes #260
70
-
71
- Wed Jun 11 11:27:25 PDT 2008 cygnus@janrain.com
72
- * admin/fixperms: Fix stale entries
73
-
74
- Wed Jun 11 11:08:11 PDT 2008 cygnus@janrain.com
75
- * Add test cases for trust roots with non-ASCII characters in path or hostname
76
-
77
- Fri Jun 6 15:50:12 PDT 2008 cygnus@janrain.com
78
- tagged 2.1.1
10
+ Tue Dec 16 13:14:07 PST 2008 cygnus@janrain.com
11
+ tagged 2.1.3
@@ -13,7 +13,7 @@
13
13
  # permissions and limitations under the License.
14
14
 
15
15
  module OpenID
16
- VERSION = "2.1.2"
16
+ VERSION = "2.1.4"
17
17
  end
18
18
 
19
19
  require "openid/consumer"
@@ -369,7 +369,8 @@ module OpenID
369
369
  if message.is_openid1
370
370
  return complete_invalid(message, nil)
371
371
  else
372
- return SetupNeededResponse.new(last_requested_endpoint, nil)
372
+ setup_url = message.get_arg(OPENID2_NS, 'user_setup_url')
373
+ return SetupNeededResponse.new(last_requested_endpoint, setup_url)
373
374
  end
374
375
  end
375
376
 
@@ -288,6 +288,13 @@ module OpenID
288
288
  return local_id
289
289
  end
290
290
 
291
+ def self.normalize_xri(xri)
292
+ # Normalize an XRI, stripping its scheme if present
293
+ m = /^xri:\/\/(.*)/.match(xri)
294
+ xri = m[1] if m
295
+ return xri
296
+ end
297
+
291
298
  def self.normalize_url(url)
292
299
  # Normalize a URL, converting normalization failures to
293
300
  # DiscoveryFailure
@@ -411,6 +418,7 @@ module OpenID
411
418
 
412
419
  def self.discover_xri(iname)
413
420
  endpoints = []
421
+ iname = self.normalize_xri(iname)
414
422
 
415
423
  begin
416
424
  canonical_id, services = Yadis::XRI::ProxyResolver.new().query(
@@ -187,7 +187,6 @@ module OpenID
187
187
 
188
188
  headers ||= {}
189
189
  headers['User-agent'] ||= USER_AGENT
190
- headers['Range'] ||= "0-#{MAX_RESPONSE_KB*1024}"
191
190
 
192
191
  begin
193
192
  conn = make_connection(url)
@@ -445,12 +445,12 @@ module OpenID
445
445
  # Raises #MalformedReturnURL when the +return_to+ URL is not
446
446
  # a URL.
447
447
  def initialize(identity, return_to, op_endpoint, trust_root=nil,
448
- immediate=false, assoc_handle=nil)
448
+ immediate=false, assoc_handle=nil, claimed_id=nil)
449
449
  @assoc_handle = assoc_handle
450
450
  @identity = identity
451
- @claimed_id = identity
451
+ @claimed_id = (claimed_id or identity)
452
452
  @return_to = return_to
453
- @trust_root = trust_root or return_to
453
+ @trust_root = (trust_root or return_to)
454
454
  @op_endpoint = op_endpoint
455
455
  @message = nil
456
456
 
@@ -756,7 +756,7 @@ module OpenID
756
756
  # immediate=false.
757
757
  setup_request = self.class.new(@identity, @return_to,
758
758
  @op_endpoint, @trust_root, false,
759
- @assoc_handle)
759
+ @assoc_handle, @claimed_id)
760
760
  setup_request.message = Message.new(@message.get_openid_namespace)
761
761
  setup_url = setup_request.encode_to_url(server_url)
762
762
  response.fields.set_arg(OPENID_NS, 'user_setup_url', setup_url)
@@ -32,7 +32,8 @@ module OpenID
32
32
  return nil if el.tag_name == 'html'
33
33
 
34
34
  if el.tag_name == 'meta' and (equiv = el.attr_hash['http-equiv'])
35
- if ['x-xrds-location','x-yadis-location'].member?(equiv.downcase)
35
+ if ['x-xrds-location','x-yadis-location'].member?(equiv.downcase) &&
36
+ el.attr_hash.member?('content')
36
37
  return CGI::unescapeHTML(el.attr_hash['content'])
37
38
  end
38
39
  end
@@ -0,0 +1,19 @@
1
+ <html>
2
+ <head>
3
+ <title />
4
+
5
+ <link rel="openid.server"
6
+ href="http://www.myopenid.com/server" />
7
+ <link rel="openid.delegate"
8
+ href="http://user.myopenid.com/" />
9
+ <link rel="openid2.local_id"
10
+ href="http://user.myopenid.com/" />
11
+ <link rel="openid2.provider"
12
+ href="http://www.myopenid.com/server" />
13
+ <meta http-equiv="X-XRDS-Location"
14
+ http://www.myopenid.com/xrds?username=user.myopenid.com" />
15
+
16
+ </head>
17
+ <body>
18
+ </body>
19
+ </html>
@@ -273,6 +273,33 @@ module OpenID
273
273
  false)
274
274
  end
275
275
 
276
+ def test_malformed_meta_tag
277
+ @id_url = "http://user.myopenid.com/"
278
+
279
+ services = _discover(
280
+ 'text/html',
281
+ read_data_file('test_discover/malformed_meta_tag.html', false),
282
+ 2)
283
+
284
+ _checkService(
285
+ services[0],
286
+ "http://www.myopenid.com/server",
287
+ @id_url,
288
+ @id_url,
289
+ nil,
290
+ ['2.0'],
291
+ false)
292
+
293
+ _checkService(
294
+ services[1],
295
+ "http://www.myopenid.com/server",
296
+ @id_url,
297
+ @id_url,
298
+ nil,
299
+ ['1.1'],
300
+ false)
301
+ end
302
+
276
303
  def test_html1
277
304
  services = _discover('text/html',
278
305
  read_data_file('test_discover/openid.html', false),
@@ -544,6 +571,28 @@ module OpenID
544
571
  '=smoker')
545
572
  end
546
573
 
574
+ def test_xri_normalize
575
+ user_xri, services = OpenID.discover_xri('xri://=smoker')
576
+
577
+ _checkService(services[0],
578
+ "http://www.myopenid.com/server",
579
+ Yadis::XRI.make_xri("=!1000"),
580
+ 'http://smoker.myopenid.com/',
581
+ Yadis::XRI.make_xri("=!1000"),
582
+ ['1.0'],
583
+ true,
584
+ '=smoker')
585
+
586
+ _checkService(services[1],
587
+ "http://www.livejournal.com/openid/server.bml",
588
+ Yadis::XRI.make_xri("=!1000"),
589
+ 'http://frank.livejournal.com/',
590
+ Yadis::XRI.make_xri("=!1000"),
591
+ ['1.0'],
592
+ true,
593
+ '=smoker')
594
+ end
595
+
547
596
  def test_xriNoCanonicalID
548
597
  silence_logging {
549
598
  user_xri, services = OpenID.discover_xri('=smoker*bad')
@@ -605,7 +605,9 @@ module OpenID
605
605
  expected_endpoint.local_id = nil
606
606
  expected_endpoint.claimed_id = claimed_id
607
607
 
608
- hacked_discover = Proc.new { ['unused', [expected_endpoint]] }
608
+ hacked_discover = Proc.new {
609
+ |_claimed_id| ['unused', [expected_endpoint]]
610
+ }
609
611
  idres = IdResHandler.new(resp_mesg, nil, nil, @endpoint)
610
612
  assert_log_matches('Performing discovery') {
611
613
  OpenID.with_method_overridden(:discover, hacked_discover) {
@@ -661,7 +663,7 @@ module OpenID
661
663
  'identity' => 'sour grapes',
662
664
  'claimed_id' => 'monkeysoft',
663
665
  'op_endpoint' => 'Phone Home'}) do |idres|
664
- idres.instance_def(:discover_and_verify) do
666
+ idres.instance_def(:discover_and_verify) do |claimed_id, endpoints|
665
667
  @endpoint = endpoint
666
668
  end
667
669
  end
@@ -684,7 +686,7 @@ module OpenID
684
686
  'claimed_id' => 'monkeysoft',
685
687
  'op_endpoint' => 'Green Cheese'}) do |idres|
686
688
  idres.extend(InstanceDefExtension)
687
- idres.instance_def(:discover_and_verify) do
689
+ idres.instance_def(:discover_and_verify) do |claimed_id, endpoints|
688
690
  @endpoint = endpoint
689
691
  end
690
692
  end
@@ -768,7 +770,7 @@ module OpenID
768
770
  assert_raises(verified_error) {
769
771
  call_verify_modify({'ns' => OPENID1_NS,
770
772
  'identity' => @endpoint.local_id}) { |idres|
771
- idres.instance_def(:discover_and_verify) do
773
+ idres.instance_def(:discover_and_verify) do |claimed_id, endpoints|
772
774
  raise verified_error
773
775
  end
774
776
  }
@@ -1421,6 +1421,7 @@ module OpenID
1421
1421
  @request.message = Message.new(OPENID1_NS)
1422
1422
  @request.mode = 'checkid_immediate'
1423
1423
  @request.immediate = true
1424
+ @request.claimed_id = 'http://claimed-id.test/'
1424
1425
  server_url = "http://setup-url.unittest/"
1425
1426
  # crappiting setup_url, you dirty my interface with your presence!
1426
1427
  answer = @request.answer(false, server_url)
@@ -1428,8 +1429,11 @@ module OpenID
1428
1429
  assert_equal(2, answer.fields.to_post_args.length, answer.fields)
1429
1430
  assert_equal(OPENID1_NS, answer.fields.get_openid_namespace)
1430
1431
  assert_equal('id_res', answer.fields.get_arg(OPENID_NS, 'mode'))
1431
- assert(answer.fields.get_arg(
1432
- OPENID_NS, 'user_setup_url', '').starts_with?(server_url))
1432
+
1433
+ usu = answer.fields.get_arg(OPENID_NS, 'user_setup_url', '')
1434
+ assert(usu.starts_with?(server_url))
1435
+ expected_substr = 'openid.claimed_id=http%3A%2F%2Fclaimed-id.test%2F'
1436
+ assert(!usu.index(expected_substr).nil?, usu)
1433
1437
  end
1434
1438
 
1435
1439
  def test_answerSetupDeny
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ruby-openid
5
5
  version: !ruby/object:Gem::Version
6
- version: 2.1.2
7
- date: 2008-06-27 00:00:00 -07:00
6
+ version: 2.1.4
7
+ date: 2008-12-19 00:00:00 -08:00
8
8
  summary: A library for consuming and serving OpenID identities.
9
9
  require_paths:
10
10
  - lib
@@ -256,6 +256,7 @@ files:
256
256
  - test/data/test_discover/yadis_idp.xml
257
257
  - test/data/test_discover/yadis_idp_delegate.xml
258
258
  - test/data/test_discover/yadis_no_delegate.xml
259
+ - test/data/test_discover/malformed_meta_tag.html
259
260
  - NOTICE
260
261
  - CHANGELOG
261
262
  - README