auth.go 802 B

123456789101112131415161718192021222324252627
  1. package auth
  2. import (
  3. "context"
  4. "errors"
  5. )
  6. var (
  7. ErrTokenExpired = errors.New("token has expired")
  8. ErrInvalidToken = errors.New("token is invalid")
  9. ErrTokenBlacklisted = errors.New("token has been revoked")
  10. )
  11. // Service defines the interface for authentication operations
  12. type Service interface {
  13. // GenerateToken creates a new authentication token for a user
  14. GenerateToken(ctx context.Context, clientID string) (string, error)
  15. // ValidateToken verifies a token and returns the client ID if valid
  16. ValidateToken(ctx context.Context, token string) (string, error)
  17. // RefreshToken creates a new token based on an existing valid token
  18. RefreshToken(ctx context.Context, token string) (string, error)
  19. // Logout invalidates a token
  20. Logout(ctx context.Context, token string) error
  21. }