auth

package
v1.35.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBearerInfoCanceled = errors.New("canceled: bearer info validation abandoned")

ErrBearerInfoCanceled is returned when the caller's own request context was cancelled while validating, which normally means the MCP client hung up first. Nothing went wrong on our side and no response will be read, so this is not worth reporting as a server error.

View Source
var ErrBearerInfoUnauthorized = errors.New("unauthorized: failed to get bearer info")

ErrBearerInfoUnauthorized is returned when Teamwork API positively rejected the bearer token. This is the only error that may be turned into a 401 for the MCP client: a 401 carries an RFC 9728 re-authorisation challenge, which makes the client discard the token and run the OAuth flow again.

View Source
var ErrBearerInfoUnavailable = errors.New("unavailable: failed to validate bearer info")

ErrBearerInfoUnavailable is returned when the token could not be validated at all — Teamwork API was unreachable, timed out, or answered with a server error. The token may well be valid, so callers must not tell the client to throw it away; report this as 503 instead.

Functions

func Bypass

func Bypass(data []byte) (bool, error)

Bypass checks if the protocol method can bypass authentication.

func BypassMethod

func BypassMethod(method string) bool

BypassMethod checks if the protocol method can bypass authentication.

Types

type BearerInfo

type BearerInfo struct {
	UserID         int64  `json:"user_id"`
	InstallationID int64  `json:"installation_id"`
	Region         string `json:"awsRegion"`
	URL            string `json:"url"`
	Meta           struct {
		Scopes []string `json:"scopes"`
	} `json:"meta"`
}

BearerInfo contains information about the bearer token used to authenticate with Teamwork API.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator resolves a bearer token into the installation and user it belongs to. It takes the HTTP client, API base URL and logger explicitly rather than the server configuration, so a server built on this package can supply its own.

func NewValidator

func NewValidator(client *http.Client, apiURL string, logger *slog.Logger) *Validator

NewValidator creates a Validator that asks apiURL to identify bearer tokens.

func (*Validator) GetBearerInfo

func (v *Validator) GetBearerInfo(ctx context.Context, token string) (*BearerInfo, error)

GetBearerInfo retrieves information about the bearer token from Teamwork API. It returns a BearerInfo struct containing the user ID, installation ID, and installation URL. If the token is invalid or unauthorized, it returns ErrBearerInfoUnauthorized.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL