Add option to check CSRF token

This commit is contained in:
Kijin Sung 2018-10-10 18:17:27 +09:00
parent 3484b2bb48
commit 73e79fe547
6 changed files with 16 additions and 0 deletions

View file

@ -114,6 +114,7 @@ return array(
'classes' => array(),
),
'security' => array(
'check_csrf_token' => false,
'nofollow' => false,
),
'mobile' => array(

View file

@ -685,6 +685,7 @@ class adminAdminController extends admin
Rhymix\Framework\Config::set('session.use_keys', $vars->use_session_keys === 'Y');
Rhymix\Framework\Config::set('session.use_ssl', $vars->use_session_ssl === 'Y');
Rhymix\Framework\Config::set('session.use_ssl_cookies', $vars->use_cookies_ssl === 'Y');
Rhymix\Framework\Config::set('security.check_csrf_token', $vars->check_csrf_token === 'Y');
Rhymix\Framework\Config::set('security.nofollow', $vars->use_nofollow === 'Y');
// Save

View file

@ -444,6 +444,7 @@ class adminAdminView extends admin
Context::set('use_session_keys', Rhymix\Framework\Config::get('session.use_keys'));
Context::set('use_session_ssl', Rhymix\Framework\Config::get('session.use_ssl'));
Context::set('use_cookies_ssl', Rhymix\Framework\Config::get('session.use_ssl_cookies'));
Context::set('check_csrf_token', Rhymix\Framework\Config::get('security.check_csrf_token'));
Context::set('use_nofollow', Rhymix\Framework\Config::get('security.nofollow'));
$this->setTemplateFile('config_security');

View file

@ -170,6 +170,8 @@ $lang->use_session_ssl = 'Use SSL-only session';
$lang->about_use_session_ssl = 'Force the session to be SSL-only.<br>This helps improve security if your site always uses SSL.';
$lang->use_cookies_ssl = 'Use SSL-only cookies';
$lang->about_use_cookies_ssl = 'Force all cookies to be SSL-only.';
$lang->check_csrf_token = 'Use CSRF tokens';
$lang->about_check_csrf_token = 'Use CSRF tokens to validate requests. This is more secure but may break some functionality.<br>If not selected, Rhymix will use only the Referer header to defend against CSRF attacks.';
$lang->use_nofollow = 'Use nofollow attribute';
$lang->about_use_nofollow = 'Add rel=&quot;nofollow&quot; to all links submitted by users in order to reduce the effectiveness of spamming.<br>This does not apply to content submitted by the administrator.';
$lang->use_object_cache = 'Use Cache';

View file

@ -171,6 +171,8 @@ $lang->use_session_ssl = 'SSL 전용 세션 사용';
$lang->about_use_session_ssl = '세션을 SSL 전용으로 지정하여 SSL이 아닌 페이지에서는 사용할 수 없도록 합니다.<br>SSL을 항상 사용하도록 설정되어 있는 경우에만 활성화됩니다.';
$lang->use_cookies_ssl = 'SSL 전용 쿠키 사용';
$lang->about_use_cookies_ssl = '세션뿐 아니라 모든 쿠키를 SSL 전용으로 지정합니다.<br>SSL을 항상 사용하도록 설정되어 있는 경우에만 활성화됩니다.';
$lang->check_csrf_token = 'CSRF 토큰 사용';
$lang->about_check_csrf_token = 'CSRF 토큰을 사용하여 정상적인 요청 여부를 확인합니다. 보안이 향상되지만, 일부 서드파티 자료와 호환되지 않을 수 있습니다.<br>사용하지 않을 경우 리퍼러 헤더 확인만으로 CSRF 공격에 방어합니다.';
$lang->use_nofollow = 'Nofollow 속성 사용';
$lang->about_use_nofollow = '사용자들이 작성한 글에 포함된 모든 링크에 rel=&quot;nofollow&quot; 속성을 추가하여 스팸으로 인한 사이트 신뢰도 저하를 방지합니다.<br>관리자가 작성한 글에는 적용되지 않습니다.';
$lang->use_object_cache = '캐시 사용';

View file

@ -69,6 +69,15 @@
<p class="x_help-block">{$lang->about_use_cookies_ssl}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->check_csrf_token}</label>
<div class="x_controls">
<label for="check_csrf_token_y" class="x_inline"><input type="radio" name="check_csrf_token" id="check_csrf_token_y" value="Y" checked="checked"|cond="$check_csrf_token" /> {$lang->cmd_yes}</label>
<label for="check_csrf_token_n" class="x_inline"><input type="radio" name="check_csrf_token" id="check_csrf_token_n" value="N" checked="checked"|cond="!$check_csrf_token" /> {$lang->cmd_no}</label>
<br />
<p class="x_help-block">{$lang->about_check_csrf_token}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->use_nofollow}</label>
<div class="x_controls">