Documentation
¶
Index ¶
- Constants
- func ApprovalMintRequest(label string, scope GrantScope) (*models.CreateAccessTokenRequest, error)
- func CanonicalResource(raw string) (string, error)
- func DefaultURL(kind, custom string) (string, error)
- func InferKind(raw string) (string, error)
- func NormalizeApprovalPreset(raw string, caps []string) (string, []string, error)
- func PublicBase(scheme, host, forwardedProto, forwardedHost, forwardedPort, configured string) string
- func WithRESTMeta(ctx context.Context, projectID, tenantID string, headers map[string]string) context.Context
- type AccessRecord
- type AuditEvent
- type Auditor
- type AuthRequest
- type ClientRecord
- type CodeRecord
- type Endpoint
- type GrantScope
- type Handler
- type Options
- type RESTMeta
- type RefreshRecord
- type Store
- func (s *Store) Access(raw string) (AccessRecord, bool)
- func (s *Store) Client(id string) (ClientRecord, bool)
- func (s *Store) Request(id string) (AuthRequest, bool)
- func (s *Store) SaveAccess(raw string, rec AccessRecord) error
- func (s *Store) SaveClient(rec ClientRecord) error
- func (s *Store) SaveCode(raw string, rec CodeRecord) error
- func (s *Store) SaveRefresh(raw string, rec RefreshRecord) error
- func (s *Store) SaveRequest(rec AuthRequest) error
- func (s *Store) TakeCode(raw string) (CodeRecord, bool)
- func (s *Store) TakeRefresh(raw string) (RefreshRecord, bool)
- type SystemAPI
- type Tool
Constants ¶
const ( KindCloud = "cloud" KindLocal = "local" KindCustom = "custom" CloudMCPURL = "https://api.apito.io/mcp" LocalMCPURL = "http://localhost:4055/mcp" ScopeMCP = "mcp" )
Variables ¶
This section is empty.
Functions ¶
func ApprovalMintRequest ¶
func ApprovalMintRequest(label string, scope GrantScope) (*models.CreateAccessTokenRequest, error)
ApprovalMintRequest builds the mint for an MCP approval. An empty preset stays mcp_assistant. MCP advanced and Custom are the other choices. Named presets ignore client-supplied capabilities.
func CanonicalResource ¶
CanonicalResource removes client hints from the resource identifier. kind and profile are not part of the OAuth audience.
func DefaultURL ¶
DefaultURL is the clean URL for a deployment. It does not add kind or profile.
func NormalizeApprovalPreset ¶
NormalizeApprovalPreset keeps MCP approval on mcp_assistant, mcp_advanced, or custom.
func PublicBase ¶
func PublicBase(scheme, host, forwardedProto, forwardedHost, forwardedPort, configured string) string
PublicBase is scheme://host[:port] for the request the client actually used. A loopback host with no port is the Studio console on 4055. Nginx $host drops that port, and the MCP resource must still be http://localhost:4055/mcp.
Types ¶
type AccessRecord ¶
type AccessRecord struct {
Hash string `json:"hash"`
ClientID string `json:"client_id"`
Resource string `json:"resource"`
UserID string `json:"user_id"`
InternalToken string `json:"internal_token,omitempty"`
Scope string `json:"scope"`
ExpiresAt time.Time `json:"expires_at"`
RefreshHash string `json:"refresh_hash,omitempty"`
}
type AuditEvent ¶
type AuditEvent struct {
RequestID string `json:"request_id"`
Tool string `json:"tool"`
Transport string `json:"transport"`
Edition string `json:"edition"`
ProjectID string `json:"project_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
ScopeOK bool `json:"scope_ok"`
Error string `json:"error,omitempty"`
}
AuditEvent is trusted server-side MCP metadata.
type Auditor ¶
type Auditor interface {
Record(ctx context.Context, event AuditEvent)
}
Auditor records MCP tool calls on the existing log pipeline.
type AuthRequest ¶
type AuthRequest struct {
ID string `json:"id"`
ClientID string `json:"client_id"`
RedirectURI string `json:"redirect_uri"`
CodeChallenge string `json:"code_challenge"`
Method string `json:"method"`
Resource string `json:"resource"`
State string `json:"state"`
Scope string `json:"scope"`
ExpiresAt time.Time `json:"expires_at"`
Status string `json:"status"`
}
type ClientRecord ¶
type CodeRecord ¶
type CodeRecord struct {
Hash string `json:"hash"`
ClientID string `json:"client_id"`
RedirectURI string `json:"redirect_uri"`
Challenge string `json:"challenge"`
Method string `json:"method"`
Resource string `json:"resource"`
UserID string `json:"user_id"`
InternalToken string `json:"internal_token,omitempty"`
ProjectMode string `json:"project_mode"`
ProjectIDs []string `json:"project_ids"`
TenantMode string `json:"tenant_mode"`
TenantIDs map[string][]string `json:"tenant_ids"`
ExpiresAt time.Time `json:"expires_at"`
Used bool `json:"used"`
}
type GrantScope ¶
type GrantScope struct {
Name string
Description string
Duration string
Preset string
Capabilities []string
ProjectGrantMode string
ProjectIDs []string
TenantGrantMode string
TenantIDs map[string][]string
AcknowledgeDanger bool
}
GrantScope is the project and tenant choice from the existing approval form.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves OAuth discovery and Streamable HTTP MCP on the engine router.
type Options ¶
type Options struct {
Config *models.Config
StorePath string
Authorize echo.MiddlewareFunc
Mint func(ctx context.Context, userID string, req *models.CreateAccessTokenRequest) (string, error)
System SystemAPI
Audit Auditor
Edition string
Now func() time.Time
}
Options wires the adapter to engine auth without a second permission model.
type RefreshRecord ¶
type RefreshRecord struct {
Hash string `json:"hash"`
ClientID string `json:"client_id"`
Resource string `json:"resource"`
UserID string `json:"user_id"`
InternalToken string `json:"internal_token,omitempty"`
Scope string `json:"scope"`
ExpiresAt time.Time `json:"expires_at"`
Used bool `json:"used"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the durable OAuth client, transaction, and credential record. It is not the process-local device-login map.
func (*Store) SaveAccess ¶
func (s *Store) SaveAccess(raw string, rec AccessRecord) error
func (*Store) SaveClient ¶
func (s *Store) SaveClient(rec ClientRecord) error
func (*Store) SaveRefresh ¶
func (s *Store) SaveRefresh(raw string, rec RefreshRecord) error
func (*Store) SaveRequest ¶
func (s *Store) SaveRequest(rec AuthRequest) error
func (*Store) TakeRefresh ¶
func (s *Store) TakeRefresh(raw string) (RefreshRecord, bool)
type SystemAPI ¶
type SystemAPI interface {
GraphQL(ctx context.Context, token, projectID, tenantID, query string, vars map[string]any) (json.RawMessage, error)
REST(ctx context.Context, token, method, path string, body []byte) (int, json.RawMessage, error)
}
SystemAPI executes an already-authorized system call inside the engine process.