-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect to index after session expiration on /generate #4496
Conversation
Previous logic when sessions expire on /generate: 1. On /generate page, codename is added to the session. 2. When expiration occurs, session is cleared. 3. A flashed message indicating that the session has expired would be added to the current session (this is done via passing `_flashes` on the session object [0]). 4. Execution enters the view function associated with `/create`. But `/create` expects codename to be in the session (which was cleared in step 2), thus a KeyError will occur. Logic now when sessions expire on /generate: 1. On /generate page, codename is added to the session 2. When expiration occurs, session is cleared and user is redirected to the index. [0] https://github.com/pallets/flask/blob/cd4023d9d2ab630ce4f95856f065072ef8badb2b/flask/helpers.py#L449
Codecov Report
@@ Coverage Diff @@
## develop #4496 +/- ##
===========================================
+ Coverage 83.21% 83.22% +<.01%
===========================================
Files 45 45
Lines 3069 3070 +1
Branches 332 332
===========================================
+ Hits 2554 2555 +1
Misses 430 430
Partials 85 85
Continue to review full report at Codecov.
|
After consideration, I'm going to leave this be, this is a simple fix - I was considering moving the setting of |
Can confirm in Docker-based development environment:
|
Tested in qubes staging environment:
LGTM! |
Status
Ready for review
Description of Changes
Fixes #4490.
Previous logic when sessions expire on
/generate
:/generate
page, codename is added to the session.would be added to the current session (this is done via passing
_flashes
on Flask'ssession
object)./create
.But
/create
expects codename to be in the session (which wascleared in step 2), thus a
KeyError
will occur.If you're wondering "but why does step 4 even happen" - it's because we don't immediately redirect to the index when a session expires. When the session expires when the
@login_required
decorator is on the view function corresponding to the request path, execution doesn't end up entering the view function itself, as the logic in@login_required
will redirect the user to thelogin
page iflogged_in
is not in thesession
object (andlogged_in
won't be in thesession
object, because it gets cleared in step 2).Logic with this diff when sessions expire on
/generate
:/generate
page, codename is added to the sessionTesting
Deployment
No special instructions (deployed via
securedrop-app-code
deb)Checklist
If you made changes to the server application code:
make lint
) and tests (make -C securedrop test
) pass in the development containerIf you made non-trivial code changes: