Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidPort = errors.New("invalid local port") ErrInvalidState = errors.New("invalid or expired state") ErrIncompatibleVersion = errors.New("incompatible client version") ErrRateLimited = errors.New("rate limit exceeded") ErrAccountBanned = errors.New("account banned") ErrAuthDenied = errors.New("authorization denied") ErrInvalidRefreshToken = errors.New("invalid or missing refresh token") ErrRefreshFailed = errors.New("token refresh failed") )
Functions ¶
This section is empty.
Types ¶
type AuthError ¶
type CallbackRequest ¶
type CallbackResult ¶
type OAuth ¶
type OAuth struct {
// contains filtered or unexported fields
}
func NewOAuth ¶
func NewOAuth( oauthConfig *oauth2.Config, stateStore storage.StateStore, userService user.Service, whoopLimiter storage.WhoopRateLimiter, ) *OAuth
func (*OAuth) HandleCallback ¶
func (s *OAuth) HandleCallback(ctx context.Context, req CallbackRequest) (*CallbackResult, error)
func (*OAuth) RefreshToken ¶
func (s *OAuth) RefreshToken(ctx context.Context, req RefreshRequest) (*RefreshResult, error)
func (*OAuth) StartAuth ¶
func (s *OAuth) StartAuth(ctx context.Context, req StartAuthRequest) (*StartAuthResult, error)
type RefreshRequest ¶
type RefreshRequest struct {
RefreshToken string
}
type RefreshResult ¶
type Service ¶
type Service interface {
// StartAuth validates the request, stores state, and returns the auth URL.
// Returns ErrInvalidPort if the local port is invalid.
// Returns *VersionError (wrapping ErrIncompatibleVersion) if version check fails.
StartAuth(ctx context.Context, req StartAuthRequest) (*StartAuthResult, error)
// HandleCallback processes the OAuth callback.
// Returns ErrInvalidState if state is missing or invalid.
// Returns ErrAuthDenied if WHOOP denied authorization.
// Returns ErrRateLimited if rate limited.
// Returns ErrAccountBanned if the user is banned.
// The returned *AuthError contains LocalPort for redirect construction.
HandleCallback(ctx context.Context, req CallbackRequest) (*CallbackResult, error)
// RefreshToken exchanges a refresh token for new access and refresh tokens.
// Returns ErrInvalidRefreshToken if refresh token is missing.
// Returns ErrRefreshFailed if the token exchange fails.
RefreshToken(ctx context.Context, req RefreshRequest) (*RefreshResult, error)
}
type StartAuthRequest ¶
type StartAuthResult ¶
type StartAuthResult struct {
AuthURL string
}
type VersionError ¶
type VersionError struct {
MinVersion string
}
func (*VersionError) Error ¶
func (e *VersionError) Error() string
func (*VersionError) Unwrap ¶
func (e *VersionError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.