forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* no change * lok into token * Added a custom session handler instead of signed_sessions * Update common.py * Update README.md * added a new settings * 3060 linting * 3060 linting * 3060 remove unused params * 3060 uncommented SIGNED_COOKIE_EXPIRES * 3060 update markdown * disable session expire at browser close * remove unused overrides * corrected the timeouts --------- Co-authored-by: Alex P. <63075587+ADPennington@users.noreply.github.com>
- Loading branch information
1 parent
ccb07cc
commit 34fb345
Showing
5 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Custom session engine for TDP.""" | ||
|
||
from django.contrib.sessions.backends import signed_cookies | ||
from django.core import signing | ||
import datetime | ||
from django.conf import settings | ||
|
||
class SessionStore(signed_cookies.SessionStore): | ||
"""Custom session engine for TDP.""" | ||
|
||
def __init__(self, session_key=None): | ||
"""Initialize the custom session engine.""" | ||
super().__init__(session_key) | ||
|
||
def load(self): | ||
"""Load the session data from the database.""" | ||
""" | ||
Load the data from the key itself instead of fetching from some | ||
external data store. Opposite of _get_session_key(), raise BadSignature | ||
if signature fails. | ||
""" | ||
|
||
try: | ||
return signing.loads( | ||
self.session_key, | ||
serializer=self.serializer, | ||
# This doesn't handle non-default expiry dates, see #19201 | ||
max_age=datetime.timedelta(seconds=settings.SIGNED_COOKIE_EXPIRES), | ||
salt="django.contrib.sessions.backends.signed_cookies", | ||
) | ||
except Exception: | ||
# BadSignature, ValueError, or unpickling exceptions. If any of | ||
# these happen, reset the session. | ||
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters