Упростить ошибки сессий, логировать миграции и тестировать с рабочим клиентом Valkey

This commit is contained in:
2026-10-06 15:46:01 +03:00
parent 405fb07608
commit f9850a36c4
7 changed files with 39 additions and 34 deletions
+3 -6
View File
@@ -2,19 +2,16 @@ package auth
import (
"context"
"errors"
"github.com/google/uuid"
)
// ErrSessionNotFound means the token is unknown, expired or revoked; the
// store cannot tell these apart, and the client must not either.
var ErrSessionNotFound = errors.New("session not found")
type Repository interface {
// Create stores the session until its absolute ExpiresAt.
Create(ctx context.Context, s Session) error
// UserID returns the owner of a live session or ErrSessionNotFound.
// UserID returns the owner of a live session, or ErrUnauthenticated when
// the token is unknown, expired or revoked: the store cannot tell these
// apart, and the client must not either.
UserID(ctx context.Context, tokenHash string) (uuid.UUID, error)
// Delete revokes the session; deleting a missing one is not an error.
Delete(ctx context.Context, tokenHash string) error