auth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: AGPL-3.0 Imports: 3 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

Overview

Package auth defines the relay's pluggable authorization seam. v1 ships a single implementation — OpenAuthorizer, which admits every pair unconditionally — but every connection already flows through this interface and every hello already carries a (currently-empty) Token field (spec/PROTOCOL.md §3, §9), so a future subscription-gated implementation is a new file and a config switch, not a protocol change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	Authorize(ctx context.Context, pair [16]byte, meta ConnMeta) (Grant, error)
}

Authorizer decides whether a connection may proceed and under what limits. Errors from Authorize are treated as a hard rejection — the caller closes the connection with code 4503 (capacity) or an implementation-specific code; Authorize itself does not touch the network.

type ConnMeta

type ConnMeta struct {
	Role      Role
	RemoteIP  netip.Addr
	UserAgent string
	Token     string // from hello.token; "" in v1 — see spec §9
	Version   int
}

ConnMeta is everything about a connection attempt an Authorizer might want to base a decision on.

type Grant

type Grant struct {
	MaxBytesPerSec int64
	MaxFrameBytes  int
	MaxSessionDur  time.Duration
	Tier           string // "open" in v1; becomes a metrics label once tiers exist
}

Grant is what an Authorizer hands back: the limits this connection operates under. OpenAuthorizer returns the same Grant for everyone; threading it through Pair/Conn from day one (rather than adding the plumbing later) is what makes a future tiered authorizer a drop-in replacement.

type OpenAuthorizer

type OpenAuthorizer struct {
	Default Grant
}

OpenAuthorizer is the v1 authorizer: every pair is admitted, every connection gets Default.

func (OpenAuthorizer) Authorize

func (a OpenAuthorizer) Authorize(_ context.Context, _ [16]byte, _ ConnMeta) (Grant, error)

type Role

type Role string

Role mirrors wire.Role without importing the wire package, keeping auth dependency-free (it's the seam other packages depend on, not the other way around).

const (
	RoleAgent  Role = "agent"
	RoleClient Role = "client"
)

Jump to

Keyboard shortcuts

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