Browse Source

Verify claimed_id parameter properly

Closes #12
tags/0.6
Chris Smith 14 years ago
parent
commit
34ab8eb518
2 changed files with 10 additions and 4 deletions
  1. 4
    2
      processor.php
  2. 6
    2
      urlbuilder.inc.php

+ 4
- 2
processor.php View File

@@ -286,7 +286,9 @@
286 286
                          . URLBuilder::getCurrentURL());
287 287
   }
288 288
 
289
-  if ($_REQUEST['openid_identity'] != $_SESSION['openid']['claimedId'] && $_REQUEST['openid_identity'] != $_SESSION['openid']['opLocalId']) {
289
+  $id = $_REQUEST[isset($_REQUEST['openid_claimed_id']) ? 'openid_claimed_id' : 'openid_identity'];
290
+
291
+  if (!URLBuilder::isSameURL($id, $_SESSION['openid']['claimedId']) && !URLBuilder::isSameURL($id, $_SESSION['openid']['opLocalId'])) {
290 292
    if ($_SESSION['openid']['claimedId'] == 'http://specs.openid.net/auth/2.0/identifier_select') {
291 293
     $disc = new Discoverer($_REQUEST['openid_claimed_id'], false);
292 294
 
@@ -299,7 +301,7 @@
299 301
    } else {
300 302
      error('diffid', 'Identity provider validated wrong identity. Expected it to '
301 303
 	             . 'validate ' . $_SESSION['openid']['claimedId'] . ' but it '
302
-  	             . 'validated ' . $_REQUEST['openid_identity']);
304
+  	             . 'validated ' . $id);
303 305
    }
304 306
   }
305 307
 

+ 6
- 2
urlbuilder.inc.php View File

@@ -165,8 +165,12 @@
165 165
    //       also be present with the same values in the URL of the HTTP request the
166 166
    //       RP received.
167 167
 
168
-   $actual = parse_url(self::getCurrentURL(true));
169
-   $return = parse_url($url);
168
+   return self::isSameURL(self::getCurrentURL(true), $url);
169
+  }
170
+
171
+  public static function isSameURL($url1, $url2) {
172
+   $actual = parse_url($url1);
173
+   $return = parse_url($url2);
170 174
 
171 175
    foreach (array('scheme', 'host', 'port', 'user', 'pass', 'path') as $part) {
172 176
     if ($part == 'port') {

Loading…
Cancel
Save