@@ -519,7 +519,6 @@ To use the SQLAlchemy session backend, you need to:
519519
520520 # 3. Configure session backend
521521 session_config = ServerSideSessionConfig(
522- secret = " your-secret-key-here" , # Use a secure secret in production
523522 max_age = 3600 , # 1 hour
524523 )
525524
@@ -693,34 +692,17 @@ The session table created by ``SessionModelMixin`` has the following structure:
693692Security Considerations
694693^^^^^^^^^^^^^^^^^^^^^^^
695694
696- **Secret Key Management **
697-
698- Always use a secure secret key for session encryption:
699-
700- .. code-block :: python
701-
702- import secrets
703-
704- # Generate a secure random secret
705- secret_key = secrets.token_urlsafe(32 )
706-
707- session_config = ServerSideSessionConfig(
708- secret = secret_key,
709- max_age = 3600 ,
710- https_only = True , # Require HTTPS in production
711- samesite = " strict" , # CSRF protection
712- )
713-
714695**Session Expiration **
715696
716697Configure appropriate session timeouts:
717698
718699.. code-block :: python
719700
701+ # Sessions are automatically renewed on each request
720702 session_config = ServerSideSessionConfig(
721- secret = " your-secret-key" ,
722703 max_age = 1800 , # 30 minutes
723- # Sessions are automatically renewed on each request
704+ https_only = True , # Require HTTPS in production
705+ samesite = " strict" , # CSRF protection
724706 )
725707
726708 **Database Security **
@@ -821,7 +803,6 @@ Here's a complete working example:
821803
822804 # Session configuration
823805 session_config = ServerSideSessionConfig(
824- secret = " your-super-secret-key-change-in-production" ,
825806 max_age = 3600 , # 1 hour
826807 )
827808
0 commit comments