-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix(session-storage): add typing and trust proxy setting #9725
base: main
Are you sure you want to change the base?
Conversation
Added explicit typing for session storage options to improve type safety. Enabled 'trust proxy' to ensure proper client IP and protocol detection behind proxies. These changes improve security and reliability in session handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Added explicit typing for session storage options and enabled trust proxy settings to improve security and reliability when running behind proxies, particularly for SSO functionality.
- Added
trust proxy
setting inpackages/twenty-server/src/main.ts
to ensure accurate client IP detection - Implemented explicit
session.SessionOptions
typing insession-storage.module-factory.ts
for better type safety - Set secure cookie option based on HTTPS detection through
SERVER_URL
environment variable - Added Redis connection error handling with descriptive error messages
2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
// Trust the first proxy to ensure correct client IP and protocol detection. | ||
app.set('trust proxy', 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Ensure this is only enabled when actually running behind a proxy. Consider making this configurable via an environment variable.
Relocated the session middleware initialization to an earlier point in the code for better alignment and clarity. This change ensures proper setup and avoids redundancy in the middleware application.
Fix #9430 |
Added explicit typing for session storage options to improve type safety. Enabled 'trust proxy' to ensure proper client IP and protocol detection behind proxies. These changes improve security and reliability in session handling.