mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
Improve cookie security; Secure flag
SSL 항상 사용 옵션인 경우 쿠키도 이에 맞추어 SSL 인 경우에만 사용되도록 `secure` flag 를 추가합니다. 선택적 SSL 인 경우 SSL 이 적용되지 않은 구간에서도 쿠키를 읽을 수 있어야 하므로, 적용하지 않습니다.
This commit is contained in:
parent
5ebbbf5b36
commit
c1c9a94623
7 changed files with 26 additions and 9 deletions
|
|
@ -300,7 +300,7 @@ class Context
|
|||
{
|
||||
if($_COOKIE['lang_type'] !== $lang_type)
|
||||
{
|
||||
setcookie('lang_type', $lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000, '/');
|
||||
setcookie('lang_type', $lang_type, time() + 86400 * 365, '/', null, self::checkSslEnforce());
|
||||
}
|
||||
}
|
||||
elseif($_COOKIE['lang_type'])
|
||||
|
|
@ -316,7 +316,7 @@ class Context
|
|||
if(!strncasecmp($lang_code, $_SERVER['HTTP_ACCEPT_LANGUAGE'], strlen($lang_code)))
|
||||
{
|
||||
$lang_type = $lang_code;
|
||||
setcookie('lang_type', $lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000, '/');
|
||||
setcookie('lang_type', $lang_type, time() + 86400 * 365, '/', null, self::checkSslEnforce());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -617,6 +617,22 @@ class Context
|
|||
return self::get('_use_ssl');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return ssl status
|
||||
*
|
||||
* @return boolean (true|false)
|
||||
*/
|
||||
public static function checkSslEnforce()
|
||||
{
|
||||
static $ssl_only = null;
|
||||
if(is_null($ssl_only))
|
||||
{
|
||||
$ssl_only = (self::get('_use_ssl') === 'always' ? true : false)
|
||||
}
|
||||
return $ssl_only;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return default URL
|
||||
*
|
||||
|
|
@ -1769,7 +1785,7 @@ class Context
|
|||
return;
|
||||
}
|
||||
|
||||
if(self::get('_use_ssl') == 'always')
|
||||
if(self::checkSslEnforce())
|
||||
{
|
||||
$ssl_mode = ENFORCE_SSL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue