storj/satellite/console/consoleauth/sessions.go
Jeremy Wharton 3f26cc599f satellite/console,web/satellite: invalidate sessions after inactivity
Sessions now expire after a much shorter amount of time, requiring
clients to issue API requests for session extension. This is handled
behind the scenes as the user interacts with the page, but once session
expiration is imminent, a modal appears which informs the user of his
inactivity and presents him with the choice of loging out or preserving
his session.

Change-Id: I68008d45859c814a835d65d882ad5ad2199d618e
2022-08-23 15:51:05 +00:00

38 lines
1.3 KiB
Go

// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.
package consoleauth
import (
"context"
"time"
"storj.io/common/uuid"
)
// WebappSessions is the repository for webapp sessions.
type WebappSessions interface {
// Create creates a webapp session and returns the session info.
Create(ctx context.Context, id, userID uuid.UUID, ip, userAgent string, expires time.Time) (WebappSession, error)
// GetBySessionID gets the session info from the session ID.
GetBySessionID(ctx context.Context, sessionID uuid.UUID) (WebappSession, error)
// GetAllByUserID gets all webapp sessions with userID.
GetAllByUserID(ctx context.Context, userID uuid.UUID) ([]WebappSession, error)
// DeleteBySessionID deletes a webapp session by ID.
DeleteBySessionID(ctx context.Context, sessionID uuid.UUID) error
// DeleteAllByUserID deletes all webapp sessions by user ID.
DeleteAllByUserID(ctx context.Context, userID uuid.UUID) (int64, error)
// UpdateExpiration updates the expiration time of the session.
UpdateExpiration(ctx context.Context, sessionID uuid.UUID, expiresAt time.Time) (err error)
}
// WebappSession represents a session on the satellite web app.
type WebappSession struct {
ID uuid.UUID
UserID uuid.UUID
Address string
UserAgent string
Status int
ExpiresAt time.Time
}