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

3060 active user session #3182

Merged
merged 28 commits into from
Oct 16, 2024
Merged

3060 active user session #3182

merged 28 commits into from
Oct 16, 2024

Conversation

raftmsohani
Copy link

@raftmsohani raftmsohani commented Sep 11, 2024

Summary of Changes

Pull request closes #3060 _

How to Test

List the steps to test the PR
These steps are generic, please adjust as necessary.

cd tdrs-frontend && docker-compose -f docker-compose.yml -f docker-compose.local.yml up -d
cd tdrs-backend && docker-compose -f docker-compose.yml -f docker-compose.local.yml up -d 
  1. Open http://localhost:3000/ and sign in.
  2. The timeout is set 10 seconds, as long as you browse different pages, you will be considered active.

Deliverables

More details on how deliverables herein are assessed included here.

Deliverable 1: Accepted Features

Checklist of ACs:

  • A user session persists while the user is actively using the system
  • the session ends when the browser is closed
  • the session ends if the user is inactive for 15-30 minutes (see above)
  • lfrohlich and/or adpennington confirmed that ACs are met.

Deliverable 2: Tested Code

  • Are all areas of code introduced in this PR meaningfully tested?
    • If this PR introduces backend code changes, are they meaningfully tested?
    • If this PR introduces frontend code changes, are they meaningfully tested?
  • Are code coverage minimums met?
    • Frontend coverage: [insert coverage %] (see CodeCov Report comment in PR)
    • Backend coverage: [insert coverage %] (see CodeCov Report comment in PR)

Deliverable 3: Properly Styled Code

  • Are backend code style checks passing on CircleCI?
  • Are frontend code style checks passing on CircleCI?
  • Are code maintainability principles being followed?

Deliverable 4: Accessible

  • Does this PR complete the epic?
  • Are links included to any other gov-approved PRs associated with epic?
  • Does PR include documentation for Raft's a11y review?
  • Did automated and manual testing with iamjolly and ttran-hub using Accessibility Insights reveal any errors introduced in this PR?

Deliverable 5: Deployed

  • Was the code successfully deployed via automated CircleCI process to development on Cloud.gov?

Deliverable 6: Documented

  • Does this PR provide background for why coding decisions were made?
  • If this PR introduces backend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces frontend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces dependencies, are their licenses documented?
  • Can reviewer explain and take ownership of these elements presented in this code review?

Deliverable 7: Secure

  • Does the OWASP Scan pass on CircleCI?
  • Do manual code review and manual testing detect any new security issues?
  • If new issues detected, is investigation and/or remediation plan documented?

Deliverable 8: User Research

Research product(s) clearly articulate(s):

  • the purpose of the research
  • methods used to conduct the research
  • who participated in the research
  • what was tested and how
  • impact of research on TDP
  • (if applicable) final design mockups produced for TDP development

@raftmsohani raftmsohani self-assigned this Sep 11, 2024
@raftmsohani raftmsohani added the Deploy with CircleCI-raft Deploy to https://tdp-frontend-raft.app.cloud.gov through CircleCI label Sep 11, 2024
@raftmsohani raftmsohani removed the Deploy with CircleCI-raft Deploy to https://tdp-frontend-raft.app.cloud.gov through CircleCI label Sep 11, 2024
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.66%. Comparing base (3ed27eb) to head (1e01d38).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3182   +/-   ##
========================================
  Coverage    92.66%   92.66%           
========================================
  Files           47       47           
  Lines         1009     1009           
  Branches       169      169           
========================================
  Hits           935      935           
  Misses          42       42           
  Partials        32       32           
Flag Coverage Δ
dev-frontend 92.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ccb07cc...1e01d38. Read the comment docs.

@raftmsohani raftmsohani added the Deploy with CircleCI-raft Deploy to https://tdp-frontend-raft.app.cloud.gov through CircleCI label Sep 11, 2024
@raftmsohani
Copy link
Author

backend is using django.contrib.session, which enables db backend session manager. However, we also enable cookie session enabled by SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies" which in turn happens to only respect default SESSION_COOKIE_AGE and not updated session timeout

@raftmsohani
Copy link
Author

raftmsohani commented Sep 24, 2024

We are using signed-cookies to keep the session information, which is using SessionBase.
With every new request, the session timestamp is updated by signing a new session using signing package.

SESSION_COOKIE_AGE = 15 * 60 # 15 minutes
#SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_SAVE_EVERY_REQUEST = True
SESSION_COOKIE_AGE = 10 # 15 minutes
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing only: revert back to previous setting

@@ -1,7 +1,6 @@
"""Admin class for DataFile objects."""
from django.contrib import admin
from tdpservice.core.utils import ReadOnlyAdminMixin
# from tdpservice.core.filters import custom_filter_title
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR but I saw this is commented and not deleted

@raftmsohani raftmsohani added the raft review This issue is ready for raft review label Sep 26, 2024
@raftmsohani raftmsohani added QASP Review and removed raft review This issue is ready for raft review labels Oct 10, 2024
@ADPennington ADPennington removed the Deploy with CircleCI-raft Deploy to https://tdp-frontend-raft.app.cloud.gov through CircleCI label Oct 10, 2024
@ADPennington ADPennington added the Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI label Oct 10, 2024
@@ -281,10 +281,12 @@ class Common(Configuration):
)

# Sessions
SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
SESSION_ENGINE = "tdpservice.core.custom_session_engine"
SIGNED_COOKIE_EXPIRES = 60 * 60 * 24 # 24 hours
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raftmsohani is this set to expire 24 hours from the initial session? if so, i wonder if it would be better to shorten this to 12 hours, which is on the very high end of an average work day. i'm also reaching out to our security officer about this.

Copy link
Collaborator

@ADPennington ADPennington Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evidence below suggests expiry 24 hours into future. left side is staging (current state) and right side is qasp (this branch)

Screenshot 2024-10-10 172400

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raftmsohani TDP's ISSO's feedback:

  • this change is related to AC-2-5. We'll need to update this documentation as part of this work to capture how the session refresh/expiration works for ACF users.
  • let's also reduce the expiration to 12 hours
  • we'll likely need to also complete risk-based decision documentation when the security team provides it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ADPennington we shouldn't need to update the AC-2-5, since we are still following same time out concept. In fact, this PR makes sure we are exactly following this time out setting.
The only difference is: with new changes, even if the user is active, system will log the user out after 12hrs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirming that the AC-2-5 seems aligned with the behavior in this PR, particularly this part: If the user chooses to extend the session, TDP will refresh the session.

@ADPennington ADPennington added OCIO Review and removed Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI labels Oct 10, 2024
Copy link
Collaborator

@ADPennington ADPennington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feedback included in comments.

@ADPennington ADPennington added raft review This issue is ready for raft review and removed QASP Review OCIO Review labels Oct 11, 2024
@ADPennington ADPennington added the Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI label Oct 16, 2024
@andrew-jameson andrew-jameson added QASP Review and removed raft review This issue is ready for raft review labels Oct 16, 2024
SESSION_COOKIE_HTTPONLY = True
SESSION_SAVE_EVERY_REQUEST = True
#SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 10 # 15 minutes
SESSION_COOKIE_AGE = 60 * 30 # 30 minutes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raftmsohani can confirm that I received the warning for inactivity while logged in via AMS. im gonna wait another 30 minutes, because Im trying to understand the relationship between cookie_age and cookie_expires. max age set to 30 minutes when looking at devtools.

@ADPennington ADPennington removed the Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI label Oct 16, 2024
Copy link
Collaborator

@ADPennington ADPennington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 thanks @raftmsohani

@raftmsohani raftmsohani merged commit 34fb345 into develop Oct 16, 2024
27 checks passed
@raftmsohani raftmsohani deleted the 3060-active-user-session branch October 16, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

As a TDP user, I need to stay logged in when I'm actively using the system
5 participants