Documentation ¶
Index ¶
- Variables
- type Repository
- type Service
- func (s Service) Close() error
- func (s Service) Create(ctx context.Context, userID string) (*Session, error)
- func (s Service) Delete(ctx context.Context, sessionID uuid.UUID) error
- func (s Service) ExtractFromContext(ctx context.Context) (*Session, error)
- func (s Service) InitSessions(ctx context.Context) error
- func (s Service) Refresh(ctx context.Context, sessionID uuid.UUID) error
- type Session
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoSession = errors.New("no session") ErrDeletingSession = errors.New("error deleting session") )
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { Set(ctx context.Context, session *Session) error Get(ctx context.Context, id uuid.UUID) (*Session, error) Delete(ctx context.Context, id uuid.UUID) error DeleteExpiredSessions(ctx context.Context) error UpdateValidity(ctx context.Context, id uuid.UUID, validity time.Duration) error }
type Service ¶
func NewService ¶
func (Service) ExtractFromContext ¶
func (Service) InitSessions ¶
InitSessions Initiates CronJob to delete expired sessions from the database
type Session ¶
type Session struct { ID uuid.UUID // UserID is a unique identifier for logged in users UserID string // AuthenticatedAt is set when a user is successfully authn AuthenticatedAt time.Time // ExpiresAt is ideally now() + lifespan of session, e.g. 7 days ExpiresAt time.Time CreatedAt time.Time Metadata metadata.Metadata }
Session is created on successful authentication of users
Click to show internal directories.
Click to hide internal directories.