Documentation
¶
Overview ¶
Package auth hosts offline identities and signs metadata-approved object grants without owning namespace, placement or a metadata write lease.
Index ¶
- Constants
- func ReplicaRestoreExactGeneration(ctx context.Context, r io.Reader, path string, identity cluster.Config) error
- func Restore(ctx context.Context, r io.Reader, path string, identity cluster.Config) error
- func SnapshotFile(ctx context.Context, path string, w io.Writer) error
- type CheckpointInfo
- type Client
- func (c *Client) Catalog(ctx context.Context) ([]NamespacePolicy, error)
- func (c *Client) Close() error
- func (c *Client) CreateKey(ctx context.Context, q KeyRequest) (CreatedCredential, error)
- func (c *Client) CreateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)
- func (c *Client) DeleteKey(ctx context.Context, ak string) error
- func (c *Client) DisableKey(ctx context.Context, ak string) error
- func (c *Client) DisableNamespace(ctx context.Context, id string) error
- func (c *Client) Issue(ctx context.Context, principal string, grant cluster.Grant) (cluster.Credentials, error)
- func (c *Client) ListKeys(ctx context.Context, id string) ([]CredentialInfo, error)
- func (c *Client) Lookup(accessKeyID, securityToken string) (cluster.Identity, error)
- func (c *Client) Revocations(ctx context.Context, since uint64) ([]Revocation, error)
- func (c *Client) RotateKey(ctx context.Context, ak string) (CreatedCredential, error)
- func (c *Client) UpdateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)
- type ClientConfig
- type CommitFunc
- type Config
- type CreatedCredential
- type CredentialInfo
- type IssueRequest
- type KeyRequest
- type LookupRequest
- type NamespacePolicy
- type RecoveryInfo
- type Revocation
- type Server
- func (s *Server) AppliedSequence(ctx context.Context) (uint64, error)
- func (s *Server) Apply(ctx context.Context, seq uint64, payload []byte) error
- func (s *Server) Catalog(ctx context.Context) ([]NamespacePolicy, error)
- func (s *Server) Close(ctx context.Context) error
- func (s *Server) CreateKey(ctx context.Context, q KeyRequest) (CreatedCredential, error)
- func (s *Server) CreateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)
- func (s *Server) DeleteKey(ctx context.Context, ak string) error
- func (s *Server) DisableKey(ctx context.Context, ak string) error
- func (s *Server) DisableNamespace(ctx context.Context, id string) error
- func (s *Server) Drain(ctx context.Context) error
- func (s *Server) Issue(ctx context.Context, origin string, grant cluster.Grant) (cluster.Credentials, error)
- func (s *Server) ListKeys(ctx context.Context, namespaceID string) ([]CredentialInfo, error)
- func (s *Server) Lookup(accessKeyID, securityToken string) (cluster.Identity, error)
- func (s *Server) ReplicationDigest(ctx context.Context) (string, error)
- func (s *Server) ReplicationSeed(ctx context.Context) ([]byte, error)
- func (s *Server) Revocations(ctx context.Context, since uint64) ([]Revocation, error)
- func (s *Server) RotateKey(ctx context.Context, ak string) (CreatedCredential, error)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetCommitter(commit CommitFunc)
- func (s *Server) Snapshot(ctx context.Context, w io.Writer) error
- func (s *Server) UpdateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)
Constants ¶
const ( NodeID = "auth" ControlPath = "/v1/auth/control" )
const RevocationPageSize = 1024
Variables ¶
This section is empty.
Functions ¶
func ReplicaRestoreExactGeneration ¶
func ReplicaRestoreExactGeneration(ctx context.Context, r io.Reader, path string, identity cluster.Config) error
ReplicaRestoreExactGeneration bootstraps a fresh, fenced standby at exactly the snapshot generation. It must not be used as disaster promotion: the caller must keep the new replica fenced until normal authority replay/registration.
func Restore ¶
Restore creates a new database without replacing any existing target. Disaster recovery must use a strictly newer epoch and a different incarnation; the generation in an old backup can never be activated directly by this API. Every restored client/reader AK is permanently retired: a backup cannot know which users were revoked after its capture. Administrators must create new user AKs. Service/admin credentials are retained for control-plane recovery and require a separate trusted revocation audit and subsequent rotation.
func SnapshotFile ¶
SnapshotFile exclusively opens an offline identity database. It neither seeds JSON identities nor changes authority generation. A running Auth owns the exclusive lock, so an operator must stop it before using this helper.
Types ¶
type CheckpointInfo ¶
CheckpointInfo describes secret-bearing offline replica material without exposing stored SKs. Digest is only for authenticated replica comparisons.
func InspectCheckpoint ¶
func InspectCheckpoint(ctx context.Context, path string, identity cluster.Config) (CheckpointInfo, error)
InspectCheckpoint validates a stopped database without creating, seeding or changing it. It requires the exact signing generation; ordinary NewServer intentionally permits explicit generation advancement and is not an inspector.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client owns one lazily established RPC connection. Calls share that connection concurrently; failures never replay a token issue automatically.
func NewClient ¶
func NewClient(cfg ClientConfig) (*Client, error)
func (*Client) Close ¶
Close cancels pending calls and dialing, closes the shared connection and waits until all callers have relinquished it. It is safe to call concurrently.
func (*Client) CreateKey ¶
func (c *Client) CreateKey(ctx context.Context, q KeyRequest) (CreatedCredential, error)
func (*Client) CreateNamespace ¶
func (c *Client) CreateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)
func (*Client) DisableNamespace ¶
func (*Client) Lookup ¶
Lookup is a bounded remote identity lookup for an RPC Authenticator. It accepts long-term identities only and does not treat temporary tokens as keys.
func (*Client) Revocations ¶
func (*Client) UpdateNamespace ¶
func (c *Client) UpdateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)
type ClientConfig ¶
type CommitFunc ¶
CommitFunc reserves a global sequence, prepares under that reservation and confirms only after Apply persisted the mutation on every required replica.
type Config ¶
type Config struct {
Identity cluster.Config
StatePath string
Gate func(context.Context) error
Other cluster.RPCHandler
// ReplicaKeys authenticate only physical consensus peers. These fixed
// bootstrap keys cannot call ordinary identity, signing or admin methods.
ReplicaKeys map[string]cluster.Identity
}
Config requires a role-scoped Auth identity and a persistent state path. StatePath is a bbolt file held exclusively until Server.Close succeeds.
type CreatedCredential ¶
type CreatedCredential struct {
CredentialInfo
SecretAccessKey string `json:"secret_access_key"`
}
type CredentialInfo ¶
type CredentialInfo struct {
AccessKeyID string `json:"access_key_id"`
Principal string `json:"principal"`
NamespaceID string `json:"namespace_id"`
Roles []string `json:"roles"`
Expires time.Time `json:"expires,omitempty"`
Disabled bool `json:"disabled"`
// Retired permanently disables a user AK after disaster recovery. Its
// audit record survives, while the stored SK is erased and never reissued.
Retired bool `json:"retired,omitempty"`
Revision uint64 `json:"revision"`
}
CredentialInfo deliberately excludes every stored secret.
type IssueRequest ¶
type IssueRequest struct {
Principal string `json:"principal"`
Grant cluster.Grant `json:"grant"`
Epoch uint64 `json:"epoch"`
Incarnation string `json:"incarnation"`
}
IssueRequest binds every issue call to the exact authority generation with which the requesting Meta was started. It cannot advance the Auth generation.
type KeyRequest ¶
type LookupRequest ¶
type NamespacePolicy ¶
type NamespacePolicy struct {
Name string `json:"name"`
ID string `json:"id"`
QuotaBytes int64 `json:"quota_bytes"`
CacheBytes int64 `json:"cache_bytes"`
ReadCacheBytes int64 `json:"read_cache_bytes"`
Workers int `json:"workers"`
Weight int `json:"weight"`
MaxInflight int `json:"max_inflight"`
Disabled bool `json:"disabled"`
Revision uint64 `json:"revision"`
}
NamespacePolicy is the authoritative account catalog. IDs never change when display names or resource policy change. Zero resource values mean defaults.
type RecoveryInfo ¶
type RecoveryInfo struct {
SourceSequence uint64 `json:"source_sequence"`
RetiredUsers int `json:"retired_users"`
}
RecoveryInfo is a nonsecret audit of the most recent disaster restore. The native marker starts at zero in the new generation; SourceSequence retains the input database's native position without permitting old WAL reuse.
func ReadRecoveryInfo ¶
func ReadRecoveryInfo(ctx context.Context, path string) (RecoveryInfo, error)
type Revocation ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns RPC connections and its exclusive authority-generation store. The caller owns the enclosing HTTP server and listener.
func (*Server) AppliedSequence ¶
func (*Server) Apply ¶
Apply is deterministic and idempotent. It never invokes the committer. The published snapshot is constructed within the transaction and stored only after bbolt commits, so persistence failure cannot change authentication.
func (*Server) Close ¶
Close cancels and joins RPC calls before releasing the state file. A timed out RPC close keeps the database owned so callers may retry with a new ctx.
func (*Server) CreateKey ¶
func (s *Server) CreateKey(ctx context.Context, q KeyRequest) (CreatedCredential, error)
func (*Server) CreateNamespace ¶
func (s *Server) CreateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)
func (*Server) DisableNamespace ¶
func (*Server) Drain ¶
Drain cancels and joins the RPC layer while retaining database ownership. Consensus owners stop background Apply after Drain and before Close.
func (*Server) ReplicationDigest ¶
ReplicationDigest compares logical state rather than bbolt pages or Gob map byte order. It includes bootstrap secrets, catalog, generation, revocations and native watermarks, so equal empty WALs cannot hide different seeds. The digest must only be exchanged over an authenticated physical peer link.
func (*Server) ReplicationSeed ¶
ReplicationSeed captures complete account state for the first consensus log entry. The coordinator must commit it only to an empty log; existing logs retain their original seed, including strict-recovery retirement tombstones. SourceSequence is checked on Apply: an existing nonzero native history must be migrated explicitly instead of being silently renumbered into a fresh group.
func (*Server) Revocations ¶
Revocations returns one bounded page. Continue from the last Sequence until an empty page; the feed includes tombstones and namespace transitions.
func (*Server) SetCommitter ¶
func (s *Server) SetCommitter(commit CommitFunc)
func (*Server) Snapshot ¶
Snapshot streams a consistent database image including secrets, tombstones, revocations and the applied sequence. The caller owns and protects the writer. A checksum detects accidental damage; this is not an untrusted import format.
func (*Server) UpdateNamespace ¶
func (s *Server) UpdateNamespace(ctx context.Context, p NamespacePolicy) (NamespacePolicy, error)