Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
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.
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 BypassMethod ¶
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 ¶
NewValidator creates a Validator that asks apiURL to identify bearer tokens.
func (*Validator) GetBearerInfo ¶
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.