Commit 696c4361 by Chris Dodge Committed by Xavier Antoviaque

allow the prevention of the LMS/CMS from being renderable in an iframe

parent c60fa954
...@@ -264,3 +264,6 @@ PASSWORD_DICTIONARY = ENV_TOKENS.get("PASSWORD_DICTIONARY", []) ...@@ -264,3 +264,6 @@ PASSWORD_DICTIONARY = ENV_TOKENS.get("PASSWORD_DICTIONARY", [])
### INACTIVITY SETTINGS #### ### INACTIVITY SETTINGS ####
SESSION_INACTIVITY_TIMEOUT_IN_SECONDS = AUTH_TOKENS.get("SESSION_INACTIVITY_TIMEOUT_IN_SECONDS") SESSION_INACTIVITY_TIMEOUT_IN_SECONDS = AUTH_TOKENS.get("SESSION_INACTIVITY_TIMEOUT_IN_SECONDS")
##### X-Frame-Options response header settings #####
X_FRAME_OPTIONS = ENV_TOKENS.get('X_FRAME_OPTIONS', X_FRAME_OPTIONS)
...@@ -195,8 +195,15 @@ MIDDLEWARE_CLASSES = ( ...@@ -195,8 +195,15 @@ MIDDLEWARE_CLASSES = (
# for expiring inactive sessions # for expiring inactive sessions
'session_inactivity_timeout.middleware.SessionInactivityTimeout', 'session_inactivity_timeout.middleware.SessionInactivityTimeout',
# use Django built in clickjacking protection
'django.middleware.clickjacking.XFrameOptionsMiddleware',
) )
# This can be overridden if one does not want LMS/CMS to be embeddable in
# an iframe
X_FRAME_OPTIONS = 'ALLOW'
############# XBlock Configuration ########## ############# XBlock Configuration ##########
# This should be moved into an XBlock Runtime/Application object # This should be moved into an XBlock Runtime/Application object
......
...@@ -53,3 +53,22 @@ class AnonymousIndexPageTest(ModuleStoreTestCase): ...@@ -53,3 +53,22 @@ class AnonymousIndexPageTest(ModuleStoreTestCase):
def test_anon_user_no_startdate_index(self): def test_anon_user_no_startdate_index(self):
response = self.client.get('/') response = self.client.get('/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_allow_x_frame_options(self):
"""
Check the x-frame-option response header
"""
# check to see that the default setting is to ALLOW iframing
resp = self.client.get('/')
self.assertEquals(resp['X-Frame-Options'], 'ALLOW')
@override_settings(X_FRAME_OPTIONS='DENY')
def test_deny_x_frame_options(self):
"""
Check the x-frame-option response header
"""
# check to see that the override value is honored
resp = self.client.get('/')
self.assertEquals(resp['X-Frame-Options'], 'DENY')
...@@ -383,3 +383,6 @@ if ENV_TOKENS.get('XBLOCK_SELECT_FUNCTION') == 'prefer_xmodules': ...@@ -383,3 +383,6 @@ if ENV_TOKENS.get('XBLOCK_SELECT_FUNCTION') == 'prefer_xmodules':
##### LMS DEADLINE DISPLAY TIME_ZONE ####### ##### LMS DEADLINE DISPLAY TIME_ZONE #######
TIME_ZONE_DISPLAYED_FOR_DEADLINES = ENV_TOKENS.get("TIME_ZONE_DISPLAYED_FOR_DEADLINES", TIME_ZONE_DISPLAYED_FOR_DEADLINES = ENV_TOKENS.get("TIME_ZONE_DISPLAYED_FOR_DEADLINES",
TIME_ZONE_DISPLAYED_FOR_DEADLINES) TIME_ZONE_DISPLAYED_FOR_DEADLINES)
##### X-Frame-Options response header settings #####
X_FRAME_OPTIONS = ENV_TOKENS.get('X_FRAME_OPTIONS', X_FRAME_OPTIONS)
...@@ -732,8 +732,15 @@ MIDDLEWARE_CLASSES = ( ...@@ -732,8 +732,15 @@ MIDDLEWARE_CLASSES = (
# for expiring inactive sessions # for expiring inactive sessions
'session_inactivity_timeout.middleware.SessionInactivityTimeout', 'session_inactivity_timeout.middleware.SessionInactivityTimeout',
# use Django built in clickjacking protection
'django.middleware.clickjacking.XFrameOptionsMiddleware',
) )
# This can be overridden if one does not want LMS/CMS to be embeddable in
# an iframe
X_FRAME_OPTIONS = 'ALLOW'
############################### Pipeline ####################################### ############################### Pipeline #######################################
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment