auth

package
v0.7.44 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 10 Imported by: 0 modules, 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

View Source
const (
	KindNone    = "none"
	KindConsole = "console"
	KindKey     = "key"
)

Variables

This section is empty.

Functions

func ServeLoopback added in v0.6.0

func ServeLoopback(ln net.Listener, path, title string, callback func(context.Context, string) error)

ServeLoopback owns the HTTP transport on an already-bound loopback listener. Provider callbacks receive protocol input only; errors preserve the 400 contract.

func ServeLoopbackRoutes added in v0.7.35

func ServeLoopbackRoutes(ln net.Listener, routes []LoopbackRoute)

ServeLoopbackRoutes is ServeLoopback for a listener that answers more than one path. One listener can only be served once, so the routes share it.

func WithIdentity added in v0.2.21

func WithIdentity(ctx context.Context, identity Identity) context.Context

Types

type Identity added in v0.2.21

type Identity struct {
	Kind             string
	KeyID            string
	Name             string
	AllowedProviders []string
	// MaxInFlight caps concurrent /v1 chat requests for a named key. Zero
	// means unlimited. Console traffic is never capped.
	MaxInFlight int
}

func ConsoleIdentity added in v0.2.21

func ConsoleIdentity() Identity

func IdentityFrom added in v0.2.21

func IdentityFrom(ctx context.Context) (Identity, bool)

func KeyIdentity added in v0.2.21

func KeyIdentity(key accounts.APIKey) Identity

func (Identity) AllowsProvider added in v0.2.21

func (i Identity) AllowsProvider(provider string) bool

AllowsProvider answers the family-level grant question. The helpers live on accounts (Pool wrappers around grants.go) so this package does not import grant parsing and accounts does not import auth.

func (Identity) AllowsProviderRegion added in v0.5.1

func (i Identity) AllowsProviderRegion(provider, region string) bool

AllowsProviderRegion reports whether a concrete account — family plus region — is covered by the key allowlist. This is the fail-closed gate for routing candidates; AllowsProvider only answers the family-level question.

func (Identity) Console added in v0.2.21

func (i Identity) Console() bool

type KeyLookup added in v0.2.21

type KeyLookup interface {
	LookupAPIKey(context.Context, string) (accounts.APIKey, bool, error)
}

type LoopbackRoute added in v0.7.35

type LoopbackRoute struct {
	Path     string
	Title    string
	Callback func(context.Context, string) error
}

LoopbackRoute is one path a loopback listener accepts. A provider that gets two redirects on the same port (Kiro's Microsoft sign-in does) registers both here instead of building its own server.

type Verifier added in v0.2.1

type Verifier struct {
	// contains filtered or unexported fields
}

func NewVerifier added in v0.2.1

func NewVerifier(consoleKey string, keys KeyLookup) Verifier

func (Verifier) Authenticate added in v0.2.21

func (v Verifier) Authenticate(ctx context.Context, r *http.Request) (Identity, bool)

func (Verifier) ConsoleKey added in v0.6.0

func (v Verifier) ConsoleKey() string

ConsoleKey reads the shared live key. Copies of Verifier share this state.

func (Verifier) SetConsoleKey added in v0.6.0

func (v Verifier) SetConsoleKey(secret string)

SetConsoleKey rotates a verifier created by NewVerifier without replacing the verifier copies already held by HTTP handlers.

Jump to

Keyboard shortcuts

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