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

Session improvements #510

Merged
merged 9 commits into from
Jan 6, 2024
Merged

Conversation

0xCA
Copy link
Contributor

@0xCA 0xCA commented Dec 28, 2023

Session improvements

Fixed and improved

  • Fixed session duration
  • Use MaxAge instead of Expires
  • Added cookie refresh on all pages (API calls are ignored)
  • Refresh not sooner than 24h
  • Do not refresh temporary sessions
  • Delete cookies on logout

Enhanced security

  • Use HttpOnly and SameSite
  • Auth + Encryption for cookies, based on SessionSecret, via SHA512
  • Verify if the cookie is not too old and not from the future
  • Verify if the user exists and unchanged
  • Any change to the user logs out all other sessions as a result

Params

Variable Description Default
SESSION_MAX_DURATION Max time in days a remembered session is refreshed and valid. Non-refreshed session is valid for 7 days max, regardless of this setting. 90

Discussion

Open for discussion, please check for errors

0xCA added 4 commits December 29, 2023 15:08
v1
Fixed session duration
Use HttpOnly and SameSite
Added cookie refresh on all pages
Use MaxAge instead of Expires
Verify if the cookie is not too old and not from the future
Verify if the user exists and unchanged
Refresh not sooner than 24h
Do not refresh temporary sessions
Delete cookies on logout
@0xCA 0xCA marked this pull request as ready for review December 29, 2023 10:09
@0xCA
Copy link
Contributor Author

0xCA commented Jan 2, 2024

After all, I decided to panic on gob-incompatible model.User
Should be ready for merge after testing and review

handler/session.go Outdated Show resolved Hide resolved
handler/session.go Outdated Show resolved Hide resolved
@ngoduykhanh ngoduykhanh merged commit fa33d3f into ngoduykhanh:master Jan 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants