macula_realm_trust (macula v0.20.5)
View SourceRealm Trust Management for Hybrid Trust Model
Implements the Hybrid Trust Model (ADR-001) with three trust levels: - Level 1: Realm Authentication (API key/token validation) - Level 2: Certificate Trust (TOFU within authenticated realm) - Level 3: Optional CA-signed certificates for seed nodes
This module manages: - Realm authentication via API keys - Certificate fingerprint registration and verification - Trust On First Use (TOFU) pattern - Fingerprint change detection - Trust revocation
Summary
Functions
Authenticate to a realm using API key Returns a session map on success, error tuple on failure Implements rate limiting per realm
Extract SHA-256 fingerprint from certificate PEM
Get the current auth attempt count for a realm
Get fingerprint info for a node in a realm
Get all trusted peers in a realm
Initialize the rate limiter ETS table
Register a certificate fingerprint for a node in a realm
Reset the rate limit for a realm
Revoke trust for a node in a realm
Verify a certificate fingerprint for a node in a realm Implements Trust On First Use (TOFU) - first connection is automatically trusted
Types
Functions
Authenticate to a realm using API key Returns a session map on success, error tuple on failure Implements rate limiting per realm
-spec extract_fingerprint(binary()) -> {ok, fingerprint()} | {error, term()}.
Extract SHA-256 fingerprint from certificate PEM
-spec get_auth_attempt_count(realm()) -> {ok, non_neg_integer()}.
Get the current auth attempt count for a realm
Get fingerprint info for a node in a realm
Get all trusted peers in a realm
-spec init_rate_limiter() -> ok.
Initialize the rate limiter ETS table
-spec register_fingerprint(realm(), node_id(), fingerprint()) -> {ok, registered}.
Register a certificate fingerprint for a node in a realm
-spec reset_rate_limit(realm()) -> ok.
Reset the rate limit for a realm
Revoke trust for a node in a realm
-spec verify_fingerprint(realm(), node_id(), fingerprint()) -> {ok, trusted | trusted_first_use} | {error, {fingerprint_mismatch, #{expected := fingerprint(), received := fingerprint()}}}.
Verify a certificate fingerprint for a node in a realm Implements Trust On First Use (TOFU) - first connection is automatically trusted