auth

package
v0.0.0-...-b5da06d Latest Latest
Warning

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

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

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

Types

type Agent

type Agent struct {
	ID string
}

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

type Principal struct {
	User  User
	Agent Agent
}

Authn

type Resource

type Resource struct {
	Name string
	Type string
}

type Session

type Session interface {
	Principal() Principal
}

func AuthSessionFrom

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

type User

type User struct {
	ID    string
	Roles []string
}

type Verb

type Verb string
const (
	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