Skip to content
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

Make use of session-storage safer and more DRY #442

Open
StephenChan opened this issue Feb 24, 2022 · 0 comments
Open

Make use of session-storage safer and more DRY #442

StephenChan opened this issue Feb 24, 2022 · 0 comments
Milestone

Comments

@StephenChan
Copy link
Member

We typically use session storage in multi-step views such as metadata/annotation upload - request 1 stores the data in the session and gives a preview to the user, then request 2 lets the user confirm and saves the data that was stored in the session.

Using sessions for this ensures that the user is the same for both requests, which is good. However, one potentially unsafe thing is that the session key is only unique per view (e.g. session['uploaded_annotations'], not unique per view-visit. So if the same user starts two annotation-uploads in different browser tabs, for example, then depending on the timing of events, CoralNet could end up trying to save tab 1's data when the confirm button is clicked in tab 2. It would be safer if each tab had its own unique session key, which is returned from request 1 and passed in during request 2.

Also, each view that uses sessions like this uses Django's cache API directly and provides its own 'not in session' error message when things go wrong. This could probably stand to be more DRY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant