Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrTokenNotFound = errors.New("token not found")
)
Functions ¶
This section is empty.
Types ¶
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore implements in-memory session-based CSRF token storage
func NewSessionStore ¶
func NewSessionStore(args ...any) *SessionStore
NewSessionStore creates a new session-based token store. The first argument is an optional context.Context used to control the lifetime of the background cleanup goroutine. When the context is cancelled, the goroutine stops automatically. If no context is provided (or nil), context.Background() is used and Close() must be called manually.
An optional lifetime duration can be provided after the context; defaults to 24h if zero or omitted.
Accepted call signatures:
NewSessionStore() // background ctx, 24h lifetime NewSessionStore(ctx) // caller ctx, 24h lifetime NewSessionStore(lifetime) // background ctx, custom lifetime (backward compat) NewSessionStore(ctx, lifetime) // caller ctx, custom lifetime
func (*SessionStore) Close ¶ added in v0.9.2
func (s *SessionStore) Close()
Close stops the background cleanup goroutine. It is safe to call Close() even if the parent context has already been cancelled (it becomes a no-op in that case). Close is kept for backward compatibility; prefer passing a cancellable context to NewSessionStore.
func (*SessionStore) Exists ¶
func (s *SessionStore) Exists(id string) bool
Exists checks if a token exists and is not expired