Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6eace27f
Commit
6eace27f
authored
Oct 08, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't allow the user id to change in a session loaded from storage.
parent
496022a4
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
119 additions
and
6 deletions
+119
-6
cms/envs/aws.py
+1
-1
cms/envs/common.py
+1
-0
cms/envs/yaml_config.py
+1
-1
common/djangoapps/external_auth/tests/test_shib.py
+1
-1
lms/envs/aws.py
+1
-1
lms/envs/common.py
+1
-0
lms/envs/devplus.py
+1
-1
lms/envs/yaml_config.py
+1
-1
openedx/core/djangoapps/safe_sessions/__init__.py
+0
-0
openedx/core/djangoapps/safe_sessions/backends/__init__.py
+0
-0
openedx/core/djangoapps/safe_sessions/backends/base.py
+86
-0
openedx/core/djangoapps/safe_sessions/backends/cache.py
+5
-0
openedx/core/djangoapps/safe_sessions/backends/cached_db.py
+5
-0
openedx/core/djangoapps/safe_sessions/backends/db.py
+5
-0
openedx/core/djangoapps/safe_sessions/backends/file.py
+5
-0
openedx/core/djangoapps/safe_sessions/backends/signed_cookies.py
+5
-0
No files found.
cms/envs/aws.py
View file @
6eace27f
...
@@ -42,7 +42,7 @@ DEBUG = False
...
@@ -42,7 +42,7 @@ DEBUG = False
TEMPLATE_DEBUG
=
False
TEMPLATE_DEBUG
=
False
EMAIL_BACKEND
=
'django_ses.SESBackend'
EMAIL_BACKEND
=
'django_ses.SESBackend'
SESSION_ENGINE
=
'
django.contrib.
sessions.backends.cache'
SESSION_ENGINE
=
'
openedx.core.djangoapps.safe_
sessions.backends.cache'
# IMPORTANT: With this enabled, the server must always be behind a proxy that
# IMPORTANT: With this enabled, the server must always be behind a proxy that
# strips the header HTTP_X_FORWARDED_PROTO from client requests. Otherwise,
# strips the header HTTP_X_FORWARDED_PROTO from client requests. Otherwise,
...
...
cms/envs/common.py
View file @
6eace27f
...
@@ -394,6 +394,7 @@ DEBUG = False
...
@@ -394,6 +394,7 @@ DEBUG = False
TEMPLATE_DEBUG
=
False
TEMPLATE_DEBUG
=
False
SESSION_COOKIE_SECURE
=
False
SESSION_COOKIE_SECURE
=
False
SESSION_SAVE_EVERY_REQUEST
=
False
SESSION_SAVE_EVERY_REQUEST
=
False
SESSION_ENGINE
=
'openedx.core.djangoapps.safe_sessions.backends.db'
# Site info
# Site info
SITE_ID
=
1
SITE_ID
=
1
...
...
cms/envs/yaml_config.py
View file @
6eace27f
...
@@ -62,7 +62,7 @@ DEBUG = False
...
@@ -62,7 +62,7 @@ DEBUG = False
TEMPLATE_DEBUG
=
False
TEMPLATE_DEBUG
=
False
EMAIL_BACKEND
=
'django_ses.SESBackend'
EMAIL_BACKEND
=
'django_ses.SESBackend'
SESSION_ENGINE
=
'
django.contrib.
sessions.backends.cache'
SESSION_ENGINE
=
'
openedx.core.djangoapps.safe_
sessions.backends.cache'
DEFAULT_FILE_STORAGE
=
'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE
=
'storages.backends.s3boto.S3BotoStorage'
##############################################################
##############################################################
...
...
common/djangoapps/external_auth/tests/test_shib.py
View file @
6eace27f
...
@@ -73,7 +73,7 @@ def gen_all_identities():
...
@@ -73,7 +73,7 @@ def gen_all_identities():
@ddt
@ddt
@override_settings
(
SESSION_ENGINE
=
'
django.contrib.
sessions.backends.cache'
)
@override_settings
(
SESSION_ENGINE
=
'
openedx.core.djangoapps.safe_
sessions.backends.cache'
)
class
ShibSPTest
(
SharedModuleStoreTestCase
):
class
ShibSPTest
(
SharedModuleStoreTestCase
):
"""
"""
Tests for the Shibboleth SP, which communicates via request.META
Tests for the Shibboleth SP, which communicates via request.META
...
...
lms/envs/aws.py
View file @
6eace27f
...
@@ -47,7 +47,7 @@ DEBUG = False
...
@@ -47,7 +47,7 @@ DEBUG = False
TEMPLATE_DEBUG
=
False
TEMPLATE_DEBUG
=
False
EMAIL_BACKEND
=
'django_ses.SESBackend'
EMAIL_BACKEND
=
'django_ses.SESBackend'
SESSION_ENGINE
=
'
django.contrib.
sessions.backends.cache'
SESSION_ENGINE
=
'
openedx.core.djangoapps.safe_
sessions.backends.cache'
# IMPORTANT: With this enabled, the server must always be behind a proxy that
# IMPORTANT: With this enabled, the server must always be behind a proxy that
# strips the header HTTP_X_FORWARDED_PROTO from client requests. Otherwise,
# strips the header HTTP_X_FORWARDED_PROTO from client requests. Otherwise,
...
...
lms/envs/common.py
View file @
6eace27f
...
@@ -802,6 +802,7 @@ TEMPLATE_DEBUG = False
...
@@ -802,6 +802,7 @@ TEMPLATE_DEBUG = False
USE_TZ
=
True
USE_TZ
=
True
SESSION_COOKIE_SECURE
=
False
SESSION_COOKIE_SECURE
=
False
SESSION_SAVE_EVERY_REQUEST
=
False
SESSION_SAVE_EVERY_REQUEST
=
False
SESSION_ENGINE
=
'openedx.core.djangoapps.safe_sessions.backends.db'
# CMS base
# CMS base
CMS_BASE
=
'localhost:8001'
CMS_BASE
=
'localhost:8001'
...
...
lms/envs/devplus.py
View file @
6eace27f
...
@@ -48,7 +48,7 @@ CACHES = {
...
@@ -48,7 +48,7 @@ CACHES = {
}
}
}
}
SESSION_ENGINE
=
'
django.contrib.
sessions.backends.cache'
SESSION_ENGINE
=
'
openedx.core.djangoapps.safe_
sessions.backends.cache'
################################ DEBUG TOOLBAR #################################
################################ DEBUG TOOLBAR #################################
...
...
lms/envs/yaml_config.py
View file @
6eace27f
...
@@ -61,7 +61,7 @@ DEBUG = False
...
@@ -61,7 +61,7 @@ DEBUG = False
TEMPLATE_DEBUG
=
False
TEMPLATE_DEBUG
=
False
EMAIL_BACKEND
=
'django_ses.SESBackend'
EMAIL_BACKEND
=
'django_ses.SESBackend'
SESSION_ENGINE
=
'
django.contrib.
sessions.backends.cache'
SESSION_ENGINE
=
'
openedx.core.djangoapps.safe_
sessions.backends.cache'
DEFAULT_FILE_STORAGE
=
'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE
=
'storages.backends.s3boto.S3BotoStorage'
# IMPORTANT: With this enabled, the server must always be behind a proxy that
# IMPORTANT: With this enabled, the server must always be behind a proxy that
...
...
openedx/core/djangoapps/safe_sessions/__init__.py
0 → 100644
View file @
6eace27f
openedx/core/djangoapps/safe_sessions/backends/__init__.py
0 → 100644
View file @
6eace27f
openedx/core/djangoapps/safe_sessions/backends/base.py
0 → 100644
View file @
6eace27f
from
django.contrib.auth
import
SESSION_KEY
class
SessionUserChanged
(
Exception
):
def
__init__
(
self
,
key
,
new
,
stored
):
self
.
key
=
key
self
.
new
=
new
self
.
stored
=
stored
super
(
SessionUserChanged
,
self
)
.
__init__
(
"Cannot change session {} from user {} to user {}"
.
format
(
self
.
key
,
self
.
stored
,
self
.
new
,
)
)
class
SafeSessionMixin
(
object
):
"""
Mixin to prevent a session from being changed from one userid to another.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
__stored_user
=
None
super
(
SafeSessionMixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
__setitem__
(
self
,
key
,
value
):
if
(
key
==
SESSION_KEY
and
self
.
__stored_user
is
not
None
and
value
!=
self
.
__stored_user
):
raise
SessionUserChanged
(
self
.
session_key
,
value
,
self
.
__stored_user
)
return
super
(
SafeSessionMixin
,
self
)
.
__setitem__
(
key
,
value
)
def
pop
(
self
,
key
,
*
args
):
if
key
==
SESSION_KEY
and
self
.
__stored_user
is
None
:
self
.
__stored_user
=
self
.
_session
.
get
(
SESSION_KEY
)
return
super
(
SafeSessionMixin
,
self
)
.
pop
(
key
,
*
args
)
def
setdefault
(
self
,
key
,
value
):
if
(
key
==
SESSION_KEY
and
self
.
__stored_user
is
not
None
and
value
!=
self
.
__stored_user
):
raise
SessionUserChanged
(
self
.
session_key
,
value
,
self
.
__stored_user
)
return
super
(
SafeSessionMixin
,
self
)
.
setdefault
(
key
,
value
)
def
update
(
self
,
dict_
):
if
(
SESSION_KEY
in
dict_
and
self
.
__stored_user
is
not
None
and
dict_
[
SESSION_KEY
]
!=
self
.
__stored_user
):
raise
SessionUserChanged
(
self
.
session_key
,
dict_
[
SESSION_KEY
],
self
.
__stored_user
)
return
super
(
SafeSessionMixin
,
self
)
.
save
(
must_create
=
must_create
)
def
clear
(
self
):
super
(
SafeSessionMixin
,
self
)
.
clear
()
self
.
__stored_user
=
None
def
save
(
self
,
must_create
=
False
):
"""
Saves the session data. If 'must_create' is True, a new session object
is created (otherwise a CreateError exception is raised). Otherwise,
save() can update an existing object with the same key.
"""
if
(
SESSION_KEY
in
self
.
_session
and
self
.
__stored_user
is
not
None
and
self
.
_session
[
SESSION_KEY
]
!=
self
.
__stored_user
):
raise
SessionUserChanged
(
self
.
session_key
,
self
.
_session
[
SESSION_KEY
],
self
.
__stored_user
)
return
super
(
SafeSessionMixin
,
self
)
.
save
(
must_create
=
must_create
)
def
load
(
self
):
"""
Loads the session data and returns a dictionary.
"""
session_data
=
super
(
SafeSessionMixin
,
self
)
.
load
()
self
.
__stored_user
=
session_data
.
get
(
SESSION_KEY
)
return
session_data
openedx/core/djangoapps/safe_sessions/backends/cache.py
0 → 100644
View file @
6eace27f
from
django.contrib.sessions.backends.cache
import
SessionStore
from
.base
import
SafeSessionMixin
class
SessionStore
(
SafeSessionMixin
,
SessionStore
):
pass
openedx/core/djangoapps/safe_sessions/backends/cached_db.py
0 → 100644
View file @
6eace27f
from
django.contrib.sessions.backends.cached_db
import
SessionStore
from
.base
import
SafeSessionMixin
class
SessionStore
(
SafeSessionMixin
,
SessionStore
):
pass
openedx/core/djangoapps/safe_sessions/backends/db.py
0 → 100644
View file @
6eace27f
from
django.contrib.sessions.backends.db
import
SessionStore
from
.base
import
SafeSessionMixin
class
SessionStore
(
SafeSessionMixin
,
SessionStore
):
pass
openedx/core/djangoapps/safe_sessions/backends/file.py
0 → 100644
View file @
6eace27f
from
django.contrib.sessions.backends.file
import
SessionStore
from
.base
import
SafeSessionMixin
class
SessionStore
(
SafeSessionMixin
,
SessionStore
):
pass
openedx/core/djangoapps/safe_sessions/backends/signed_cookies.py
0 → 100644
View file @
6eace27f
from
django.contrib.sessions.backends.signed_cookies
import
SessionStore
from
.base
import
SafeSessionMixin
class
SessionStore
(
SafeSessionMixin
,
SessionStore
):
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment