Documentation
¶
Index ¶
- func AuthSessionTo(ctx context.Context, session Session) context.Context
- func AuthnMiddleware(authn AuthProvider) func(http.Handler) http.Handler
- 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 Agent
- type AuthProvider
- type Authorizer
- type CollectionAuthorizer
- type ControlPlaneSession
- type NoopAuthorizer
- type Principal
- type Resource
- type Session
- type ShareContext
- type User
- 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 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 skips authentication. AccessRuntime requires the separate workload authenticator; the remaining modes use public identity.
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)
// add auth to upstream requests of a session for upstream service account.
// For A2A calls, UpstreamMethodFrom(r.Context()) names the outgoing method.
UpstreamAuth(r *http.Request, session Session, upstreamPrincipal Principal) 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 {
User User
Agent Agent
Claims map[string]any // Raw JWT claims (nil for non-JWT auth)
}
Authn
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.