ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SimpleSAML\Utils\HTTP Class Reference
+ Collaboration diagram for SimpleSAML\Utils\HTTP:

Static Public Member Functions

static getServerHTTPS ()
 Retrieve HTTPS status from $_SERVER environment variables. More...
 
static getServerPort ()
 Retrieve the port number from $_SERVER environment variables. More...
 
static checkSessionCookie ($retryURL=null)
 Check for session cookie, and show missing-cookie page if it is missing. More...
 
static checkURLAllowed ($url, array $trustedSites=null)
 Check if a URL is valid and is in our list of allowed URLs. More...
 
static fetch ($url, $context=array(), $getHeaders=false)
 Helper function to retrieve a file or URL with proxy support, also supporting proxy basic authorization. More...
 
static getAcceptLanguage ()
 This function parses the Accept-Language HTTP header and returns an associative array with each language and the score for that language. More...
 
static guessBasePath ()
 Try to guess the base SimpleSAMLphp path from the current request. More...
 
static getBaseURL ()
 Retrieve the base URL of the SimpleSAMLphp installation. More...
 
static getFirstPathElement ($trailingslash=true)
 Retrieve the first element of the URL path. More...
 
static getPOSTRedirectURL ($destination, $data)
 Create a link which will POST data. More...
 
static getSelfHost ()
 Retrieve our own host. More...
 
static getSelfHostWithPath ()
 Retrieve our own host together with the URL path. More...
 
static getSelfURLNoQuery ()
 Retrieve the current URL using the base URL in the configuration, without the query parameters. More...
 
static isHTTPS ()
 This function checks if we are using HTTPS as protocol. More...
 
static normalizeURL ($url)
 Normalizes a URL to an absolute URL and validate it. More...
 
static parseQueryString ($query_string)
 Parse a query string into an array. More...
 
static redirectTrustedURL ($url, $parameters=array())
 This function redirects to the specified URL without performing any security checks. More...
 
static redirectUntrustedURL ($url, $parameters=array())
 This function redirects to the specified URL after performing the appropriate security checks on it. More...
 
static resolveURL ($url, $base=null)
 Resolve a (possibly relative) URL relative to a given base URL. More...
 
static setCookie ($name, $value, $params=null, $throw=true)
 Set a cookie. More...
 
static submitPOSTData ($destination, $data)
 Submit a POST form to a specific destination. More...
 

Static Private Member Functions

static getSecurePOSTRedirectURL ($destination, $data)
 Obtain a URL where we can redirect to securely post a form with the given data to a specific destination. More...
 
static getServerHost ()
 Retrieve Host value from $_SERVER environment variables. More...
 
static redirect ($url, $parameters=array())
 This function redirects the user to the specified address. More...
 
static savePOSTData (\SimpleSAML_Session $session, $destination, $data)
 Save the given HTTP POST data and the destination where it should be posted to a given session. More...
 

Detailed Description

Definition at line 12 of file HTTP.php.

Member Function Documentation

◆ checkSessionCookie()

static SimpleSAML\Utils\HTTP::checkSessionCookie (   $retryURL = null)
static

Check for session cookie, and show missing-cookie page if it is missing.

Parameters
string | null$retryURLThe URL the user should access to retry the operation. Defaults to null.
Returns
void If there is a session cookie, nothing will be returned. Otherwise, the user will be redirected to a page telling about the missing cookie.
Exceptions

Definition at line 286 of file HTTP.php.

Referenced by SimpleSAML_Utilities\checkCookie(), SimpleSAML\Utils\HttpAdapter\checkSessionCookie(), sspmod_saml_IdP_SAML1\receiveAuthnRequest(), and sspmod_saml_IdP_SAML2\receiveAuthnRequest().

287  {
288  if (!is_null($retryURL) && !is_string($retryURL)) {
289  throw new \InvalidArgumentException('Invalid input parameters.');
290  }
291 
293  if ($session->hasSessionCookie()) {
294  return;
295  }
296 
297  // we didn't have a session cookie. Redirect to the no-cookie page
298 
299  $url = Module::getModuleURL('core/no_cookie.php');
300  if ($retryURL !== null) {
301  $url = self::addURLParameters($url, array('retryURL' => $retryURL));
302  }
303  self::redirectTrustedURL($url);
304  }
$session
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
$url
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
+ Here is the caller graph for this function:

◆ checkURLAllowed()

static SimpleSAML\Utils\HTTP::checkURLAllowed (   $url,
array  $trustedSites = null 
)
static

Check if a URL is valid and is in our list of allowed URLs.

Parameters
string$urlThe URL to check.
array$trustedSitesAn optional white list of domains. If none specified, the 'trusted.url.domains' configuration directive will be used.
Returns
string The normalized URL itself if it is allowed. An empty string if the $url parameter is empty as defined by the empty() function.
Exceptions

Definition at line 321 of file HTTP.php.

Referenced by SimpleSAML_XHTML_IdPDisco\__construct(), SimpleSAML\Utils\HttpAdapter\checkURLAllowed(), and sspmod_adfs_IdP_ADFS\receiveAuthnRequest().

322  {
323  if (empty($url)) {
324  return '';
325  }
326  $url = self::normalizeURL($url);
327 
328  if (filter_var($url, FILTER_VALIDATE_URL) === false) {
329  throw new \SimpleSAML_Error_Exception('Invalid URL: '.$url);
330  }
331 
332  // get the white list of domains
333  if ($trustedSites === null) {
334  $trustedSites = \SimpleSAML_Configuration::getInstance()->getValue('trusted.url.domains', array());
335  }
336 
337  // validates the URL's host is among those allowed
338  if (is_array($trustedSites)) {
339  assert(is_array($trustedSites));
340  $components = parse_url($url);
341  $hostname = $components['host'];
342 
343  // check for userinfo
344  if ((isset($components['user']) && strpos($components['user'], '\\') !== false) ||
345  (isset($components['pass']) && strpos($components['pass'], '\\') !== false)
346  ) {
347  throw new \SimpleSAML_Error_Exception('Invalid URL: '.$url);
348  }
349 
350  // allow URLs with standard ports specified (non-standard ports must then be allowed explicitly)
351  if (isset($components['port']) &&
352  (($components['scheme'] === 'http' && $components['port'] !== 80) ||
353  ($components['scheme'] === 'https' && $components['port'] !== 443))
354  ) {
355  $hostname = $hostname.':'.$components['port'];
356  }
357 
358  $self_host = self::getSelfHostWithNonStandardPort();
359 
360  $trustedRegex = \SimpleSAML_Configuration::getInstance()->getValue('trusted.url.regex', false);
361 
362  $trusted = false;
363  if ($trustedRegex) {
364  // add self host to the white list
365  $trustedSites[] = preg_quote($self_host);
366  foreach ($trustedSites as $regex) {
367  // Add start and end delimiters.
368  $regex = "@^{$regex}$@";
369  if (preg_match($regex, $hostname)) {
370  $trusted = true;
371  break;
372  }
373  }
374  } else {
375  // add self host to the white list
376  $trustedSites[] = $self_host;
377  $trusted = in_array($hostname, $trustedSites, true);
378  }
379 
380  // throw exception due to redirection to untrusted site
381  if (!$trusted) {
382  throw new \SimpleSAML_Error_Exception('URL not allowed: '.$url);
383  }
384  }
385  return $url;
386  }
$url
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ Here is the caller graph for this function:

◆ fetch()

static SimpleSAML\Utils\HTTP::fetch (   $url,
  $context = array(),
  $getHeaders = false 
)
static

Helper function to retrieve a file or URL with proxy support, also supporting proxy basic authorization.

An exception will be thrown if we are unable to retrieve the data.

Parameters
string$urlThe path or URL we should fetch.
array$contextExtra context options. This parameter is optional.
boolean$getHeadersWhether to also return response headers. Optional.
Returns
string|array An array if $getHeaders is set, containing the data and the headers respectively; string otherwise.
Exceptions

Definition at line 408 of file HTTP.php.

Referenced by sspmod_cas_Auth_Source_CAS\casServiceValidate(), sspmod_cas_Auth_Source_CAS\casValidate(), SimpleSAML\Bindings\Shib13\Artifact\extractResponse(), SimpleSAML\Utils\HttpAdapter\fetch(), sspmod_authwindowslive_Auth_Source_LiveID\finalStep(), sspmod_oauth_Consumer\getAccessToken(), sspmod_oauth_Consumer\getHTTP(), sspmod_oauth_Consumer\getUserInfo(), sspmod_metarefresh_MetaLoader\loadSource(), SimpleSAML_Metadata_SAMLParser\parseDescriptorsFile(), SimpleSAML_Metadata_SAMLParser\parseFile(), sspmod_oauth_Consumer\postRequest(), and Auth_Yubico\verify().

409  {
410  if (!is_string($url)) {
411  throw new \InvalidArgumentException('Invalid input parameters.');
412  }
413 
415 
416  $proxy = $config->getString('proxy', null);
417  if ($proxy !== null) {
418  if (!isset($context['http']['proxy'])) {
419  $context['http']['proxy'] = $proxy;
420  }
421  $proxy_auth = $config->getString('proxy.auth', false);
422  if ($proxy_auth !== false) {
423  $context['http']['header'] = "Proxy-Authorization: Basic ".base64_encode($proxy_auth);
424  }
425  if (!isset($context['http']['request_fulluri'])) {
426  $context['http']['request_fulluri'] = true;
427  }
428  /*
429  * If the remote endpoint over HTTPS uses the SNI extension (Server Name Indication RFC 4366), the proxy
430  * could introduce a mismatch between the names in the Host: HTTP header and the SNI_server_name in TLS
431  * negotiation (thanks to Cristiano Valli @ GARR-IDEM to have pointed this problem).
432  * See: https://bugs.php.net/bug.php?id=63519
433  * These controls will force the same value for both fields.
434  * Marco Ferrante (marco@csita.unige.it), Nov 2012
435  */
436  if (preg_match('#^https#i', $url)
437  && defined('OPENSSL_TLSEXT_SERVER_NAME')
438  && OPENSSL_TLSEXT_SERVER_NAME
439  ) {
440  // extract the hostname
441  $hostname = parse_url($url, PHP_URL_HOST);
442  if (!empty($hostname)) {
443  $context['ssl'] = array(
444  'SNI_server_name' => $hostname,
445  'SNI_enabled' => true,
446  );
447  } else {
448  Logger::warning('Invalid URL format or local URL used through a proxy');
449  }
450  }
451  }
452 
453  $context = stream_context_create($context);
454  $data = @file_get_contents($url, false, $context);
455  if ($data === false) {
456  $error = error_get_last();
457  throw new \SimpleSAML_Error_Exception('Error fetching '.var_export($url, true).':'.
458  (is_array($error) ? $error['message'] : 'no error available'));
459  }
460 
461  // data and headers
462  if ($getHeaders) {
463  if (isset($http_response_header)) {
464  $headers = array();
465  foreach ($http_response_header as $h) {
466  if (preg_match('@^HTTP/1\.[01]\s+\d{3}\s+@', $h)) {
467  $headers = array(); // reset
468  $headers[0] = $h;
469  continue;
470  }
471  $bits = explode(':', $h, 2);
472  if (count($bits) === 2) {
473  $headers[strtolower($bits[0])] = trim($bits[1]);
474  }
475  }
476  } else {
477  // no HTTP headers, probably a different protocol, e.g. file
478  $headers = null;
479  }
480  return array($data, $headers);
481  }
482 
483  return $data;
484  }
$context
Definition: webdav.php:25
$config
Definition: bootstrap.php:15
$h
static warning($string)
Definition: Logger.php:177
$url
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ getAcceptLanguage()

static SimpleSAML\Utils\HTTP::getAcceptLanguage ( )
static

This function parses the Accept-Language HTTP header and returns an associative array with each language and the score for that language.

If a language includes a region, then the result will include both the language with the region and the language without the region.

The returned array will be in the same order as the input.

Returns
array An associative array with each language and the score for that language.
Author
Olav Morken, UNINETT AS olav..nosp@m.mork.nosp@m.en@un.nosp@m.inet.nosp@m.t.no

Definition at line 498 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\getAcceptLanguage(), and SimpleSAML\Locale\Language\getHTTPLanguage().

499  {
500  if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
501  // no Accept-Language header, return an empty set
502  return array();
503  }
504 
505  $languages = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
506 
507  $ret = array();
508 
509  foreach ($languages as $l) {
510  $opts = explode(';', $l);
511 
512  $l = trim(array_shift($opts)); // the language is the first element
513 
514  $q = 1.0;
515 
516  // iterate over all options, and check for the quality option
517  foreach ($opts as $o) {
518  $o = explode('=', $o);
519  if (count($o) < 2) {
520  // skip option with no value
521  continue;
522  }
523 
524  $name = trim($o[0]);
525  $value = trim($o[1]);
526 
527  if ($name === 'q') {
528  $q = (float) $value;
529  }
530  }
531 
532  // remove the old key to ensure that the element is added to the end
533  unset($ret[$l]);
534 
535  // set the quality in the result
536  $ret[$l] = $q;
537 
538  if (strpos($l, '-')) {
539  // the language includes a region part
540 
541  // extract the language without the region
542  $l = explode('-', $l);
543  $l = $l[0];
544 
545  // add this language to the result (unless it is defined already)
546  if (!array_key_exists($l, $ret)) {
547  $ret[$l] = $q;
548  }
549  }
550  }
551  return $ret;
552  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $l
Definition: afr.php:30
$ret
Definition: parser.php:6
$languages
Definition: cssgen2.php:34
+ Here is the caller graph for this function:

◆ getBaseURL()

static SimpleSAML\Utils\HTTP::getBaseURL ( )
static

Retrieve the base URL of the SimpleSAMLphp installation.

The URL will always end with a '/'. For example: https://idp.example.org/simplesaml/

Returns
string The absolute base URL for the SimpleSAMLphp installation.
Exceptions

Definition at line 597 of file HTTP.php.

Referenced by SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile\generateDynamicHostedEntityID(), SimpleSAML_Metadata_MetaDataStorageHandlerPdo\generateDynamicHostedEntityID(), SimpleSAML\Utils\HttpAdapter\getBaseURL(), and SimpleSAML_Error_Error\show().

598  {
600  $baseURL = $globalConfig->getString('baseurlpath', 'simplesaml/');
601 
602  if (preg_match('#^https?://.*/?$#D', $baseURL, $matches)) {
603  // full URL in baseurlpath, override local server values
604  return rtrim($baseURL, '/').'/';
605  } elseif ((preg_match('#^/?([^/]?.*/)$#D', $baseURL, $matches)) ||
606  (preg_match('#^\*(.*)/$#D', $baseURL, $matches)) ||
607  ($baseURL === '')
608  ) {
609  // get server values
610  $protocol = 'http';
611  $protocol .= (self::getServerHTTPS()) ? 's' : '';
612  $protocol .= '://';
613 
614  $hostname = self::getServerHost();
615  $port = self::getServerPort();
616  $path = $globalConfig->getBasePath();
617 
618  return $protocol.$hostname.$port.$path;
619  } else {
620  /*
621  * Invalid 'baseurlpath'. We cannot recover from this, so throw a critical exception and try to be graceful
622  * with the configuration. Use a guessed base path instead of the one provided.
623  */
624  $c = $globalConfig->toArray();
625  $c['baseurlpath'] = self::guessBasePath();
626  throw new \SimpleSAML\Error\CriticalConfigurationError(
627  'Invalid value for \'baseurlpath\' in config.php. Valid format is in the form: '.
628  '[(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/]. It must end with a \'/\'.',
629  null,
630  $c
631  );
632  }
633  }
$path
Definition: aliased.php:25
$globalConfig
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ Here is the caller graph for this function:

◆ getFirstPathElement()

static SimpleSAML\Utils\HTTP::getFirstPathElement (   $trailingslash = true)
static

Retrieve the first element of the URL path.

Parameters
boolean$trailingslashWhether to add a trailing slash to the element or not. Defaults to true.
Returns
string The first element of the URL path, with an optional, trailing slash.
Author
Andreas Solberg, UNINETT AS andre.nosp@m.as.s.nosp@m.olber.nosp@m.g@un.nosp@m.inett.nosp@m..no

Definition at line 645 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\getFirstPathElement().

646  {
647  if (preg_match('|^/(.*?)/|', $_SERVER['SCRIPT_NAME'], $matches)) {
648  return ($trailingslash ? '/' : '').$matches[1];
649  }
650  return '';
651  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the caller graph for this function:

◆ getPOSTRedirectURL()

static SimpleSAML\Utils\HTTP::getPOSTRedirectURL (   $destination,
  $data 
)
static

Create a link which will POST data.

Parameters
string$destinationThe destination URL.
array$dataThe name-value pairs which will be posted to the destination.
Returns
string A URL which can be accessed to post the data.
Exceptions

Definition at line 666 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\getPOSTRedirectURL(), and SimpleSAML\Auth\Simple\login().

667  {
668  if (!is_string($destination) || !is_array($data)) {
669  throw new \InvalidArgumentException('Invalid input parameters.');
670  }
671 
673  $allowed = $config->getBoolean('enable.http_post', false);
674 
675  if ($allowed && preg_match("#^http:#", $destination) && self::isHTTPS()) {
676  // we need to post the data to HTTP
677  $url = self::getSecurePOSTRedirectURL($destination, $data);
678  } else { // post the data directly
680  $id = self::savePOSTData($session, $destination, $data);
681  $url = Module::getModuleURL('core/postredirect.php', array('RedirId' => $id));
682  }
683 
684  return $url;
685  }
$config
Definition: bootstrap.php:15
$session
$destination
if(!array_key_exists('StateId', $_REQUEST)) $id
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
$url
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ getSecurePOSTRedirectURL()

static SimpleSAML\Utils\HTTP::getSecurePOSTRedirectURL (   $destination,
  $data 
)
staticprivate

Obtain a URL where we can redirect to securely post a form with the given data to a specific destination.

Parameters
string$destinationThe destination URL.
array$dataAn associative array containing the data to be posted to $destination.
Exceptions

Definition at line 26 of file HTTP.php.

References $data, $destination, $id, $info, $session, $url, SimpleSAML\Utils\Crypto\aesEncrypt(), SimpleSAML\Module\getModuleURL(), and SimpleSAML_Session\getSessionFromRequest().

27  {
29  $id = self::savePOSTData($session, $destination, $data);
30 
31  // get the session ID
32  $session_id = $session->getSessionId();
33  if (is_null($session_id)) {
34  // this is a transient session, it is pointless to continue
35  throw new \SimpleSAML_Error_Exception('Cannot save POST data to a transient session.');
36  }
37 
38  // encrypt the session ID and the random ID
39  $info = base64_encode(Crypto::aesEncrypt($session_id.':'.$id));
40 
41  $url = Module::getModuleURL('core/postredirect.php', array('RedirInfo' => $info));
42  return preg_replace('#^https:#', 'http:', $url);
43  }
static aesEncrypt($data)
Encrypt data using AES-256-CBC and the system-wide secret salt as key.
Definition: Crypto.php:146
$session
$destination
if(!array_key_exists('StateId', $_REQUEST)) $id
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
$url
$info
Definition: index.php:5
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ getSelfHost()

static SimpleSAML\Utils\HTTP::getSelfHost ( )
static

Retrieve our own host.

E.g. www.example.com

Returns
string The current host.
Author
Jaime Perez, UNINETT AS jaime.nosp@m..per.nosp@m.ez@un.nosp@m.inet.nosp@m.t.no

Definition at line 697 of file HTTP.php.

Referenced by SimpleSAML_Metadata_MetaDataStorageHandler\getMetaDataCurrentEntityID(), SimpleSAML\Auth\Simple\getProcessedURL(), SimpleSAML\Utils\HttpAdapter\getSelfHost(), and SimpleSAML_Metadata_MetaDataStorageSource\lookupIndexFromEntityId().

698  {
699  $decomposed = explode(':', self::getSelfHostWithNonStandardPort());
700  return array_shift($decomposed);
701  }
+ Here is the caller graph for this function:

◆ getSelfHostWithPath()

static SimpleSAML\Utils\HTTP::getSelfHostWithPath ( )
static

Retrieve our own host together with the URL path.

Please note this function will return the base URL for the current SP, as defined in the global configuration.

Returns
string The current host (with non-default ports included) plus the URL path.
Author
Andreas Solberg, UNINETT AS andre.nosp@m.as.s.nosp@m.olber.nosp@m.g@un.nosp@m.inett.nosp@m..no
Olav Morken, UNINETT AS olav..nosp@m.mork.nosp@m.en@un.nosp@m.inet.nosp@m.t.no

Definition at line 736 of file HTTP.php.

Referenced by SimpleSAML_Metadata_MetaDataStorageHandler\getMetaDataCurrentEntityID(), and SimpleSAML\Utils\HttpAdapter\getSelfHostWithPath().

737  {
738  $baseurl = explode("/", self::getBaseURL());
739  $elements = array_slice($baseurl, 3 - count($baseurl), count($baseurl) - 4);
740  $path = implode("/", $elements);
741  return self::getSelfHostWithNonStandardPort()."/".$path;
742  }
$path
Definition: aliased.php:25
getBaseURL($t, $type='get', $key=null, $value=null)
Definition: showstats.php:145
+ Here is the caller graph for this function:

◆ getSelfURLNoQuery()

static SimpleSAML\Utils\HTTP::getSelfURLNoQuery ( )
static

Retrieve the current URL using the base URL in the configuration, without the query parameters.

Returns
string The current URL, not including query parameters.
Author
Andreas Solberg, UNINETT AS andre.nosp@m.as.s.nosp@m.olber.nosp@m.g@un.nosp@m.inett.nosp@m..no
Jaime Perez, UNINETT AS jaime.nosp@m..per.nosp@m.ez@un.nosp@m.inet.nosp@m.t.no

Definition at line 843 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\getSelfURLNoQuery(), sspmod_saml_Message\processAssertion(), sspmod_saml_Message\processResponse(), and SimpleSAML_Error_Error\saveError().

844  {
845  $url = self::getSelfURL();
846  $pos = strpos($url, '?');
847  if (!$pos) {
848  return $url;
849  }
850  return substr($url, 0, $pos);
851  }
$url
+ Here is the caller graph for this function:

◆ getServerHost()

static SimpleSAML\Utils\HTTP::getServerHost ( )
staticprivate

Retrieve Host value from $_SERVER environment variables.

Returns
string The current host name, including the port if needed. It will use localhost when unable to determine the current host.
Author
Olav Morken, UNINETT AS olav..nosp@m.mork.nosp@m.en@un.nosp@m.inet.nosp@m.t.no

Definition at line 54 of file HTTP.php.

References $_SERVER, and $current.

55  {
56  if (array_key_exists('HTTP_HOST', $_SERVER)) {
57  $current = $_SERVER['HTTP_HOST'];
58  } elseif (array_key_exists('SERVER_NAME', $_SERVER)) {
59  $current = $_SERVER['SERVER_NAME'];
60  } else {
61  // almost certainly not what you want, but...
62  $current = 'localhost';
63  }
64 
65  if (strstr($current, ":")) {
66  $decomposed = explode(":", $current);
67  $port = array_pop($decomposed);
68  if (!is_numeric($port)) {
69  array_push($decomposed, $port);
70  }
71  $current = implode(":", $decomposed);
72  }
73  return $current;
74  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

◆ getServerHTTPS()

static SimpleSAML\Utils\HTTP::getServerHTTPS ( )
static

Retrieve HTTPS status from $_SERVER environment variables.

Returns
boolean True if the request was performed through HTTPS, false otherwise.
Author
Olav Morken, UNINETT AS olav..nosp@m.mork.nosp@m.en@un.nosp@m.inet.nosp@m.t.no

Definition at line 84 of file HTTP.php.

References $_SERVER.

Referenced by SimpleSAML\Auth\Simple\getProcessedURL(), and SimpleSAML\Utils\HttpAdapter\getServerHTTPS().

85  {
86  if (!array_key_exists('HTTPS', $_SERVER)) {
87  // not an https-request
88  return false;
89  }
90 
91  if ($_SERVER['HTTPS'] === 'off') {
92  // IIS with HTTPS off
93  return false;
94  }
95 
96  // otherwise, HTTPS will be non-empty
97  return !empty($_SERVER['HTTPS']);
98  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the caller graph for this function:

◆ getServerPort()

static SimpleSAML\Utils\HTTP::getServerPort ( )
static

Retrieve the port number from $_SERVER environment variables.

Returns
string The port number prepended by a colon, if it is different than the default port for the protocol (80 for HTTP, 443 for HTTPS), or an empty string otherwise.
Author
Olav Morken, UNINETT AS olav..nosp@m.mork.nosp@m.en@un.nosp@m.inet.nosp@m.t.no

Definition at line 109 of file HTTP.php.

References $_SERVER.

Referenced by SimpleSAML\Auth\Simple\getProcessedURL(), and SimpleSAML\Utils\HttpAdapter\getServerPort().

110  {
111  $default_port = self::getServerHTTPS() ? '443' : '80';
112  $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : $default_port;
113 
114  // Take care of edge-case where SERVER_PORT is an integer
115  $port = strval($port);
116 
117  if ($port !== $default_port) {
118  return ':'.$port;
119  }
120  return '';
121  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the caller graph for this function:

◆ guessBasePath()

static SimpleSAML\Utils\HTTP::guessBasePath ( )
static

Try to guess the base SimpleSAMLphp path from the current request.

This method offers just a guess, so don't rely on it.

Returns
string The guessed base path that should correspond to the root installation of SimpleSAMLphp.

Definition at line 562 of file HTTP.php.

Referenced by SimpleSAML\Error\CriticalConfigurationError\__construct(), SimpleSAML_Configuration\getBasePath(), and SimpleSAML\Utils\HttpAdapter\guessBasePath().

563  {
564  if (!array_key_exists('REQUEST_URI', $_SERVER) || !array_key_exists('SCRIPT_FILENAME', $_SERVER)) {
565  return '/';
566  }
567  // get the name of the current script
568  $path = explode('/', $_SERVER['SCRIPT_FILENAME']);
569  $script = array_pop($path);
570 
571  // get the portion of the URI up to the script, i.e.: /simplesaml/some/directory/script.php
572  if (!preg_match('#^/(?:[^/]+/)*'.$script.'#', $_SERVER['REQUEST_URI'], $matches)) {
573  return '/';
574  }
575  $uri_s = explode('/', $matches[0]);
576  $file_s = explode('/', $_SERVER['SCRIPT_FILENAME']);
577 
578  // compare both arrays from the end, popping elements matching out of them
579  while ($uri_s[count($uri_s) - 1] === $file_s[count($file_s) - 1]) {
580  array_pop($uri_s);
581  array_pop($file_s);
582  }
583  // we are now left with the minimum part of the URI that does not match anything in the file system, use it
584  return join('/', $uri_s).'/';
585  }
$path
Definition: aliased.php:25
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the caller graph for this function:

◆ isHTTPS()

static SimpleSAML\Utils\HTTP::isHTTPS ( )
static

This function checks if we are using HTTPS as protocol.

Returns
boolean True if the HTTPS is used, false otherwise.
Author
Olav Morken, UNINETT AS olav..nosp@m.mork.nosp@m.en@un.nosp@m.inet.nosp@m.t.no
Jaime Perez, UNINETT AS jaime.nosp@m..per.nosp@m.ez@un.nosp@m.inet.nosp@m.t.no

Definition at line 862 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\isHTTPS().

863  {
864  return strpos(self::getSelfURL(), 'https://') === 0;
865  }
+ Here is the caller graph for this function:

◆ normalizeURL()

static SimpleSAML\Utils\HTTP::normalizeURL (   $url)
static

Normalizes a URL to an absolute URL and validate it.

In addition to resolving the URL, this function makes sure that it is a link to an http or https site.

Parameters
string$urlThe relative URL.
Returns
string An absolute URL for the given relative URL.
Exceptions

Definition at line 880 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\normalizeURL().

881  {
882  if (!is_string($url)) {
883  throw new \InvalidArgumentException('Invalid input parameters.');
884  }
885 
886  $url = self::resolveURL($url, self::getSelfURL());
887 
888  // verify that the URL is to a http or https site
889  if (!preg_match('@^https?://@i', $url)) {
890  throw new \InvalidArgumentException('Invalid URL: '.$url);
891  }
892 
893  return $url;
894  }
$url
+ Here is the caller graph for this function:

◆ parseQueryString()

static SimpleSAML\Utils\HTTP::parseQueryString (   $query_string)
static

Parse a query string into an array.

This function parses a query string into an array, similar to the way the builtin 'parse_str' works, except it doesn't handle arrays, and it doesn't do "magic quotes".

Query parameters without values will be set to an empty string.

Parameters
string$query_stringThe query string which should be parsed.
Returns
array The query string as an associative array.
Exceptions

Definition at line 912 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\parseQueryString().

913  {
914  if (!is_string($query_string)) {
915  throw new \InvalidArgumentException('Invalid input parameters.');
916  }
917 
918  $res = array();
919  if (empty($query_string)) {
920  return $res;
921  }
922 
923  foreach (explode('&', $query_string) as $param) {
924  $param = explode('=', $param);
925  $name = urldecode($param[0]);
926  if (count($param) === 1) {
927  $value = '';
928  } else {
929  $value = urldecode($param[1]);
930  }
931  $res[$name] = $value;
932  }
933  return $res;
934  }
foreach($_POST as $key=> $value) $res
+ Here is the caller graph for this function:

◆ redirect()

static SimpleSAML\Utils\HTTP::redirect (   $url,
  $parameters = array() 
)
staticprivate

This function redirects the user to the specified address.

This function will use the "HTTP 303 See Other" redirection if the current request used the POST method and the HTTP version is 1.1. Otherwise, a "HTTP 302 Found" redirection will be used.

The function will also generate a simple web page with a clickable link to the target page.

Parameters
string$urlThe URL we should redirect to. This URL may include query parameters. If this URL is a relative URL (starting with '/'), then it will be turned into an absolute URL by prefixing it with the absolute URL to the root of the website.
string[]$parameters An array with extra query string parameters which should be appended to the URL. The name of the parameter is the array index. The value of the parameter is the value stored in the index. Both the name and the value will be urlencoded. If the value is NULL, then the parameter will be encoded as just the name, without a value.
Returns
void This function never returns.
Exceptions

Definition at line 147 of file HTTP.php.

References $_SERVER, $code, $url, n, and SimpleSAML\Logger\warning().

148  {
149  if (!is_string($url) || empty($url) || !is_array($parameters)) {
150  throw new \InvalidArgumentException('Invalid input parameters.');
151  }
152  if (!empty($parameters)) {
153  $url = self::addURLParameters($url, $parameters);
154  }
155 
156  /* Set the HTTP result code. This is either 303 See Other or
157  * 302 Found. HTTP 303 See Other is sent if the HTTP version
158  * is HTTP/1.1 and the request type was a POST request.
159  */
160  if ($_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1' &&
161  $_SERVER['REQUEST_METHOD'] === 'POST'
162  ) {
163  $code = 303;
164  } else {
165  $code = 302;
166  }
167 
168  if (strlen($url) > 2048) {
169  Logger::warning('Redirecting to a URL longer than 2048 bytes.');
170  }
171 
172  if (!headers_sent()) {
173  // set the location header
174  header('Location: '.$url, true, $code);
175 
176  // disable caching of this response
177  header('Pragma: no-cache');
178  header('Cache-Control: no-cache, no-store, must-revalidate');
179  }
180 
181  // show a minimal web page with a clickable link to the URL
182  echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
183  echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"';
184  echo ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n";
185  echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n";
186  echo " <head>\n";
187  echo ' <meta http-equiv="content-type" content="text/html; charset=utf-8">'."\n";
188  echo ' <meta http-equiv="refresh" content="0;URL=\''.htmlspecialchars($url).'\'">'."\n";
189  echo " <title>Redirect</title>\n";
190  echo " </head>\n";
191  echo " <body>\n";
192  echo " <h1>Redirect</h1>\n";
193  echo ' <p>You were redirected to: <a id="redirlink" href="'.htmlspecialchars($url).'">';
194  echo htmlspecialchars($url)."</a>\n";
195  echo ' <script type="text/javascript">document.getElementById("redirlink").focus();</script>'."\n";
196  echo " </p>\n";
197  echo " </body>\n";
198  echo '</html>';
199 
200  // end script execution
201  exit;
202  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$code
Definition: example_050.php:99
if(! $in) print Initializing normalization quick check tables n
static warning($string)
Definition: Logger.php:177
$url
+ Here is the call graph for this function:

◆ redirectTrustedURL()

static SimpleSAML\Utils\HTTP::redirectTrustedURL (   $url,
  $parameters = array() 
)
static

This function redirects to the specified URL without performing any security checks.

Please, do NOT use this function with user supplied URLs.

This function will use the "HTTP 303 See Other" redirection if the current request used the POST method and the HTTP version is 1.1. Otherwise, a "HTTP 302 Found" redirection will be used.

The function will also generate a simple web page with a clickable link to the target URL.

Parameters
string$urlThe URL we should redirect to. This URL may include query parameters. If this URL is a relative URL (starting with '/'), then it will be turned into an absolute URL by prefixing it with the absolute URL to the root of the website.
string[]$parameters An array with extra query string parameters which should be appended to the URL. The name of the parameter is the array index. The value of the parameter is the value stored in the index. Both the name and the value will be urlencoded. If the value is NULL, then the parameter will be encoded as just the name, without a value.
Returns
void This function never returns.
Exceptions

Definition at line 959 of file HTTP.php.

Referenced by sspmod_saml_Auth_Source_SP\askForIdPChange(), sspmod_authwindowslive_Auth_Source_LiveID\authenticate(), sspmod_authfacebook_Auth_Source_Facebook\authenticate(), sspmod_exampleauth_Auth_Source_External\authenticate(), sspmod_authYubiKey_Auth_Source_YubiKey\authenticate(), sspmod_multiauth_Auth_Source_MultiAuth\authenticate(), sspmod_core_Auth_UserPassOrgBase\authenticate(), sspmod_core_Auth_UserPassBase\authenticate(), sspmod_cas_Auth_Source_CAS\authenticate(), SimpleSAML_IdP\finishLogoutRedirect(), sspmod_oauth_Consumer\getAuthorizeRequest(), SimpleSAML_XHTML_IdPDisco\handleRequest(), SimpleSAML_Auth_Default\initLogout(), SimpleSAML_Auth_Source\loginCompleted(), sspmod_cas_Auth_Source_CAS\logout(), SimpleSAML_Auth_Default\logoutCompleted(), SimpleSAML\Auth\Simple\logoutCompleted(), SimpleSAML\IdP\TraditionalLogoutHandler\logoutNextSP(), sspmod_consent_Logout\postLogout(), sspmod_exampleauth_Auth_Process_RedirectTest\process(), sspmod_core_Auth_Process_WarnShortSSOInterval\process(), sspmod_preprodwarning_Auth_Process_Warning\process(), sspmod_authX509_Auth_Process_ExpiryWarning\process(), sspmod_expirycheck_Auth_Process_ExpiryDate\process(), sspmod_consent_Auth_Process_Consent\process(), SimpleSAML\Utils\HttpAdapter\redirectTrustedURL(), SimpleSAML_Utilities\redirectTrustedURL(), SimpleSAML_Auth_ProcessingChain\resumeProcessing(), sspmod_cdc_Server\send(), sspmod_adfs_IdP_ADFS\sendLogoutResponse(), SimpleSAML_XHTML_IdPDisco\start(), sspmod_saml_Auth_Source_SP\startDisco(), SimpleSAML\IdP\IFrameLogoutHandler\startLogout(), sspmod_saml_Auth_Source_SP\startSSO1(), SimpleSAML_Auth_State\throwException(), sspmod_saml_Auth_Process_ExpectedAuthnContextClassRef\unauthorized(), and sspmod_authorize_Auth_Process_Authorize\unauthorized().

960  {
961  if (!is_string($url) || !is_array($parameters)) {
962  throw new \InvalidArgumentException('Invalid input parameters.');
963  }
964 
965  $url = self::normalizeURL($url);
966  self::redirect($url, $parameters);
967  }
$url
+ Here is the caller graph for this function:

◆ redirectUntrustedURL()

static SimpleSAML\Utils\HTTP::redirectUntrustedURL (   $url,
  $parameters = array() 
)
static

This function redirects to the specified URL after performing the appropriate security checks on it.

Particularly, it will make sure that the provided URL is allowed by the 'trusted.url.domains' directive in the configuration.

If the aforementioned option is not set or the URL does correspond to a trusted site, it performs a redirection to it. If the site is not trusted, an exception will be thrown.

Parameters
string$urlThe URL we should redirect to. This URL may include query parameters. If this URL is a relative URL (starting with '/'), then it will be turned into an absolute URL by prefixing it with the absolute URL to the root of the website.
string[]$parameters An array with extra query string parameters which should be appended to the URL. The name of the parameter is the array index. The value of the parameter is the value stored in the index. Both the name and the value will be urlencoded. If the value is NULL, then the parameter will be encoded as just the name, without a value.
Returns
void This function never returns.
Exceptions

Definition at line 991 of file HTTP.php.

Referenced by sspmod_saml_Auth_Source_SP\handleUnsolicitedAuth(), SimpleSAML_Auth_State\loadState(), SimpleSAML\Utils\HttpAdapter\redirectUntrustedURL(), and SimpleSAML_Utilities\redirectUntrustedURL().

992  {
993  if (!is_string($url) || !is_array($parameters)) {
994  throw new \InvalidArgumentException('Invalid input parameters.');
995  }
996 
997  $url = self::checkURLAllowed($url);
998  self::redirect($url, $parameters);
999  }
$url
+ Here is the caller graph for this function:

◆ resolveURL()

static SimpleSAML\Utils\HTTP::resolveURL (   $url,
  $base = null 
)
static

Resolve a (possibly relative) URL relative to a given base URL.

This function supports these forms of relative URLs:

  • ^+: Absolute URL. E.g. "http://www.example.com:port/path?query#fragment".
  • ^// Same protocol. E.g. "//www.example.com:port/path?query#fragment"
  • ^/ Same protocol and host. E.g. "/path?query#fragment".
  • ^? Same protocol, host and path, replace query string & fragment. E.g. "?query#fragment".
  • ^# Same protocol, host, path and query, replace fragment. E.g. "#fragment".
  • The rest: Relative to the base path.
Parameters
string$urlThe relative URL.
string$baseThe base URL. Defaults to the base URL of this installation of SimpleSAMLphp.
Returns
string An absolute URL for the given relative URL.
Exceptions

Definition at line 1023 of file HTTP.php.

Referenced by SimpleSAML\Utils\HttpAdapter\resolveURL(), and showEntry().

1024  {
1025  if ($base === null) {
1026  $base = self::getBaseURL();
1027  }
1028 
1029  if (!is_string($url) || !is_string($base)) {
1030  throw new \InvalidArgumentException('Invalid input parameters.');
1031  }
1032 
1033  if (!preg_match('/^((((\w+:)\/\/[^\/]+)(\/[^?#]*))(?:\?[^#]*)?)(?:#.*)?/', $base, $baseParsed)) {
1034  throw new \InvalidArgumentException('Unable to parse base url: '.$base);
1035  }
1036 
1037  $baseDir = dirname($baseParsed[5].'filename');
1038  $baseScheme = $baseParsed[4];
1039  $baseHost = $baseParsed[3];
1040  $basePath = $baseParsed[2];
1041  $baseQuery = $baseParsed[1];
1042 
1043  if (preg_match('$^\w+:$', $url)) {
1044  return $url;
1045  }
1046 
1047  if (substr($url, 0, 2) === '//') {
1048  return $baseScheme.$url;
1049  }
1050 
1051  if ($url[0] === '/') {
1052  return $baseHost.$url;
1053  }
1054  if ($url[0] === '?') {
1055  return $basePath.$url;
1056  }
1057  if ($url[0] === '#') {
1058  return $baseQuery.$url;
1059  }
1060 
1061  // we have a relative path. Remove query string/fragment and save it as $tail
1062  $queryPos = strpos($url, '?');
1063  $fragmentPos = strpos($url, '#');
1064  if ($queryPos !== false || $fragmentPos !== false) {
1065  if ($queryPos === false) {
1066  $tailPos = $fragmentPos;
1067  } elseif ($fragmentPos === false) {
1068  $tailPos = $queryPos;
1069  } elseif ($queryPos < $fragmentPos) {
1070  $tailPos = $queryPos;
1071  } else {
1072  $tailPos = $fragmentPos;
1073  }
1074 
1075  $tail = substr($url, $tailPos);
1076  $dir = substr($url, 0, $tailPos);
1077  } else {
1078  $dir = $url;
1079  $tail = '';
1080  }
1081 
1082  $dir = System::resolvePath($dir, $baseDir);
1083 
1084  return $baseHost.$dir.$tail;
1085  }
$tail
Definition: tail.php:20
$base
Definition: index.php:4
getBaseURL($t, $type='get', $key=null, $value=null)
Definition: showstats.php:145
static resolvePath($path, $base=null)
Resolve a (possibly) relative path from the given base path.
Definition: System.php:118
$url
+ Here is the caller graph for this function:

◆ savePOSTData()

static SimpleSAML\Utils\HTTP::savePOSTData ( \SimpleSAML_Session  $session,
  $destination,
  $data 
)
staticprivate

Save the given HTTP POST data and the destination where it should be posted to a given session.

Parameters
\SimpleSAML_Session$sessionThe session where to temporarily store the data.
string$destinationThe destination URL where the form should be posted.
array$dataAn associative array with the data to be posted to $destination.
Returns
string A random identifier that can be used to retrieve the data from the current session.
Author
Andjelko Horvat
Jaime Perez, UNINETT AS jaime.nosp@m..per.nosp@m.ez@un.nosp@m.inet.nosp@m.t.no

Definition at line 217 of file HTTP.php.

218  {
219  // generate a random ID to avoid replay attacks
221  $postData = array(
222  'post' => $data,
223  'url' => $destination,
224  );
225 
226  // save the post data to the session, tied to the random ID
227  $session->setData('core_postdatalink', $id, $postData);
228 
229  return $id;
230  }
static generateID()
Generate a random identifier, ID_LENGTH bytes long.
Definition: Random.php:26
$session
$destination
if(!array_key_exists('StateId', $_REQUEST)) $id
if($session===NULL) $postData
$data
Definition: bench.php:6

◆ setCookie()

static SimpleSAML\Utils\HTTP::setCookie (   $name,
  $value,
  $params = null,
  $throw = true 
)
static

Set a cookie.

Parameters
string$nameThe name of the cookie.
string | NULL$valueThe value of the cookie. Set to NULL to delete the cookie.
array | NULL$paramsCookie parameters.
bool$throwWhether to throw exception if setcookie() fails.
Exceptions

Definition at line 1104 of file HTTP.php.

Referenced by sspmod_consent_Consent_Store_Cookie\_setConsentCookie(), SimpleSAML_Session\doLogin(), SimpleSAML_AuthMemCookie\doLogout(), sspmod_cdc_Server\handleDelete(), sspmod_cdc_Server\setCDC(), SimpleSAML\Utils\HttpAdapter\setCookie(), SimpleSAML_XHTML_IdPDisco\setCookie(), SimpleSAML_Utilities\setCookie(), SimpleSAML\Locale\Language\setLanguageCookie(), sspmod_discopower_PowerIdPDisco\setPreviousIdP(), sspmod_multiauth_Auth_Source_MultiAuth\setPreviousSource(), and SimpleSAML_Session\updateSessionCookies().

1105  {
1106  if (!(is_string($name) && // $name must be a string
1107  (is_string($value) || is_null($value)) && // $value can be a string or null
1108  (is_array($params) || is_null($params)) && // $params can be an array or null
1109  is_bool($throw)) // $throw must be boolean
1110  ) {
1111  throw new \InvalidArgumentException('Invalid input parameters.');
1112  }
1113 
1114  $default_params = array(
1115  'lifetime' => 0,
1116  'expire' => null,
1117  'path' => '/',
1118  'domain' => null,
1119  'secure' => false,
1120  'httponly' => true,
1121  'raw' => false,
1122  );
1123 
1124  if ($params !== null) {
1125  $params = array_merge($default_params, $params);
1126  } else {
1127  $params = $default_params;
1128  }
1129 
1130  // Do not set secure cookie if not on HTTPS
1131  if ($params['secure'] && !self::isHTTPS()) {
1132  if ($throw) {
1133  throw new \SimpleSAML\Error\CannotSetCookie(
1134  'Setting secure cookie on plain HTTP is not allowed.',
1136  );
1137  }
1138  Logger::warning('Error setting cookie: setting secure cookie on plain HTTP is not allowed.');
1139  return;
1140  }
1141 
1142  if ($value === null) {
1143  $expire = time() - 365 * 24 * 60 * 60;
1144  } elseif (isset($params['expire'])) {
1145  $expire = $params['expire'];
1146  } elseif ($params['lifetime'] === 0) {
1147  $expire = 0;
1148  } else {
1149  $expire = time() + $params['lifetime'];
1150  }
1151 
1152  if ($params['raw']) {
1153  $success = @setrawcookie(
1154  $name,
1155  $value,
1156  $expire,
1157  $params['path'],
1158  $params['domain'],
1159  $params['secure'],
1160  $params['httponly']
1161  );
1162  } else {
1163  $success = @setcookie(
1164  $name,
1165  $value,
1166  $expire,
1167  $params['path'],
1168  $params['domain'],
1169  $params['secure'],
1170  $params['httponly']
1171  );
1172  }
1173 
1174  if (!$success) {
1175  if ($throw) {
1176  throw new \SimpleSAML\Error\CannotSetCookie(
1177  'Headers already sent.',
1179  );
1180  }
1181  Logger::warning('Error setting cookie: headers already sent.');
1182  }
1183  }
$expire
Definition: saml2-acs.php:140
Attribute-related utility methods.
$success
Definition: Utf8Test.php:86
static warning($string)
Definition: Logger.php:177
+ Here is the caller graph for this function:

◆ submitPOSTData()

static SimpleSAML\Utils\HTTP::submitPOSTData (   $destination,
  $data 
)
static

Submit a POST form to a specific destination.

This function never returns.

Parameters
string$destinationThe destination URL.
array$dataAn associative array with the data to be posted to $destination.
Exceptions

Definition at line 1202 of file HTTP.php.

Referenced by SimpleSAML_Utilities\postRedirect(), sspmod_cdc_Server\send(), SimpleSAML\Bindings\Shib13\HTTPPost\sendResponse(), and SimpleSAML\Utils\HttpAdapter\submitPOSTData().

1203  {
1204  if (!is_string($destination) || !is_array($data)) {
1205  throw new \InvalidArgumentException('Invalid input parameters.');
1206  }
1207 
1209  $allowed = $config->getBoolean('enable.http_post', false);
1210 
1211  if ($allowed && preg_match("#^http:#", $destination) && self::isHTTPS()) {
1212  // we need to post the data to HTTP
1213  self::redirect(self::getSecurePOSTRedirectURL($destination, $data));
1214  }
1215 
1216  $p = new \SimpleSAML_XHTML_Template($config, 'post.php');
1217  $p->data['destination'] = $destination;
1218  $p->data['post'] = $data;
1219  $p->show();
1220  exit(0);
1221  }
$config
Definition: bootstrap.php:15
$destination
exit
Definition: backend.php:16
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: