Documentation
¶
Overview ¶
Package firewallauth provides bootstrap-bound identities shared by firewall APIs.
Index ¶
- Variables
- func AllowOrigin(r *http.Request, origin string) bool
- func Digest(v any) string
- func OpenPersistent(c Config, dir string, key ed25519.PrivateKey, rules []Protected) (*Authority, *Approvals, error)
- func OpenShared(ctx context.Context, c Config, db SharedDatabase, key ed25519.PrivateKey, ...) (*Authority, *Approvals, error)
- func PinState(ctx context.Context, db *sql.DB, scope Scope, enabled bool) error
- func Receipt(ctx context.Context) string
- func Require(ctx context.Context, action Action, scope Scope) error
- func WithPrincipal(ctx context.Context, p Principal) context.Context
- func WithReceipt(ctx context.Context, receipt string) context.Context
- type Action
- type ApprovalRequest
- type Approvals
- type Authority
- func (a *Authority) AddLifecycleTool(s *server.MCPServer)
- func (a *Authority) Authenticate(ctx context.Context, token string) (Principal, error)
- func (a *Authority) Close() error
- func (a *Authority) LifecycleHandler(origin string) http.Handler
- func (a *Authority) PolicyFingerprint() string
- func (a *Authority) Reload(c Config) error
- func (a *Authority) Request(r *http.Request) (*http.Request, error)
- func (a *Authority) Revoke(ctx context.Context, fingerprint string) error
- func (a *Authority) Shared() bool
- type Config
- type Grant
- type Principal
- type Protected
- type Provider
- type ReplayStore
- type Revocations
- type SQLReplayStore
- type SQLRevocations
- type SQLTransaction
- type Scope
- type SharedDatabase
- type Static
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = errors.New("firewall grant required")
var ErrUnauthenticated = errors.New("firewall credential rejected")
Functions ¶
func AllowOrigin ¶
AllowOrigin accepts only an exact bootstrap-configured first-party origin. It does not emit CORS headers or accept wildcard/subdomain matches.
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)
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" )
type ApprovalRequest ¶
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) 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.
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 (*Authority) AddLifecycleTool ¶
func (*Authority) Authenticate ¶
func (*Authority) LifecycleHandler ¶
LifecycleHandler never issues JWTs, changes issuer trust, or accepts tokens in a URL.
func (*Authority) PolicyFingerprint ¶
func (*Authority) Reload ¶
Reload revokes removed credentials and clears all JWKS caches. The caller must persist trusted configuration before invoking this method if restart durability is required.
type Config ¶
type Config struct {
Revocations Revocations
Static []Static
Providers []Provider
}
type Grant ¶
Empty grant dimensions match only empty resource dimensions. Wildcards must be explicit. All dimensions and the action must match the SAME grant.
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 ¶
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 SQLReplayStore ¶
SQLReplayStore uses an operator-owned SQLite database, not an in-memory map.
func NewSQLReplayStore ¶
type SQLRevocations ¶
SQLRevocations stores only credential fingerprints in operator-owned SQLite. Revocations are permanent; rotation/re-admission uses trusted configuration.
func NewSQLRevocations ¶
type SQLTransaction ¶
type SharedDatabase ¶
type SharedDatabase interface {
}
SharedDatabase is implemented by firewallstate.Database; the callback runs under its transaction-scoped namespace lock, including reads and capacity checks.