Documentation
¶
Index ¶
- Constants
- func ClearSecrets(path string, st *State, store secretstore.Store) error
- func Fingerprint(secret string) string
- func Redacted(secret string) string
- func Save(path string, st *State) error
- func SaveWithSecrets(path string, st *State, store secretstore.Store) error
- func SetServerInstructions(st *State, instructions string)
- func SetToken(st *State, tok TokenState)
- func SetTools(st *State, tools []*mcp.Tool)
- type AuthorizationState
- type CallRecord
- type ClientState
- type DiscoveryState
- type OldRefreshTokenCheck
- type ProtectedResourceState
- type RotationAttempt
- type SecretBundle
- type State
- type TokenSecrets
- type TokenState
Constants ¶
const DefaultPath = ".mcp-oauth-cli/state.json"
Variables ¶
This section is empty.
Functions ¶
func ClearSecrets ¶ added in v0.2.0
func ClearSecrets(path string, st *State, store secretstore.Store) error
ClearSecrets removes stored secrets (primary and per-entry history) from store and clears tokens, client secrets, and authorization codes from st before saving to disk. If st.SecretID is set, store must be non-nil and keyring deletion must succeed before st.SecretID is cleared on disk.
func Fingerprint ¶
func SaveWithSecrets ¶ added in v0.2.0
func SaveWithSecrets(path string, st *State, store secretstore.Store) error
SaveWithSecrets writes state to disk. When store is non-nil, current token and client secrets are stored under st.SecretID, historical refresh tokens are stored in separate <secret_id>/prev/<index> entries so the primary item stays bounded in size, and raw secrets are stripped from disk while preserving metadata and SHA-256 fingerprints.
func SetServerInstructions ¶
func SetToken ¶
func SetToken(st *State, tok TokenState)
Types ¶
type AuthorizationState ¶
type CallRecord ¶
type ClientState ¶
type ClientState struct {
Mode string `json:"mode,omitempty"`
ClientID string `json:"client_id,omitempty"`
ClientSecret string `json:"client_secret,omitempty"`
TokenEndpointAuthMethod string `json:"token_endpoint_auth_method,omitempty"`
Registration *oauthex.ClientRegistrationResponse `json:"registration,omitempty"`
}
type DiscoveryState ¶
type DiscoveryState struct {
ServerURL string `json:"server_url,omitempty"`
Protected *ProtectedResourceState `json:"protected_resource,omitempty"`
AuthServer *oauthex.AuthServerMeta `json:"auth_server,omitempty"`
}
type OldRefreshTokenCheck ¶
type OldRefreshTokenCheck struct {
HistoryIndex int `json:"history_index"`
OriginalReceivedAt time.Time `json:"original_received_at,omitempty"`
RefreshFingerprint string `json:"refresh_fingerprint,omitempty"`
Usable bool `json:"usable"`
NewAccessFingerprint string `json:"new_access_fingerprint,omitempty"`
NewRefreshFingerprint string `json:"new_refresh_fingerprint,omitempty"`
RefreshTokenRotated bool `json:"refresh_token_rotated"`
RefreshTokenReused bool `json:"refresh_token_reused"`
Error string `json:"error,omitempty"`
CheckedAt time.Time `json:"checked_at"`
}
type ProtectedResourceState ¶
type ProtectedResourceState struct {
MetadataURL string `json:"metadata_url,omitempty"`
Metadata *oauthex.ProtectedResourceMetadata `json:"metadata,omitempty"`
}
type RotationAttempt ¶
type SecretBundle ¶ added in v0.2.0
type SecretBundle struct {
ClientSecret string `json:"client_secret,omitempty"`
RegistrationClientSecret string `json:"registration_client_secret,omitempty"`
CurrentToken *TokenSecrets `json:"current_token,omitempty"`
}
type State ¶
type State struct {
SecretID string `json:"secret_id,omitempty"`
RedirectURL string `json:"redirect_url,omitempty"`
Discovery *DiscoveryState `json:"discovery,omitempty"`
Client *ClientState `json:"client,omitempty"`
Authorization *AuthorizationState `json:"authorization,omitempty"`
CurrentToken *TokenState `json:"current_token,omitempty"`
PreviousTokens []TokenState `json:"previous_tokens,omitempty"`
Tools []*mcp.Tool `json:"tools,omitempty"`
ToolsListedAt time.Time `json:"tools_listed_at,omitempty"`
ServerInstructions string `json:"server_instructions,omitempty"`
ServerInstructionsAt time.Time `json:"server_instructions_at,omitempty"`
Calls []CallRecord `json:"calls,omitempty"`
RotationAttempts []RotationAttempt `json:"rotation_attempts,omitempty"`
OldRefreshChecks []OldRefreshTokenCheck `json:"old_refresh_checks,omitempty"`
}
func LoadWithHistorySecrets ¶ added in v0.2.0
func LoadWithHistorySecrets(path string, store secretstore.Store) (*State, error)
LoadWithHistorySecrets loads the state file, current secrets, and per-entry historical refresh tokens stored under <secret_id>/prev/<index>.
func LoadWithSecrets ¶ added in v0.2.0
func LoadWithSecrets(path string, store secretstore.Store) (*State, error)
LoadWithSecrets loads the state file and, when store is non-nil and SecretID is set, hydrates the current token and client secrets from store.
func RedactState ¶
func (*State) RequireAuthServer ¶
func (*State) RequireClient ¶
func (*State) RequireServer ¶
func (*State) RequireToken ¶
type TokenSecrets ¶ added in v0.2.0
type TokenState ¶
type TokenState struct {
AccessToken string `json:"access_token,omitempty"`
TokenType string `json:"token_type,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
Expiry time.Time `json:"expiry,omitempty"`
Scope string `json:"scope,omitempty"`
AccessFingerprint string `json:"access_fingerprint,omitempty"`
RefreshFingerprint string `json:"refresh_fingerprint,omitempty"`
ReceivedAt time.Time `json:"received_at,omitempty"`
Raw json.RawMessage `json:"raw,omitempty"`
}
func RedactToken ¶
func RedactToken(tok *TokenState) *TokenState
func (*TokenState) EffectiveAccessFingerprint ¶
func (t *TokenState) EffectiveAccessFingerprint() string
func (*TokenState) EffectiveRefreshFingerprint ¶
func (t *TokenState) EffectiveRefreshFingerprint() string