Browse Source

Don't send openid.ns for version 1 requests, as things like blogger throw hissy fits

tags/0.5
Chris Smith 15 years ago
parent
commit
30e701107c
1 changed files with 14 additions and 3 deletions
  1. 14
    3
      urlbuilder.inc.php

+ 14
- 3
urlbuilder.inc.php View File

26
 
26
 
27
  class URLBuilder {
27
  class URLBuilder {
28
 
28
 
29
+  const MIN_VERSION_FOR_NS = 2;
30
+
29
   private static $namespace = array(
31
   private static $namespace = array(
30
    1 => 'http://openid.net/signon/1.1',
32
    1 => 'http://openid.net/signon/1.1',
31
    2 => 'http://specs.openid.net/auth/2.0'
33
    2 => 'http://specs.openid.net/auth/2.0'
58
 
60
 
59
   public static function buildRequest($type, $base, $delegate, $identity, $returnURL, $handle, $version = 1) {
61
   public static function buildRequest($type, $base, $delegate, $identity, $returnURL, $handle, $version = 1) {
60
    $args = array(
62
    $args = array(
61
-    'openid.ns' => self::$namespace[$version],
62
     'openid.mode' => 'checkid_' . $type,
63
     'openid.mode' => 'checkid_' . $type,
63
     'openid.identity' => $delegate,
64
     'openid.identity' => $delegate,
64
     'openid.claimed_id' => $identity,
65
     'openid.claimed_id' => $identity,
67
 		array('openid.nonce' => $_SESSION['openid']['nonce']))
68
 		array('openid.nonce' => $_SESSION['openid']['nonce']))
68
    );
69
    );
69
 
70
 
71
+   if ($version >= self::MIN_VERSION_FOR_NS) {
72
+    $args['openid.ns'] = self::$namespace[$version];
73
+   }
74
+
70
    if ($handle !== null) {
75
    if ($handle !== null) {
71
     $args['openid.assoc_handle'] = $handle;
76
     $args['openid.assoc_handle'] = $handle;
72
    }
77
    }
110
 
115
 
111
   public static function buildAssociate($server, $version = 1) {
116
   public static function buildAssociate($server, $version = 1) {
112
    $args = array(
117
    $args = array(
113
-        'openid.ns' => self::$namespace[$version],
114
 	'openid.mode' => 'associate',
118
 	'openid.mode' => 'associate',
115
 	'openid.assoc_type' => 'HMAC-SHA1',
119
 	'openid.assoc_type' => 'HMAC-SHA1',
116
    );
120
    );
117
 
121
 
122
+   if ($version >= self::MIN_VERSION_FOR_NS) {
123
+    $args['openid.ns'] = self::$namespace[$version];
124
+   }
125
+
118
    if (KeyManager::supportsDH()) {
126
    if (KeyManager::supportsDH()) {
119
     $args['openid.session_type'] = 'DH-SHA1';
127
     $args['openid.session_type'] = 'DH-SHA1';
120
     $args['openid.dh_modulus'] = KeyManager::getDhModulus();
128
     $args['openid.dh_modulus'] = KeyManager::getDhModulus();
129
 
137
 
130
   public static function buildAuth($params, $version = 1) {
138
   public static function buildAuth($params, $version = 1) {
131
    $args = array(
139
    $args = array(
132
-        'openid.ns' => self::$namespace[$version],
133
 	'openid.mode' => 'check_authentication'
140
 	'openid.mode' => 'check_authentication'
134
    );
141
    );
135
 
142
 
143
+   if ($version >= self::MIN_VERSION_FOR_NS) {
144
+    $args['openid.ns'] = self::$namespace[$version];
145
+   }
146
+
136
    $toadd = array('assoc_handle', 'sig', 'signed');
147
    $toadd = array('assoc_handle', 'sig', 'signed');
137
    $toadd = array_merge($toadd, explode(',', $params['openid_signed']));
148
    $toadd = array_merge($toadd, explode(',', $params['openid_signed']));
138
 
149
 

Loading…
Cancel
Save