Changeset 17697

Show
Ignore:
Timestamp:
09/25/08 16:02:11 (2 months ago)
Author:
rambo
Message:

forward port r17696

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/config/midcom_config.php

    r17635 r17697  
    7171 * <b>Authentication Backend configuration: "simple"</b> 
    7272 * 
     73 * - <b>auth_backend_simple_cookie_secure:</b> Set the "secure" flag on cookie, defaults to true, applies only when actually using SSL/TLS 
    7374 * - <b>auth_backend_simple_cookie_id:</b> The ID appended to the cookie prefix, separating 
    7475 *   auth cookies for different sites. Defaults to the GUID of the current host. 
     
    344345$GLOBALS['midcom_config_default']['auth_backend_simple_cookie_path'] = $_MIDGARD['self']; 
    345346$GLOBALS['midcom_config_default']['auth_backend_simple_cookie_domain'] = null; 
     347$GLOBALS['midcom_config_default']['auth_backend_simple_cookie_secure'] = true; // set secure flag on cookie (applies only when using SSL) 
    346348 
    347349// Where to redirect the user after a successful login 
  • trunk/midcom/midcom.core/midcom/services/auth/backend/simple.php

    r17556 r17697  
    130130    function _set_cookie() 
    131131    { 
    132         if ($GLOBALS['midcom_config']['auth_backend_simple_cookie_domain']) 
     132        $secure_cookie = false; 
     133        if (   isset($_SERVER['HTTPS']) 
     134            && !empty($_SERVER['HTTPS']) 
     135            && $GLOBALS['midcom_config']['auth_backend_simple_cookie_secure']) 
    133136        { 
    134             setcookie 
    135             ( 
    136                 $this->_cookie_id, 
    137                 "{$this->session_id}-{$this->user->id}", 
    138                 0, 
    139                 $GLOBALS['midcom_config']['auth_backend_simple_cookie_path'], 
    140                 $GLOBALS['midcom_config']['auth_backend_simple_cookie_domain'] 
    141             ); 
     137            $secure_cookie = true; 
    142138        } 
    143         else 
    144         { 
    145             setcookie 
    146             ( 
    147                 $this->_cookie_id, 
    148                 "{$this->session_id}-{$this->user->id}", 
    149                 0, 
    150                 $GLOBALS['midcom_config']['auth_backend_simple_cookie_path'] 
    151             ); 
    152         } 
     139        setcookie 
     140        ( 
     141            $this->_cookie_id, 
     142            "{$this->session_id}-{$this->user->id}", 
     143            0, 
     144            $GLOBALS['midcom_config']['auth_backend_simple_cookie_path'], 
     145            $GLOBALS['midcom_config']['auth_backend_simple_cookie_domain'], 
     146            $secure_cookie 
     147        ); 
    153148    } 
    154149 
     
    159154    function _delete_cookie() 
    160155    { 
    161         if ($GLOBALS['midcom_config']['auth_backend_simple_cookie_domain']) 
    162         { 
    163             setcookie 
    164             ( 
    165                 $this->_cookie_id, 
    166                 false, 
    167                 0, 
    168                 $GLOBALS['midcom_config']['auth_backend_simple_cookie_path'], 
    169                 $GLOBALS['midcom_config']['auth_backend_simple_cookie_domain'] 
    170             ); 
    171         } 
    172         else 
    173         { 
    174             setcookie 
    175             ( 
    176                 $this->_cookie_id, 
    177                 false, 
    178                 0, 
    179                 $GLOBALS['midcom_config']['auth_backend_simple_cookie_path'] 
    180             ); 
    181         } 
     156        setcookie 
     157        ( 
     158            $this->_cookie_id, 
     159            false, 
     160            0, 
     161            $GLOBALS['midcom_config']['auth_backend_simple_cookie_path'], 
     162            $GLOBALS['midcom_config']['auth_backend_simple_cookie_domain'] 
     163        ); 
    182164    } 
    183165