feat(auth): add refresh token lifecycle, session refresh endpoint, an… #302

Closed
opened 2026-04-05 16:19:19 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @simlarsen on 11/5/2025

…d auto-refresh middleware

  • Add refresh token signing and decoding (JSONWebToken.signRefreshToken, decodeRefreshToken)
  • Persist hashed refresh token on user on signup, login and SSO flows
  • Invalidate persisted refresh token on logout
  • Add /refresh-session endpoint to validate refresh token, rotate session, and return refreshed session
  • Implement middleware tryRefreshSession to auto-refresh expired access tokens using refresh token
  • Make CookieUtil.setUserCookie return session details (access/refresh tokens, sessionId, expiries) and set both cookies
  • Introduce secure default cookie options (path, sameSite, secure, httpOnly) and use IsProduction for secure flag
  • Add CookieName.RefreshToken constant and update tests accordingly

Title of this pull request?

Small Description?

Pull Request Checklist:

  • Please make sure all jobs pass before requesting a review.
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).
  • Have you lint your code locally before submission?
  • Did you write tests where appropriate?

Screenshots (if appropriate):

*Originally created by @simlarsen on 11/5/2025* …d auto-refresh middleware - Add refresh token signing and decoding (JSONWebToken.signRefreshToken, decodeRefreshToken) - Persist hashed refresh token on user on signup, login and SSO flows - Invalidate persisted refresh token on logout - Add /refresh-session endpoint to validate refresh token, rotate session, and return refreshed session - Implement middleware tryRefreshSession to auto-refresh expired access tokens using refresh token - Make CookieUtil.setUserCookie return session details (access/refresh tokens, sessionId, expiries) and set both cookies - Introduce secure default cookie options (path, sameSite, secure, httpOnly) and use IsProduction for secure flag - Add CookieName.RefreshToken constant and update tests accordingly ### Title of this pull request? ### Small Description? ### Pull Request Checklist: - [ ] Please make sure all jobs pass before requesting a review. - [ ] Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). - [ ] Have you lint your code locally before submission? - [ ] Did you write tests where appropriate? ### Related Issue? ### Screenshots (if appropriate):
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#302