FIX: Extend JWT token expiration to 24 hours for document viewer sessions
- Add GenerateWithDuration method to JWT manager to support custom expiration times - Update viewerHandler and userViewerHandler to generate viewer-specific tokens with 24-hour expiration - This fixes the issue where PDF viewer fails due to token expiration within 15 minutes - Add [VIEWER-SESSION] logging to track viewer session creation - Tokens now remain valid long enough for users to view, navigate, and interact with PDFs
This commit is contained in:
@@ -27,12 +27,16 @@ func NewManager(secret string) *Manager {
|
||||
}
|
||||
|
||||
func (m *Manager) Generate(userID string, orgIDs []string, sessionID string) (string, error) {
|
||||
return m.GenerateWithDuration(userID, orgIDs, sessionID, 15*time.Minute)
|
||||
}
|
||||
|
||||
func (m *Manager) GenerateWithDuration(userID string, orgIDs []string, sessionID string, duration time.Duration) (string, error) {
|
||||
claims := Claims{
|
||||
UserID: userID,
|
||||
OrgIDs: orgIDs,
|
||||
SessionID: sessionID,
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(time.Now().Add(15 * time.Minute)),
|
||||
ExpiresAt: jwt.NewNumericDate(time.Now().Add(duration)),
|
||||
IssuedAt: jwt.NewNumericDate(time.Now()),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user