auth

package
v0.0.0-...-dd3f7a9 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: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthSessionTo

func AuthSessionTo(ctx context.Context, session Session) context.Context

func AuthnMiddleware

func AuthnMiddleware(authn AuthProvider) func(http.Handler) http.Handler

func ForwardCredential

func ForwardCredential(request *http.Request, session Session) error

ForwardCredential applies a caller's current credential to an authorized upstream request. Source-less internal calls carry no bearer token.

func PrincipalID

func PrincipalID(authority, subject string) string

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

func UpstreamMethodFrom(ctx context.Context) (string, bool)

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".

func UpstreamMethodTo

func UpstreamMethodTo(ctx context.Context, method string) context.Context

UpstreamMethodTo returns a copy of ctx that names the outgoing a2a-go method.

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) Check

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 Resource

type Resource struct {
	Type      string
	Namespace string
	Name      string
}

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 AuthSessionFrom

func AuthSessionFrom(ctx context.Context) (Session, bool)

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 {
	Token  string // the raw share token
	UserID string // owner's user ID — used for DB lookups

	// SessionID is the conversation this token grants access to.
	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

type TokenSource interface {
	Token(context.Context) (string, error)
}

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.

type Verb

type Verb string
const (
	VerbList   Verb = "list"
	VerbGet    Verb = "get"
	VerbCreate Verb = "create"
	VerbUpdate Verb = "update"
	VerbDelete Verb = "delete"
)

Jump to

Keyboard shortcuts

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