Add admin setting to control the httpOnly attribute

This commit is contained in:
Kijin Sung 2023-07-22 20:17:23 +09:00
parent 56b37b7cbc
commit a2932ee8c8
6 changed files with 36 additions and 19 deletions

View file

@ -32,6 +32,7 @@ class Security extends Base
Context::set('remote_addr', RX_CLIENT_IP);
// Session and cookie security settings
Context::set('use_httponly', Config::get('session.httponly'));
Context::set('use_samesite', Config::get('session.samesite'));
Context::set('use_session_ssl', Config::get('session.use_ssl'));
Context::set('use_cookies_ssl', Config::get('session.use_ssl_cookies'));
@ -126,6 +127,7 @@ class Security extends Base
Config::set('admin.allow', array_values($allowed_ip));
Config::set('admin.deny', array_values($denied_ip));
Config::set('session.httponly', $vars->use_httponly === 'Y');
Config::set('session.samesite', $vars->use_samesite);
Config::set('session.use_ssl', $vars->use_session_ssl === 'Y');
Config::set('session.use_ssl_cookies', $vars->use_cookies_ssl === 'Y');

View file

@ -165,9 +165,11 @@ $lang->mediafilter_classes = 'Allow HTML class';
$lang->about_mediafilter_classes = 'This list defines the list of class attributes that users are allowed to use in HTML content.<br />Allowing classes that conflict with your site\'s design or functionality may cause breakage or confusing results.<br />This restriction does not apply to the administrator.';
$lang->robot_user_agents = 'Robot user-agent';
$lang->about_robot_user_agents = 'This list defines the list of browser user-agent strings that will be treated as robots, in addition to the usual search engines.<br />This may help prevent excessive server load and traffic due to malicious bots.';
$lang->use_httponly = 'HttpOnly attribute';
$lang->about_use_httponly = 'Reduce the risk of XSS attacks by blocking JavaScript access to session cookies.';
$lang->use_samesite = 'SameSite attribute';
$lang->use_samesite_empty = 'Do not use';
$lang->about_use_samesite = 'Set the SameSite attribute for session cookies and session keys.<br>Lax is the recommended setting for most sites. You may need to use None if you are having difficulties integrating with external services such as payment gateways.<br>However, None is only valid when used with SSL-only sessions.';
$lang->about_use_samesite = 'Set the SameSite attribute for session cookies.<br>Lax is the recommended setting for most sites. You may need to use None if you are having difficulties integrating with external services such as payment gateways.<br>However, None is only valid when used with SSL-only sessions.';
$lang->about_x_frame_options = 'Block loading this site in an iframe from another site. This helps prevent clickjacking attacks.<br />SameOrigin is recommended for most sites. Deny will make iframes stop working even on this site.<br />Do not use this setting if you have already enabled the X-Frame-Options header in your server configuration.';
$lang->about_x_content_type_options = 'Prevent browser sniffing of MIME types of documents and attached files.<br />Do not use this setting if you have already enabled the X-Content-Type-Options header in your server configuration.';
$lang->use_session_ssl = 'Use SSL-only session';

View file

@ -166,9 +166,11 @@ $lang->mediafilter_classes = 'HTML class 허용';
$lang->about_mediafilter_classes = '게시물, 댓글 등에서 허용되는 HTML class 속성의 목록을 지정할 수 있습니다.<br />사이트 디자인이나 기능과 중복되는 class를 허용할 경우 악의적으로 디자인을 망가뜨리거나 다른 사용자의 혼란을 유발할 수 있습니다.<br />관리자가 작성한 글은 제한을 받지 않습니다.';
$lang->robot_user_agents = '로봇 user-agent';
$lang->about_robot_user_agents = '일반적인 검색엔진 크롤러 외에 로봇으로 취급해야 할 user-agent가 있다면 한 줄에 하나씩 입력해 주십시오.<br />악성 크롤러로 인한 서버 부하 및 과도한 트래픽을 방지하는 데 도움이 될 수 있습니다.';
$lang->use_httponly = 'HttpOnly 속성';
$lang->about_use_httponly = '자바스크립트에서 세션 쿠키에 접근하지 못하도록 하여, XSS를 통한 세션 탈취의 가능성을 줄입니다.';
$lang->use_samesite = 'SameSite 속성';
$lang->use_samesite_empty = '표기하지 않음';
$lang->about_use_samesite = '세션 쿠키, 보안키 등에 적용되는 SameSite 속성을 선택할 수 있습니다.<br>대부분의 사이트에는 Lax를 권장하며, 최신 브라우저에서 결제 연동 등에 문제가 있는 경우 None을 선택하시기 바랍니다.<br>단, None을 선택할 경우 SSL 전용 세션을 사용하여야 정상 작동합니다.';
$lang->about_use_samesite = '세션 쿠키에 적용되는 SameSite 속성을 선택할 수 있습니다.<br>대부분의 사이트에는 Lax를 권장하며, 최신 브라우저에서 결제 연동 등에 문제가 있는 경우 None을 선택하시기 바랍니다.<br>단, None을 선택할 경우 SSL 전용 세션을 사용하여야 정상 작동합니다.';
$lang->about_x_frame_options = '다른 사이트에서 이 사이트를 iframe으로 로딩하는 것을 차단합니다. Clickjacking 공격 방지에 도움이 됩니다.<br />대부분의 사이트에는 SameOrigin을 추천합니다. Deny로 설정하면 같은 사이트 내에서도 iframe이 작동하지 않습니다.<br />웹서버 설정에서 이미 X-Frame-Options 헤더를 출력하고 있는 경우에는 중복 사용하지 마십시오.';
$lang->about_x_content_type_options = '브라우저가 문서나 첨부파일의 MIME type을 스니핑하여 임의로 처리하는 것을 막습니다.<br />웹서버 설정에서 이미 X-Content-Type-Options 헤더를 출력하고 있는 경우에는 중복 사용하지 마십시오.';
$lang->use_session_ssl = 'SSL 전용 세션 사용';

View file

@ -81,6 +81,15 @@
<p class="x_help-block">{$lang->about_use_nofollow}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->use_httponly}</label>
<div class="x_controls">
<label for="use_httponly_y" class="x_inline"><input type="radio" name="use_httponly" id="use_httponly_y" value="Y" checked="checked"|cond="$use_httponly !== false" /> {$lang->cmd_yes}</label>
<label for="use_httponly_n" class="x_inline"><input type="radio" name="use_httponly" id="use_httponly_n" value="N" checked="checked"|cond="$use_httponly === false" /> {$lang->cmd_no}</label>
<br />
<p class="x_help-block">{$lang->about_use_httponly}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->use_samesite}</label>
<div class="x_controls">