Documentation
¶
Index ¶
- func AuthSessionTo(ctx context.Context, session Session) context.Context
- func AuthnMiddleware(authn AuthProvider) func(http.Handler) http.Handler
- func ForwardCredential(request *http.Request, session Session) error
- func PrincipalID(authority, subject string) string
- func ShareContextTo(ctx context.Context, sc *ShareContext) context.Context
- func UpstreamMethodFrom(ctx context.Context) (string, bool)
- func UpstreamMethodTo(ctx context.Context, method string) context.Context
- type AccessMode
- type AuthProvider
- type Authorizer
- type CollectionAuthorizer
- type ControlPlaneSession
- type NoopAuthorizer
- type Principal
- type Resource
- type RuntimeBinding
- type Session
- type ShareContext
- type TokenSource
- type Verb
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthnMiddleware ¶
func AuthnMiddleware(authn AuthProvider) func(http.Handler) http.Handler
func ForwardCredential ¶
ForwardCredential applies a caller's current credential to an authorized upstream request. Source-less internal calls carry no bearer token.
func PrincipalID ¶
PrincipalID namespaces a provider's subject without exposing its syntax to consumers. Authorities identify authentication sources, not rotating keys.
func ShareContextTo ¶
func ShareContextTo(ctx context.Context, sc *ShareContext) context.Context
ShareContextTo returns a copy of ctx with sc stored as the share context.
func UpstreamMethodFrom ¶
UpstreamMethodFrom returns the outgoing a2a-go method, such as "SendMessage", or false outside an A2A call. A retried streaming send that was already accepted goes out as "SubscribeToTask".
Types ¶
type AccessMode ¶
type AccessMode string
AccessMode is what a gRPC method requires of its caller.
It lives here rather than beside the server because a library consumer registering its own services has to name these, and the server package is internal. AccessPublic permits anonymous calls. AccessRuntime requires a verified actor; other modes accept either identity and authorize in services.
const ( AccessPublic AccessMode = "public" AccessRuntime AccessMode = "runtime" AccessRead AccessMode = "read" AccessCreate AccessMode = "create" AccessUpdate AccessMode = "update" AccessDelete AccessMode = "delete" )
type AuthProvider ¶
type AuthProvider interface {
Authenticate(ctx context.Context, reqHeaders http.Header, query url.Values) (Session, error)
// UpstreamAuth authenticates an authorized upstream request as this caller.
// destinationSessionID identifies the target conversation; it is empty for
// upstreams without a Session, such as sandbox guest APIs.
// For A2A calls, UpstreamMethodFrom(r.Context()) names the outgoing method.
UpstreamAuth(r *http.Request, session Session, destinationSessionID string) error
}
Responsibilities: - Authenticate:
- a2a requests from ui/cli (human users)
- api requests from users/agents
- Forward auth credentials to upstream agents
type Authorizer ¶
type Authorizer interface {
Check(ctx context.Context, principal Principal, verb Verb, resource Resource) error
}
Authz
type CollectionAuthorizer ¶
type CollectionAuthorizer interface {
Authorizer
Scope(ctx context.Context, principal Principal, verb Verb, resourceType string) (authorization.AuthorizationScope, error)
}
type ControlPlaneSession ¶
type ControlPlaneSession struct{}
ControlPlaneSession identifies an internal controller call without human credentials. It does not assert a Substrate Actor identity. AuthProvider and Authorizer implementations may explicitly allow, deny, or authenticate these calls; actor credentials for runtime tool calls remain a separate concern.
func (ControlPlaneSession) Principal ¶
func (ControlPlaneSession) Principal() Principal
type NoopAuthorizer ¶
type NoopAuthorizer struct{}
NoopAuthorizer permits every action and collection entry.
func (NoopAuthorizer) Scope ¶
func (NoopAuthorizer) Scope(context.Context, Principal, Verb, string) (authorization.AuthorizationScope, error)
type Principal ¶
type Principal struct {
// ID is an opaque, provider-normalized identity, independent of credentials.
ID string
RuntimeBinding *RuntimeBinding
Claims map[string]any // Authenticated provider attributes, such as JWT claims.
}
Principal describes the authenticated caller, independently of the request's destination. RuntimeBinding is present only for a verified runtime caller.
type RuntimeBinding ¶
type RuntimeBinding struct {
SessionID string
// CreatorID selects the Session's data partition, never the caller's authority.
CreatorID string
}
RuntimeBinding identifies a verified runtime caller and its immutable Session binding. Caller-supplied agent headers never establish an Actor identity.
type Session ¶
type Session interface {
Principal() Principal
}
func NewCredentialSession ¶
func NewCredentialSession(principal Principal, source TokenSource) Session
NewCredentialSession binds a verified principal to its renewable credential. The authenticator is responsible for ensuring the source retains this identity.
type ShareContext ¶
type ShareContext struct {
SessionID string
}
ShareContext grants read-only access from a validated X-Share-Token header.
func ShareContextFrom ¶
func ShareContextFrom(ctx context.Context) (*ShareContext, bool)
ShareContextFrom returns the ShareContext stored in ctx, if any.
func (*ShareContext) IsForSession ¶
func (s *ShareContext) IsForSession(sessionID string) bool
IsForSession reports whether this share grants access to the named session.
type TokenSource ¶
TokenSource supplies the current bearer credential. An empty token means the authentication mechanism has no bearer credential; failures never select a different source. Implementations must not expose credentials through errors.