ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
TrustRoot.php File Reference

Go to the source code of this file.

Data Structures

class  Auth_OpenID_TrustRoot
 A wrapper for trust-root related functions. More...
 

Namespaces

 OpenID
 This module contains code for dealing with associations between consumers and servers.
 

Functions

 filter_extractReturnURL ($endpoint)
 
Auth_OpenID_extractReturnURL (&$endpoint_list)
 
 Auth_OpenID_returnToMatches ($allowed_return_to_urls, $return_to)
 
 Auth_OpenID_getAllowedReturnURLs ($relying_party_url, $fetcher, $discover_function=null)
 
 Auth_OpenID_verifyReturnTo ($realm_str, $return_to, $fetcher, $_vrfy='Auth_OpenID_getAllowedReturnURLs')
 

Variables

const Auth_OpenID___TLDs '/\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|asia' . '|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br' . '|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co' . '|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg' . '|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl' . '|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie' . '|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh' . '|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly' . '|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt' . '|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no' . '|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt' . '|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl' . '|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm' . '|tn|to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve' . '|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g' . '|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d' . '|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp' . '|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)\.?$/'
 A regular expression that matches a domain ending in a top-level domains. More...
 
const Auth_OpenID___HostSegmentRe "/^(?:[-a-zA-Z0-9!$&'\\(\\)\\*+,;=._~]|%[a-zA-Z0-9]{2})*$/"
 

Function Documentation

◆ Auth_OpenID_extractReturnURL()

& Auth_OpenID_extractReturnURL ( $endpoint_list)

Definition at line 351 of file TrustRoot.php.

References $result, and filter_extractReturnURL().

Referenced by Auth_OpenID_getAllowedReturnURLs().

354 {
355  $result = array();
356 
357  foreach ($endpoint_list as $endpoint) {
358  if (filter_extractReturnURL($endpoint)) {
359  $result[] = $endpoint;
360  }
361  }
362 
$result
filter_extractReturnURL($endpoint)
Definition: TrustRoot.php:342
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Auth_OpenID_getAllowedReturnURLs()

Auth_OpenID_getAllowedReturnURLs (   $relying_party_url,
  $fetcher,
  $discover_function = null 
)

Definition at line 395 of file TrustRoot.php.

References Auth_OpenID_extractReturnURL(), and Auth_Yadis_getServiceEndpoints().

399 {
400  if ($discover_function === null) {
401  $discover_function = array('Auth_Yadis_Yadis', 'discover');
402  }
403 
404  $xrds_parse_cb = array('Auth_OpenID_ServiceEndpoint', 'consumerFromXRDS');
405 
406  list($rp_url_after_redirects, $endpoints) =
407  Auth_Yadis_getServiceEndpoints($relying_party_url, $xrds_parse_cb,
408  $discover_function, $fetcher);
409 
410  if ($rp_url_after_redirects != $relying_party_url) {
411  // Verification caused a redirect
412  return false;
413  }
414 
415  call_user_func_array($discover_function,
416  array($relying_party_url, &$fetcher));
417 
418  $return_to_urls = array();
419  $matching_endpoints = Auth_OpenID_extractReturnURL($endpoints);
420 
421  foreach ($matching_endpoints as $e) {
422  $return_to_urls[] = $e->server_url;
423  }
424 
& Auth_OpenID_extractReturnURL(&$endpoint_list)
Definition: TrustRoot.php:351
Auth_Yadis_getServiceEndpoints($input_url, $xrds_parse_func, $discover_func=null, $fetcher=null)
Perform the Yadis protocol on the input URL and return an iterable of resulting endpoint objects...
Definition: Yadis.php:136
+ Here is the call graph for this function:

◆ Auth_OpenID_returnToMatches()

Auth_OpenID_returnToMatches (   $allowed_return_to_urls,
  $return_to 
)

Definition at line 368 of file TrustRoot.php.

References Auth_OpenID_TrustRoot\_parse(), and Auth_OpenID_TrustRoot\match().

Referenced by Auth_OpenID_verifyReturnTo().

371 {
372  foreach ($allowed_return_to_urls as $allowed_return_to) {
373  // A return_to pattern works the same as a realm, except that
374  // it's not allowed to use a wildcard. We'll model this by
375  // parsing it as a realm, and not trying to match it if it has
376  // a wildcard.
377 
378  $return_realm = Auth_OpenID_TrustRoot::_parse($allowed_return_to);
379  if (// Parses as a trust root
380  ($return_realm !== false) &&
381  // Does not have a wildcard
382  (!$return_realm['wildcard']) &&
383  // Matches the return_to that we passed in with it
384  (Auth_OpenID_TrustRoot::match($allowed_return_to, $return_to))) {
385  return true;
386  }
387  }
388 
389  // No URL in the list matched
static _parse($trust_root)
Parse a URL into its trust_root parts.
Definition: TrustRoot.php:94
static match($trust_root, $url)
Does this URL match the given trust root?
Definition: TrustRoot.php:270
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Auth_OpenID_verifyReturnTo()

Auth_OpenID_verifyReturnTo (   $realm_str,
  $return_to,
  $fetcher,
  $_vrfy = 'Auth_OpenID_getAllowedReturnURLs' 
)

Definition at line 436 of file TrustRoot.php.

References Auth_OpenID_returnToMatches(), and Auth_OpenID_TrustRoot\buildDiscoveryURL().

440 {
441  $disco_url = Auth_OpenID_TrustRoot::buildDiscoveryURL($realm_str);
442 
443  if ($disco_url === false) {
444  return false;
445  }
446 
447  $allowable_urls = call_user_func_array($_vrfy,
448  array($disco_url, $fetcher));
449 
450  // The realm_str could not be parsed.
451  if ($allowable_urls === false) {
452  return false;
453  }
454 
455  if (Auth_OpenID_returnToMatches($allowable_urls, $return_to)) {
456  return true;
457  } else {
458  return false;
Auth_OpenID_returnToMatches($allowed_return_to_urls, $return_to)
Definition: TrustRoot.php:368
static buildDiscoveryURL($realm)
Definition: TrustRoot.php:59
+ Here is the call graph for this function:

◆ filter_extractReturnURL()

filter_extractReturnURL (   $endpoint)

Definition at line 342 of file TrustRoot.php.

References Auth_OpenID_RP_RETURN_TO_URL_TYPE.

Referenced by Auth_OpenID_extractReturnURL().

345 {
346  if ($endpoint->matchTypes(array(Auth_OpenID_RP_RETURN_TO_URL_TYPE))) {
347  return $endpoint;
348  } else {
349  return null;
const Auth_OpenID_RP_RETURN_TO_URL_TYPE
Definition: Discover.php:22
+ Here is the caller graph for this function:

Variable Documentation

◆ Auth_OpenID___HostSegmentRe

const Auth_OpenID___HostSegmentRe "/^(?:[-a-zA-Z0-9!$&'\\(\\)\\*+,;=._~]|%[a-zA-Z0-9]{2})*$/"

Definition at line 42 of file TrustRoot.php.

Referenced by Auth_OpenID_TrustRoot\buildDiscoveryURL().

◆ Auth_OpenID___TLDs

const Auth_OpenID___TLDs '/\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|asia' . '|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br' . '|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co' . '|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg' . '|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl' . '|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie' . '|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh' . '|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly' . '|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt' . '|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no' . '|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt' . '|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl' . '|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm' . '|tn|to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve' . '|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g' . '|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d' . '|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp' . '|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)\.?$/'

A regular expression that matches a domain ending in a top-level domains.

Used in checking trust roots for sanity.

private

Definition at line 23 of file TrustRoot.php.

Referenced by Auth_OpenID_TrustRoot\buildDiscoveryURL().