Skip to content
Snippets Groups Projects
Commit db592d6c authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move SimpleSAML_Utilities::isHTTPS() to SimpleSAML\Utils\HTTP::isHTTPS() and deprecate the former.

parent f779db4a
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
public function newSessionId() {
$session_cookie_params = session_get_cookie_params();
if ($session_cookie_params['secure'] && !SimpleSAML_Utilities::isHTTPS()) {
if ($session_cookie_params['secure'] && !\SimpleSAML\Utils\HTTP::isHTTPS()) {
throw new SimpleSAML_Error_Exception('Session start with secure cookie not allowed on http.');
}
......@@ -105,7 +105,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
$session_cookie_params = session_get_cookie_params();
if ($session_cookie_params['secure'] && !SimpleSAML_Utilities::isHTTPS()) {
if ($session_cookie_params['secure'] && !\SimpleSAML\Utils\HTTP::isHTTPS()) {
throw new SimpleSAML_Error_Exception('Session start with secure cookie not allowed on http.');
}
......
......@@ -45,23 +45,10 @@ class SimpleSAML_Utilities {
/**
* This function checks if we should set a secure cookie.
*
* @return TRUE if the cookie should be secure, FALSE otherwise.
* @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::isHTTPS() instead.
*/
public static function isHTTPS() {
$url = self::getBaseURL();
$end = strpos($url,'://');
$protocol = substr($url, 0, $end);
if ($protocol === 'https') {
return TRUE;
} else {
return FALSE;
}
return \SimpleSAML\Utils\HTTP::isHTTPS();
}
......
......@@ -428,6 +428,20 @@ class HTTP
}
/**
* This function checks if we are using HTTPS as protocol.
*
* @return boolean True if the HTTPS is used, false otherwise.
*
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
* @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/
public static function isHTTPS()
{
return strpos(self::getBaseURL(), 'https://') === 0;
}
/**
* 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.
......
......@@ -272,7 +272,7 @@ class sspmod_consent_Consent_Store_Cookie extends sspmod_consent_Store
'httponly' => FALSE,
);
if (SimpleSAML_Utilities::isHTTPS()) {
if (\SimpleSAML\Utils\HTTP::isHTTPS()) {
/* Enable secure cookie for https-requests. */
$params['secure'] = true;
} else {
......
......@@ -16,7 +16,7 @@ $isadmin = SimpleSAML\Utils\Auth::isAdmin();
$warnings = array();
if (!SimpleSAML_Utilities::isHTTPS()) {
if (!\SimpleSAML\Utils\HTTP::isHTTPS()) {
$warnings[] = '{core:frontpage:warnings_https}';
}
......
......@@ -829,7 +829,7 @@ class sspmod_saml_IdP_SAML2 {
if ($hokAssertion) {
/* Holder-of-Key */
$sc->Method = SAML2_Const::CM_HOK;
if (SimpleSAML_Utilities::isHTTPS()) {
if (\SimpleSAML\Utils\HTTP::isHTTPS()) {
if (isset($_SERVER['SSL_CLIENT_CERT']) && !empty($_SERVER['SSL_CLIENT_CERT'])) {
/* Extract certificate data (if this is a certificate). */
$clientCert = $_SERVER['SSL_CLIENT_CERT'];
......
......@@ -610,7 +610,7 @@ class sspmod_saml_Message {
$scd = $sc->SubjectConfirmationData;
if ($sc->Method === SAML2_Const::CM_HOK) {
/* Check HoK Assertion */
if (SimpleSAML_Utilities::isHTTPS() === FALSE) {
if (\SimpleSAML\Utils\HTTP::isHTTPS() === FALSE) {
$lastError = 'No HTTPS connection, but required for Holder-of-Key SSO';
continue;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment