// Package scs_session - SessionStore backed by alexedwards/scs. package scs_session import ( "context" "net/http" "atlas9.dev/c/core" "atlas9.dev/c/core/iam" "github.com/alexedwards/scs/v2" ) // Store wraps scs.SessionManager to implement identity.SessionStore type Store struct { manager *scs.SessionManager } var _ iam.SessionStore = (*Store)(nil) func New(m *scs.SessionManager) *Store { return &Store{manager: m} } func (s *Store) Put(ctx context.Context, id core.ID) error { s.manager.Put(ctx, "principal", id.String()) return nil } func (s *Store) Get(ctx context.Context) (core.ID, error) { raw := s.manager.GetString(ctx, "principal") return core.ParseID(raw) } func (s *Store) Destroy(ctx context.Context) error { return s.manager.Destroy(ctx) } func Middleware(s *Store, next http.Handler) http.Handler { return s.manager.LoadAndSave(next) }