getBaseURL() public static method

Retrieve the base URL of the SimpleSAMLphp installation. The URL will always end with a '/'. For example: https://idp.example.org/simplesaml/
Author: Olav Morken, UNINETT AS (olav.morken@uninett.no)
public static getBaseURL ( ) : string
return string The absolute base URL for the SimpleSAMLphp installation.
Example #1
0
 /**
  * Get absolute URL to a specified module resource.
  *
  * This function creates an absolute URL to a resource stored under ".../modules/<module>/www/".
  *
  * @param string $resource Resource path, on the form "<module name>/<resource>"
  * @param array  $parameters Extra parameters which should be added to the URL. Optional.
  *
  * @return string The absolute URL to the given resource.
  */
 public static function getModuleURL($resource, array $parameters = array())
 {
     assert('is_string($resource)');
     assert('$resource[0] !== "/"');
     $url = \SimpleSAML\Utils\HTTP::getBaseURL() . 'module.php/' . $resource;
     if (!empty($parameters)) {
         $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, $parameters);
     }
     return $url;
 }
Example #2
0
 /**
  * Display this error.
  *
  * This method displays a standard SimpleSAMLphp error page and exits.
  */
 public function show()
 {
     $this->setHTTPCode();
     // log the error message
     $this->logError();
     $errorData = $this->saveError();
     $config = SimpleSAML_Configuration::getInstance();
     $data['showerrors'] = $config->getBoolean('showerrors', true);
     $data['error'] = $errorData;
     $data['errorCode'] = $this->errorCode;
     $data['parameters'] = $this->parameters;
     $data['module'] = $this->module;
     $data['dictTitle'] = $this->dictTitle;
     $data['dictDescr'] = $this->dictDescr;
     $data['includeTemplate'] = $this->includeTemplate;
     $data['clipboard.js'] = true;
     // check if there is a valid technical contact email address
     if ($config->getBoolean('errorreporting', true) && $config->getString('technicalcontact_email', '*****@*****.**') !== '*****@*****.**') {
         // enable error reporting
         $baseurl = \SimpleSAML\Utils\HTTP::getBaseURL();
         $data['errorReportAddress'] = $baseurl . 'errorreport.php';
     }
     $data['email'] = '';
     $session = SimpleSAML_Session::getSessionFromRequest();
     $authorities = $session->getAuthorities();
     foreach ($authorities as $authority) {
         $attributes = $session->getAuthData($authority, 'Attributes');
         if ($attributes !== null && array_key_exists('mail', $attributes) && count($attributes['mail']) > 0) {
             $data['email'] = $attributes['mail'][0];
             break;
             // enough, don't need to get all available mails, if more than one
         }
     }
     $show_function = $config->getArray('errors.show_function', null);
     if (isset($show_function)) {
         assert('is_callable($show_function)');
         call_user_func($show_function, $config, $data);
         assert('FALSE');
     } else {
         $t = new SimpleSAML_XHTML_Template($config, 'error.php', 'errors');
         $t->data = array_merge($t->data, $data);
         $t->show();
     }
     exit;
 }
Example #3
0
 /**
  * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getBaseURL() instead.
  */
 public static function getBaseURL()
 {
     return \SimpleSAML\Utils\HTTP::getBaseURL();
 }
Example #4
0
     }
 } else {
     $metaArray['SingleLogoutService'][] = array('Binding' => $slob, 'Location' => $slol);
 }
 if (count($keys) === 1) {
     $metaArray['certData'] = $keys[0]['X509Certificate'];
 } else {
     $metaArray['keys'] = $keys;
 }
 if ($idpmeta->getBoolean('saml20.sendartifact', false)) {
     // Artifact sending enabled
     $metaArray['ArtifactResolutionService'][] = array('index' => 0, 'Location' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'saml2/idp/ArtifactResolutionService.php', 'Binding' => SAML2_Const::BINDING_SOAP);
 }
 if ($idpmeta->getBoolean('saml20.hok.assertion', false)) {
     // Prepend HoK SSO Service endpoint.
     array_unshift($metaArray['SingleSignOnService'], array('hoksso:ProtocolBinding' => SAML2_Const::BINDING_HTTP_REDIRECT, 'Binding' => SAML2_Const::BINDING_HOK_SSO, 'Location' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'saml2/idp/SSOService.php'));
 }
 $metaArray['NameIDFormat'] = $idpmeta->getString('NameIDFormat', 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient');
 if ($idpmeta->hasValue('OrganizationName')) {
     $metaArray['OrganizationName'] = $idpmeta->getLocalizedString('OrganizationName');
     $metaArray['OrganizationDisplayName'] = $idpmeta->getLocalizedString('OrganizationDisplayName', $metaArray['OrganizationName']);
     if (!$idpmeta->hasValue('OrganizationURL')) {
         throw new SimpleSAML_Error_Exception('If OrganizationName is set, OrganizationURL must also be set.');
     }
     $metaArray['OrganizationURL'] = $idpmeta->getLocalizedString('OrganizationURL');
 }
 if ($idpmeta->hasValue('scope')) {
     $metaArray['scope'] = $idpmeta->getArray('scope');
 }
 if ($idpmeta->hasValue('EntityAttributes')) {
     $metaArray['EntityAttributes'] = $idpmeta->getArray('EntityAttributes');
Example #5
0
<?php

require_once '../_include.php';
/* Load simpleSAMLphp, configuration */
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getSessionFromRequest();
/* Check if valid local session exists.. */
SimpleSAML\Utils\Auth::requireAdmin();
$attributes = array();
$attributes['HTTP_HOST'] = array($_SERVER['HTTP_HOST']);
$attributes['HTTPS'] = isset($_SERVER['HTTPS']) ? array($_SERVER['HTTPS']) : array();
$attributes['SERVER_PROTOCOL'] = array($_SERVER['SERVER_PROTOCOL']);
$attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']);
$attributes['Utilities_getBaseURL()'] = array(\SimpleSAML\Utils\HTTP::getBaseURL());
$attributes['Utilities_getSelfHost()'] = array(\SimpleSAML\Utils\HTTP::getSelfHost());
$attributes['Utilities_selfURLhost()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLHost());
$attributes['Utilities_selfURLNoQuery()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery());
$attributes['Utilities_getSelfHostWithPath()'] = array(\SimpleSAML\Utils\HTTP::getSelfHostWithPath());
$attributes['Utilities_getFirstPathElement()'] = array(\SimpleSAML\Utils\HTTP::getFirstPathElement());
$attributes['Utilities_selfURL()'] = array(\SimpleSAML\Utils\HTTP::getSelfURL());
$template = new SimpleSAML_XHTML_Template($config, 'hostnames.php');
$template->data['remaining'] = $session->getAuthData('admin', 'Expire') - time();
$template->data['attributes'] = $attributes;
$template->data['valid'] = 'na';
$template->data['logout'] = null;
$template->show();
 private function generateDynamicHostedEntityID($set)
 {
     assert('is_string($set)');
     // get the configuration
     $baseurl = \SimpleSAML\Utils\HTTP::getBaseURL();
     if ($set === 'saml20-idp-hosted') {
         return $baseurl . 'saml2/idp/metadata.php';
     } elseif ($set === 'saml20-sp-hosted') {
         return $baseurl . 'saml2/sp/metadata.php';
     } elseif ($set === 'shib13-idp-hosted') {
         return $baseurl . 'shib13/idp/metadata.php';
     } elseif ($set === 'shib13-sp-hosted') {
         return $baseurl . 'shib13/sp/metadata.php';
     } elseif ($set === 'wsfed-sp-hosted') {
         return 'urn:federation:' . \SimpleSAML\Utils\HTTP::getSelfHost();
     } elseif ($set === 'adfs-idp-hosted') {
         return 'urn:federation:' . \SimpleSAML\Utils\HTTP::getSelfHost() . ':idp';
     } else {
         throw new Exception('Can not generate dynamic EntityID for metadata of this type: [' . $set . ']');
     }
 }
Example #7
0
 public static function sendLogoutResponse(SimpleSAML_IdP $idp, array $state)
 {
     // NB:: we don't know from which SP the logout request came from
     $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
     $idpMetadata = $idp->getConfig();
     \SimpleSAML\Utils\HTTP::redirectTrustedURL($idpMetadata->getValue('redirect-after-logout', \SimpleSAML\Utils\HTTP::getBaseURL()));
 }
$session = SimpleSAML_Session::getSessionFromRequest();
// Check if valid local session exists.
if ($config->getBoolean('admin.protectindexpage', false)) {
    SimpleSAML\Utils\Auth::requireAdmin();
}
$loginurl = SimpleSAML\Utils\Auth::getAdminLoginURL();
$isadmin = SimpleSAML\Utils\Auth::isAdmin();
$links = array();
$links_welcome = array();
$links_config = array();
$links_auth = array();
$links_federation = array();
if ($config->getBoolean('idpdisco.enableremember', FALSE)) {
    $links_federation[] = array('href' => 'cleardiscochoices.php', 'text' => '{core:frontpage:link_cleardiscochoices}');
}
$links_federation[] = array('href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/metadata-converter.php', 'text' => '{core:frontpage:link_xmlconvert}');
$allLinks = array('links' => &$links, 'welcome' => &$links_welcome, 'config' => &$links_config, 'auth' => &$links_auth, 'federation' => &$links_federation);
SimpleSAML\Module::callHooks('frontpage', $allLinks);
$metadataHosted = array();
SimpleSAML\Module::callHooks('metadata_hosted', $metadataHosted);
$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$metaentries = array('hosted' => $metadataHosted, 'remote' => array());
if ($isadmin) {
    $metaentries['remote']['saml20-idp-remote'] = $metadata->getList('saml20-idp-remote');
    $metaentries['remote']['shib13-idp-remote'] = $metadata->getList('shib13-idp-remote');
}
if ($config->getBoolean('enable.saml20-idp', FALSE) === true) {
    try {
        $metaentries['hosted']['saml20-idp'] = $metadata->getMetaDataCurrent('saml20-idp-hosted');
        $metaentries['hosted']['saml20-idp']['metadata-url'] = $config->getBasePath() . 'saml2/idp/metadata.php?output=xhtml';
        if ($isadmin) {
if ($config->getValue('secretsalt') === 'defaultsecretsalt') {
    $warnings[] = '{core:frontpage:warnings_secretsalt}';
}
if (extension_loaded('suhosin')) {
    $suhosinLength = ini_get('suhosin.get.max_value_length');
    if (empty($suhosinLength) || (int) $suhosinLength < 2048) {
        $warnings[] = '{core:frontpage:warnings_suhosin_url_length}';
    }
}
$links = array();
$links_welcome = array();
$links_config = array();
$links_auth = array();
$links_federation = array();
$links_config[] = array('href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/hostnames.php', 'text' => '{core:frontpage:link_diagnostics}');
$links_config[] = array('href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/phpinfo.php', 'text' => '{core:frontpage:link_phpinfo}');
$allLinks = array('links' => &$links, 'welcome' => &$links_welcome, 'config' => &$links_config, 'auth' => &$links_auth, 'federation' => &$links_federation);
SimpleSAML_Module::callHooks('frontpage', $allLinks);
$enablematrix = array('saml20-idp' => $config->getBoolean('enable.saml20-idp', false), 'shib13-idp' => $config->getBoolean('enable.shib13-idp', false));
$functionchecks = array('hash' => array('required', 'Hashing function'), 'gzinflate' => array('required', 'ZLib'), 'openssl_sign' => array('required', 'OpenSSL'), 'simplexml_import_dom' => array('required', 'SimpleXML'), 'dom_import_simplexml' => array('required', 'XML DOM'), 'preg_match' => array('required', 'RegEx support'), 'mcrypt_module_open' => array('optional', 'MCrypt'), 'mysql_connect' => array('optional', 'MySQL support'));
if (SimpleSAML_Module::isModuleEnabled('ldap')) {
    $functionchecks['ldap_bind'] = array('required_ldap', 'LDAP Extension');
}
if (SimpleSAML_Module::isModuleEnabled('radius')) {
    $functionchecks['radius_auth_open'] = array('required_radius', 'Radius Extension');
}
$funcmatrix = array();
$funcmatrix[] = array('required' => 'required', 'descr' => 'PHP Version >= 5.3. You run: ' . phpversion(), 'enabled' => version_compare(phpversion(), '5.3', '>='));
foreach ($functionchecks as $func => $descr) {
    $funcmatrix[] = array('descr' => $descr[1], 'required' => $descr[0], 'enabled' => function_exists($func));
}