firewallauth

package
v0.16.11 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 25 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 firewallauth provides bootstrap-bound identities shared by firewall APIs.

Index

Constants

This section is empty.

Variables

View Source
var ErrForbidden = errors.New("firewall grant required")
View Source
var ErrUnauthenticated = errors.New("firewall credential rejected")

Functions

func AllowOrigin

func AllowOrigin(r *http.Request, origin string) bool

AllowOrigin accepts only an exact bootstrap-configured first-party origin. It does not emit CORS headers or accept wildcard/subdomain matches.

func Digest

func Digest(v any) string

func OpenPersistent

func OpenPersistent(c Config, dir string, key ed25519.PrivateKey, rules []Protected) (*Authority, *Approvals, error)

OpenPersistent owns a private SQLite ledger for revocations and receipt replay. Signing secrets stay in memory. Each service process owns a separate authority.

func OpenShared

func OpenShared(ctx context.Context, c Config, db SharedDatabase, key ed25519.PrivateKey, rules []Protected) (*Authority, *Approvals, error)

func PinState

func PinState(ctx context.Context, db *sql.DB, scope Scope, enabled bool) error

PinState prevents a retained singleton database being rebound to another identity mode or resource scope. Credential rotation does not change the pin.

func Receipt

func Receipt(ctx context.Context) string

func Require

func Require(ctx context.Context, action Action, scope Scope) error

func WithPrincipal

func WithPrincipal(ctx context.Context, p Principal) context.Context

func WithReceipt

func WithReceipt(ctx context.Context, receipt string) context.Context

Types

type Action

type Action string
const (
	Read              Action = "read"
	Author            Action = "author"
	Evaluate          Action = "evaluate"
	Deploy            Action = "deploy"
	Rollback          Action = "rollback"
	Lease             Action = "lease"
	Audit             Action = "audit"
	Approve           Action = "approve"
	ManageCredentials Action = "manage-credentials"
	Prune             Action = "prune"
	Metrics           Action = "metrics"
)

func Operation

func Operation(op string) Action

type ApprovalRequest

type ApprovalRequest struct {
	Actor  string `json:"actor"`
	Action Action `json:"action"`
	Scope  Scope  `json:"scope"`
	Digest string `json:"digest"`
}

type Approvals

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

func NewApprovals

func NewApprovals(key ed25519.PrivateKey, store ReplayStore, protected []Protected) (*Approvals, error)

func (*Approvals) Check

func (a *Approvals) Check(ctx context.Context, action Action, scope Scope, digest, receipt string) error

func (*Approvals) CheckTargets

func (a *Approvals) CheckTargets(ctx context.Context, action Action, scope Scope, targets []string, digest, receipt string) error

Fleet receipts bind the complete target/CAS set through digest. A matching protected target requires approval over the enclosing tenant/app scope.

func (*Approvals) Issue

func (a *Approvals) Issue(ctx context.Context, r ApprovalRequest) (string, error)

type Authority

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

Authority is replaced atomically by trusted configuration reload. It has no token-directed discovery, token issuance, or remotely writable trust settings.

func New

func New(c Config) (*Authority, error)

func (*Authority) AddLifecycleTool

func (a *Authority) AddLifecycleTool(s *server.MCPServer)

func (*Authority) Authenticate

func (a *Authority) Authenticate(ctx context.Context, token string) (Principal, error)

func (*Authority) Close

func (a *Authority) Close() error

func (*Authority) LifecycleHandler

func (a *Authority) LifecycleHandler(origin string) http.Handler

LifecycleHandler never issues JWTs, changes issuer trust, or accepts tokens in a URL.

func (*Authority) PolicyFingerprint

func (a *Authority) PolicyFingerprint() string

func (*Authority) Reload

func (a *Authority) Reload(c Config) error

Reload revokes removed credentials and clears all JWKS caches. The caller must persist trusted configuration before invoking this method if restart durability is required.

func (*Authority) Request

func (a *Authority) Request(r *http.Request) (*http.Request, error)

func (*Authority) Revoke

func (a *Authority) Revoke(ctx context.Context, fingerprint string) error

func (*Authority) Shared

func (a *Authority) Shared() bool

type Config

type Config struct {
	Revocations Revocations
	Static      []Static
	Providers   []Provider
}

type Grant

type Grant struct {
	Scope   Scope    `json:"scope"`
	Actions []Action `json:"actions"`
}

Empty grant dimensions match only empty resource dimensions. Wildcards must be explicit. All dimensions and the action must match the SAME grant.

type Principal

type Principal struct {
	ID     string  `json:"id"`
	Grants []Grant `json:"grants"`
}

func FromContext

func FromContext(ctx context.Context) (Principal, bool)

func (Principal) Allows

func (p Principal) Allows(action Action, scope Scope) bool

func (Principal) BoundScope

func (p Principal) BoundScope(action Action, environment, target string) (Scope, error)

BoundScope is for workload APIs whose scope is never caller supplied. Refuse ambiguous or wildcard bindings instead of selecting a tenant by fallback.

type Protected

type Protected struct {
	Action Action `json:"action"`
	Scope  Scope  `json:"scope"`
}

type Provider

type Provider struct {
	Issuer      string               `json:"issuer"`
	Audience    string               `json:"audience"`
	JWKSURL     string               `json:"jwksURL"`
	Subjects    map[string]Principal `json:"subjects"`
	TTL         time.Duration        `json:"ttl"`
	MaxLifetime time.Duration        `json:"maxLifetime"`
	ClockSkew   time.Duration        `json:"clockSkew"`
	RevokedIDs  []string             `json:"revokedIDs"`
}

Provider binds an issuer's authenticated subjects to locally trusted grants. JWKSURL is pinned by the operator, never read from a token or discovery reply.

type ReplayStore

type ReplayStore interface {
	Consume(context.Context, string, time.Time) error
}

ReplayStore must atomically persist a unique receipt ID before returning. A failed operation may burn a receipt; it must never make a receipt reusable.

type Revocations

type Revocations interface {
	Revoked(context.Context, string) (bool, error)
	Revoke(context.Context, string) error
}

type SQLReplayStore

type SQLReplayStore struct{ DB *sql.DB }

SQLReplayStore uses an operator-owned SQLite database, not an in-memory map.

func NewSQLReplayStore

func NewSQLReplayStore(ctx context.Context, db *sql.DB) (*SQLReplayStore, error)

func (*SQLReplayStore) Consume

func (s *SQLReplayStore) Consume(ctx context.Context, id string, expiry time.Time) error

type SQLRevocations

type SQLRevocations struct{ DB *sql.DB }

SQLRevocations stores only credential fingerprints in operator-owned SQLite. Revocations are permanent; rotation/re-admission uses trusted configuration.

func NewSQLRevocations

func NewSQLRevocations(ctx context.Context, db *sql.DB) (*SQLRevocations, error)

func (*SQLRevocations) Revoke

func (s *SQLRevocations) Revoke(ctx context.Context, digest string) error

func (*SQLRevocations) Revoked

func (s *SQLRevocations) Revoked(ctx context.Context, digest string) (bool, error)

type SQLTransaction

type SQLTransaction interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
	QueryRowContext(context.Context, string, ...any) *sql.Row
	Clock(context.Context, int64) (int64, error)
}

type Scope

type Scope struct {
	Tenant      string `json:"tenant"`
	App         string `json:"app"`
	Environment string `json:"environment"`
	Target      string `json:"target"`
}

type SharedDatabase

type SharedDatabase interface {
	AuthNamespace() string
	AuthTransaction(context.Context, func(SQLTransaction) error) error
	Bootstrap(context.Context, string, []string) error
	Close() error
}

SharedDatabase is implemented by firewallstate.Database; the callback runs under its transaction-scoped namespace lock, including reads and capacity checks.

type Static

type Static struct {
	Token     string
	Principal Principal
}

Jump to

Keyboard shortcuts

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