Documentation
¶
Index ¶
- Variables
- func ClearSessionCookies(w http.ResponseWriter)
- func Configure(secure bool)
- func ReadAccessToken(r *http.Request) (string, bool)
- func ReadRefreshToken(r *http.Request) (string, bool)
- func SetAccessToken(w http.ResponseWriter, token string, maxAgeSeconds int)
- func SetRefreshToken(w http.ResponseWriter, token string, maxAgeSeconds int)
- type AccessIdentity
- type Service
- func (s *Service) CleanupExpiredData(ctx context.Context, now time.Time) error
- func (s *Service) CreateSession(ctx context.Context, userID uuid.UUID, audience token.Audience, ...) (accessToken string, refreshToken string, err error)
- func (s *Service) ListUserSessions(ctx context.Context, userID uuid.UUID, currentSessionID uuid.UUID, ...) ([]domain.Session, error)
- func (s *Service) Logout(ctx context.Context, refreshToken string) error
- func (s *Service) RefreshSession(ctx context.Context, refreshToken string, audience token.Audience, ...) (newAccessToken string, newRefreshToken string, err error)
- func (s *Service) RevokeAllSessions(ctx context.Context, userID uuid.UUID) error
- func (s *Service) RevokeOtherUserSessions(ctx context.Context, userID uuid.UUID, currentSessionID uuid.UUID, ...) error
- func (s *Service) RevokeUserSession(ctx context.Context, userID uuid.UUID, sessionID uuid.UUID, now time.Time) error
- func (s *Service) StartCleanupWorker(ctx context.Context, logger *slog.Logger, interval time.Duration)
- func (s *Service) ValidateAccessToken(accessToken string, expectedAudience token.Audience, now time.Time) (*AccessIdentity, error)
- func (s *Service) ValidateAnyAccessToken(accessToken string, now time.Time) (*AccessIdentity, error)
- type SessionConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnauthenticated = errors.New("unauthenticated") ErrSessionExpired = errors.New("session expired") ErrSessionRevoked = errors.New("session revoked") ErrInvalidSession = errors.New("invalid session") ErrInvalidRefreshToken = errors.New("invalid refresh token") ErrRefreshTokenReuse = errors.New("refresh token reuse") ErrForbidden = errors.New("forbidden") ErrUserDisabled = errors.New("user is disabled") ErrUserNotAllowed = errors.New("user is not allowed") )
Functions ¶
func ClearSessionCookies ¶
func ClearSessionCookies(w http.ResponseWriter)
func SetAccessToken ¶
func SetAccessToken(w http.ResponseWriter, token string, maxAgeSeconds int)
func SetRefreshToken ¶
func SetRefreshToken(w http.ResponseWriter, token string, maxAgeSeconds int)
Types ¶
type AccessIdentity ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg SessionConfig) *Service
func (*Service) CleanupExpiredData ¶ added in v0.1.6
func (*Service) CreateSession ¶
func (*Service) ListUserSessions ¶ added in v0.1.16
func (*Service) RefreshSession ¶
func (*Service) RevokeAllSessions ¶
func (*Service) RevokeOtherUserSessions ¶ added in v0.1.16
func (*Service) RevokeUserSession ¶ added in v0.1.16
func (*Service) StartCleanupWorker ¶ added in v0.1.6
func (*Service) ValidateAccessToken ¶
func (*Service) ValidateAnyAccessToken ¶ added in v0.1.13
type SessionConfig ¶
type SessionConfig struct {
Store *store.Store
Tx *tx.Manager
AccessTokens *token.AccessTokenService
SessionTTL time.Duration
RefreshTokenTTL time.Duration
RefreshTokenRotation time.Duration
AccessPolicy accesspolicy.EmailAccessPolicy
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.