Skip to content

Commit

Permalink
MDL-28344 new option to prevent clickjacking via frame embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 14, 2011
1 parent b9b639b commit 5c75493
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions admin/settings/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
$temp->add(new admin_setting_configcheckbox('loginhttps', get_string('loginhttps', 'admin'), get_string('configloginhttps', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('cookiesecure', get_string('cookiesecure', 'admin'), get_string('configcookiesecure', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('cookiehttponly', get_string('cookiehttponly', 'admin'), get_string('configcookiehttponly', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('allowframembedding', get_string('allowframembedding', 'admin'), get_string('allowframembedding_help', 'admin'), 0));
$ADMIN->add('security', $temp);


Expand Down
2 changes: 2 additions & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
$string['allowdeletes'] = 'Allow deletes';
$string['allowediplist'] = 'Allowed IP list';
$string['allowemailaddresses'] = 'Allowed email domains';
$string['allowframembedding'] = 'Allow frame embedding';
$string['allowframembedding_help'] = 'Allow embedding of this site in frames on external sites. Enabling of this feature is not recommended for security reasons.';
$string['allowobjectembed'] = 'Allow EMBED and OBJECT tags';
$string['allowrenames'] = 'Allow renames';
$string['allowthemechangeonurl'] = 'Allow theme changes in the URL';
Expand Down
6 changes: 6 additions & 0 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,8 @@ function get_html_lang($dir = false) {
* @param $cacheable Can this page be cached on back?
*/
function send_headers($contenttype, $cacheable = true) {
global $CFG;

@header('Content-Type: ' . $contenttype);
@header('Content-Script-Type: text/javascript');
@header('Content-Style-Type: text/css');
Expand All @@ -1878,6 +1880,10 @@ function send_headers($contenttype, $cacheable = true) {
@header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
}
@header('Accept-Ranges: none');

if (empty($CFG->allowframembedding)) {
@header('X-Frame-Options: sameorigin');
}
}

/**
Expand Down

0 comments on commit 5c75493

Please sign in to comment.