diff options
author | tailor <dag@janrain.com> | 2008-06-05 18:45:28 +0000 |
---|---|---|
committer | tailor <dag@janrain.com> | 2008-06-05 18:45:28 +0000 |
commit | ffae436ba5a516ee037b09e105ce5cbdd2c55e08 (patch) | |
tree | b7674ef1c563c223f55e3ee71675e5138b5d6b17 | |
parent | 89068d2d799fd86980609f502c59a601bfad3c79 (diff) | |
download | php-openid-ffae436ba5a516ee037b09e105ce5cbdd2c55e08.zip php-openid-ffae436ba5a516ee037b09e105ce5cbdd2c55e08.tar.gz php-openid-ffae436ba5a516ee037b09e105ce5cbdd2c55e08.tar.bz2 |
[project @ handle empty string for trustroot the same as missing]
-rw-r--r-- | Auth/OpenID/Server.php | 24 | ||||
-rw-r--r-- | Tests/Auth/OpenID/Server.php | 17 |
2 files changed, 30 insertions, 11 deletions
diff --git a/Auth/OpenID/Server.php b/Auth/OpenID/Server.php index 1f53044..d85c9f7 100644 --- a/Auth/OpenID/Server.php +++ b/Auth/OpenID/Server.php @@ -858,19 +858,21 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request { // here. But if TrustRoot isn't currently part of the // "public" API, I'm not sure it's worth doing. if ($namespace == Auth_OpenID_OPENID1_NS) { - $trust_root = $message->getArg(Auth_OpenID_OPENID_NS, - 'trust_root', - $return_to); + $trust_root_param = 'trust_root'; } else { - $trust_root = $message->getArg(Auth_OpenID_OPENID_NS, - 'realm', - $return_to); + $trust_root_param = 'realm'; + } + $trust_root = $message->getArg(Auth_OpenID_OPENID_NS, + $trust_root_param); + if (! $trust_root) { + $trust_root = $return_to; + } - if (($return_to === null) && - ($trust_root === null)) { - return new Auth_OpenID_ServerError($message, - "openid.realm required when openid.return_to absent"); - } + if ($namespace != Auth_OpenID_OPENID1_NS && + ($return_to === null) && + ($trust_root === null)) { + return new Auth_OpenID_ServerError($message, + "openid.realm required when openid.return_to absent"); } $assoc_handle = $message->getArg(Auth_OpenID_OPENID_NS, diff --git a/Tests/Auth/OpenID/Server.php b/Tests/Auth/OpenID/Server.php index cddcb8e..35b05e5 100644 --- a/Tests/Auth/OpenID/Server.php +++ b/Tests/Auth/OpenID/Server.php @@ -1044,6 +1044,23 @@ class Tests_Auth_OpenID_CheckID extends PHPUnit_TestCase { $this->assertTrue(is_a($result, 'Auth_OpenID_ServerError')); } + function test_fromMessageWithEmptyTrustRoot() + { + $return_to = 'http://does.not.matter/'; + $msg = Auth_OpenID_Message::fromPostArgs(array( + 'openid.assoc_handle' => '{blah}{blah}{OZivdQ==}', + 'openid.claimed_id' => 'http://delegated.invalid/', + 'openid.identity' => 'http://op-local.example.com/', + 'openid.mode' => 'checkid_setup', + 'openid.ns' => 'http://openid.net/signon/1.0', + 'openid.return_to' => $return_to, + 'openid.trust_root' => '' + )); + $result = Auth_OpenID_CheckIDRequest::fromMessage( + $msg, $this->server); + $this->assertEquals($return_to, $result->trust_root); + } + function test_trustRootInvalid() { $this->request->trust_root = "http://foo.unittest/17"; |