credentialbroker

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package credentialbroker defines metadata-only credential management and the private gateway resolution contract. Secret values are never management data.

Index

Constants

View Source
const (
	Audience       = "mcp-runtime-credential-broker"
	ResolvePath    = "/api/v1/credential-resolutions"
	ManagementPath = "/api/v1/credentials"
	HeaderPrefix   = "X-Mcp-Credential-"
	MaxValueBytes  = 64 << 10
)

Variables

View Source
var (
	ErrDenied      = errors.New("credential access denied")
	ErrUnavailable = errors.New("credential provider unavailable")
	ErrConflict    = errors.New("credential revision conflict")
	// ErrTokenRejected marks a definite workload-token rejection (not a transient
	// TokenReview/API failure).
	ErrTokenRejected = errors.New("workload token rejected")
	ErrNotFound      = errors.New("credential metadata not found")
)
View Source
var ErrProviderNotSupported = errors.New("credential provider is not yet supported; only the kubernetes provider is available")

ErrProviderNotSupported is returned for provider kinds that are recognised but not enabled. Only the Kubernetes Secret provider is supported today.

Functions

func LocalUpstream

func LocalUpstream(raw string, expectedPort int) bool

LocalUpstream prevents credential-enabled gateways from delivering a secret to an arbitrary configured network destination. Plain HTTP is confined to the server process in the same Pod's loopback network namespace.

func NameValid

func NameValid(s string) bool

func ProviderSupported

func ProviderSupported(kind string) bool

ProviderSupported reports whether a provider kind is enabled. It is the one gate for source validation and for the reader Registry. To enable another provider later: add its kind here, keep its reference validation in validateReference, and register its Provider (reader) in the platform API.

func StripHeaders

func StripHeaders(h http.Header)

func ValidValue

func ValidValue(value []byte) bool

Types

type Binding

type Binding struct {
	Namespace string   `json:"namespace"`
	Name      string   `json:"name"`
	Source    string   `json:"source"`
	Server    string   `json:"server"`
	ServerUID string   `json:"server_uid"`
	Tools     []string `json:"tools"`
	HumanID   string   `json:"human_id"`
	AgentID   string   `json:"agent_id"`
	TeamID    string   `json:"team_id"`
	SessionID string   `json:"session_id,omitempty"`
	Header    string   `json:"header"`
	Disabled  bool     `json:"disabled,omitempty"`
	Revision  int64    `json:"revision"`
}

Binding narrows a source to one immutable workload and explicit tools and subjects. HumanID and AgentID are mandatory; TeamID binds directory authority.

func (Binding) Matches

func (b Binding) Matches(human, agent, team, session, tool string) bool

func (Binding) Validate

func (b Binding) Validate() error

type Delivery

type Delivery struct {
	Headers map[string]string `json:"headers"`
}

Delivery is PRIVATE: only the server-authenticated resolution endpoint may serialize it. Values have no String method and must never be logged.

type Provider

type Provider interface {
	Read(context.Context, Source) (Value, error)
}

type Registry

type Registry map[string]Provider

Registry maps a provider kind to the Provider (reader) the broker resolves source references through. Only supported kinds can be registered, and Reader never returns a reader for an unsupported kind.

func (Registry) Reader

func (r Registry) Reader(kind string) Provider

Reader returns the reader for kind, or nil when none is enabled.

func (Registry) Register

func (r Registry) Register(kind string, reader Provider) error

Register adds a reader for an enabled provider kind.

type ResolutionRequest

type ResolutionRequest struct {
	Session  string   `json:"session"` // canonical namespace/name from verified adapter identity
	Tool     string   `json:"tool"`
	Bindings []string `json:"bindings"`
}

type Source

type Source struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
	Provider  string `json:"provider"`
	Resource  string `json:"resource"`
	Key       string `json:"key,omitempty"`
	Version   string `json:"version,omitempty"`
	UserID    string `json:"user_id,omitempty"`
	TeamID    string `json:"team_id,omitempty"`
	Disabled  bool   `json:"disabled,omitempty"`
	Revision  int64  `json:"revision"`
}

Source is an administrator-approved exact backing reference. No provider token, password, credential payload or arbitrary endpoint belongs here.

func (Source) Allows

func (s Source) Allows(human, team string) bool

func (Source) Validate

func (s Source) Validate() error

type Value

type Value struct {
	Bytes   []byte
	Version string
}

Jump to

Keyboard shortcuts

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