foundation capa

foundation-license

Capability-based license enforcement

Capability-based license enforcement

Tierfoundation
Roleunclassified (baselined)
Pathcrates/foundation/license
Edition2021
Targetsfoundation_license
Public items125 across 12 modules
Tests43

What it is for

# foundation-license

Capability-based license enforcement library crate for Rust applications.

This crate provides a server-side license enforcement system that:

Architecture

License enforcement follows a layered approach:

1. Service Layer (Primary) - Every privileged operation calls enforce_capability() 2. API Layer (Secondary) - Axum middleware gates entire route trees 3. Admin UI (Tertiary) - UI reflects license state but does not enforce

The server is always authoritative. UI gating is convenience only.

Quick Start

use foundation_license::{initialize_license, enforce_capability, LICENSE_PUBLIC_KEY};

// Initialize at startup (once)
initialize_license("license.json", &LICENSE_PUBLIC_KEY, None);

// Enforce in service methods
pub async fn create_document(input: Input) -> Result<Document, Error> {
enforce_capability("module:documents", Some(&user_id))?;
// ... proceed with operation
}

License File Format

Licenses are JSON files containing a base64-encoded payload and signature:

{
"payload": "base64-encoded-json-payload",
"signature": "base64-encoded-ed25519-signature",
"version": 1
}

Capabilities

Capabilities follow a namespace:name pattern:

Error Handling

All errors include:

Security Notes

Capabilities

CapabilityCheckResponse

License status API

Item
pub struct CapabilityCheckResponse
CapabilityCheckResponse :: fn check(capability : & str) -> Self

LicenseStatusResponse

License status API

Item
pub struct LicenseStatusResponse
LicenseStatusResponse :: fn from_current_state() -> Self

LimitSummary

License status API

Item
pub struct LimitSummary

api::handlers (other)

Axum handlers for license API endpoints.

Item
async fn get_license_status() -> Json <LicenseStatusResponse>
async fn check_capability(Path(capability) : Path <String>,) ->(StatusCode, Json <CapabilityCheckResponse>)

audit (other)

License audit event types

Item
fn audit_license_loaded(status : LicenseStatus)
fn audit_capability_denied(capability : & str, status : LicenseStatus, actor : Option <& str>)
fn audit_capability_granted(capability : & str, status : LicenseStatus, actor : Option <& str>)
fn audit_limit_exceeded(limit_name : & str, current : u64, maximum : u64, status : LicenseStatus, actor : Option <& str>,)

AuditOutcome

License audit event types

Item
pub enum AuditOutcome

LicenseAuditEntry

License audit event types

Item
pub struct LicenseAuditEntry
LicenseAuditEntry :: fn new(event : LicenseAuditEvent, status : LicenseStatus, outcome : AuditOutcome) -> Self
LicenseAuditEntry :: fn with_actor(mut self, actor : impl Into <String>) -> Self
LicenseAuditEntry :: fn with_capability(mut self, capability : impl Into <String>) -> Self
LicenseAuditEntry :: fn with_context(mut self, context : serde_json::Value) -> Self
LicenseAuditEntry :: fn emit(self)

LicenseAuditEvent

License audit event types

Item
pub enum LicenseAuditEvent

enforcement (other)

License enforcement mechanisms

Item
fn enforce_capability(capability : & str, actor : Option <& str>) -> LicenseResult <()>
fn enforce_limit(limit_name : & str, current_value : u64, actor : Option <& str>,) -> LicenseResult <()>
fn has_capability(capability : & str) -> bool
fn license_status() -> LicenseStatus
fn is_licensed() -> bool

CapabilityGuard

License enforcement mechanisms

Item
pub struct CapabilityGuard
CapabilityGuard :: fn acquire(capability : & str, actor : Option <& str>) -> LicenseResult <Self>
CapabilityGuard :: fn capability(& self) -> & str

EnforcementDenial

License enforcement mechanisms

Item
pub struct EnforcementDenial
EnforcementDenial :: fn from(error : & LicenseError) -> Self

LicenseError

License error types

Item
pub enum LicenseError
LicenseError :: fn error_code(& self) -> & 'static str
LicenseError :: fn required_capability(& self) -> Option <& str>
LicenseError :: fn license_status(& self) -> LicenseStatus
LicenseError :: fn user_message(& self) -> & str

LicenseResult

License error types

Item
pub type LicenseResult<T>: Result <T, LicenseError>

hardware (other)

Hardware node-locking + grace-then-fail entitlement (ADR 0018).

Item
pub const ACCEPT_THRESHOLD: u32
fn match_hardware(licensed : & HardwareBinding, observed : & BTreeMap <String, String>,) -> HardwareMatch

AccessMode

Hardware node-locking + grace-then-fail entitlement (ADR 0018).

Item
pub enum AccessMode

Entitlement

Hardware node-locking + grace-then-fail entitlement (ADR 0018).

Item
pub struct Entitlement
Entitlement :: fn emergency(reason : impl Into <String>) -> Self
fn evaluate(payload : & LicensePayload, signature_valid : bool, observed : Option <& BTreeMap <String, String>>, now : DateTime <Utc>, hardware_grace_until : Option <DateTime <Utc>>,) -> Entitlement

HardwareBinding

Hardware node-locking + grace-then-fail entitlement (ADR 0018).

Item
pub struct HardwareBinding

HardwareMatch

Hardware node-locking + grace-then-fail entitlement (ADR 0018).

Item
pub struct HardwareMatch

middleware (other)

Axum middleware for license enforcement

Item
async fn require_valid_license(request : Request, next : Next) -> Response
fn require_capability_middleware(capability : & 'static str,) -> impl Fn(Request, Next) -> std::pin::Pin <Box <dyn std::future::Future <Output = Response> + Send>> + Clone + Send + 'static

LicenseErrorResponse

Axum middleware for license enforcement

Item
pub struct LicenseErrorResponse
LicenseErrorResponse :: fn into_response(self) -> Response
LicenseErrorResponse :: fn from(error : LicenseError) -> Self

LicenseRouterExt

Axum middleware for license enforcement

Item
pub trait LicenseRouterExt

RequireCapability

Axum middleware for license enforcement

Item
pub struct RequireCapability
RequireCapability :: async fn from_request_parts(_parts : & mut axum::http::request::Parts, _state : & S,) -> Result <Self, Self::Rejection>

axum::Router<S>

Axum middleware for license enforcement

Item
axum::Router<S> :: fn require_license(self) -> Self
axum::Router<S> :: fn require_capability(self, capability : & 'static str) -> Self

LicenseState:LicenseState

License state management

Item
pub struct LicenseState

LicenseState:check

License state management

Item
LicenseState :: fn check_limit(& self, name : & str, current : u64) -> LicenseResult <()>

LicenseState:create

License state management

Item
fn create_test_state(payload : LicensePayload) -> LicenseState

LicenseState:customer

License state management

Item
LicenseState :: fn customer_id(& self) -> Option <& str>

LicenseState:enabled

License state management

Item
LicenseState :: fn enabled_modules(& self) -> Vec <& str>
LicenseState :: fn enabled_features(& self) -> Vec <& str>

LicenseState:expires

License state management

Item
LicenseState :: fn expires_at(& self) -> Option <DateTime <Utc>>

LicenseState:get

License state management

Item
fn get_license() -> & 'static LicenseState

LicenseState:has

License state management

Item
LicenseState :: fn has_capability(& self, cap : & str) -> bool

LicenseState:initialize

License state management

Item
fn initialize_license(path : impl AsRef <Path>, public_key : & u8; 32, environment : Option <& str>,) -> & 'static LicenseState

LicenseState:is

License state management

Item
LicenseState :: fn is_valid(& self) -> bool

LicenseState:license

License state management

Item
LicenseState :: fn license_id(& self) -> Option <uuid::Uuid>

LicenseState:limit

License state management

Item
LicenseState :: fn limit(& self, name : & str) -> Option <u64>

LicenseState:limits

License state management

Item
LicenseState :: fn limits(& self) -> std::collections::HashMap <String, u64>

LicenseState:loaded

License state management

Item
LicenseState :: fn loaded_at(& self) -> DateTime <Utc>

LicenseState:require

License state management

Item
LicenseState :: fn require(& self, cap : & str) -> LicenseResult <()>

LicenseState:status

License state management

Item
LicenseState :: fn status(& self) -> LicenseStatus

LicenseState:try

License state management

Item
fn try_get_license() -> Option <& 'static LicenseState>

LicenseStatus

License status types

Item
pub enum LicenseStatus
LicenseStatus :: fn is_operational(& self) -> bool
LicenseStatus :: fn is_terminal(& self) -> bool
LicenseStatus :: fn needs_attention(& self) -> bool
LicenseStatus :: fn description(& self) -> & 'static str
LicenseStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

Capability:Capability

License payload and capability types

Item
pub struct Capability

Capability:as

License payload and capability types

Item
Capability :: fn as_str(& self) -> & str

Capability:feature

License payload and capability types

Item
Capability :: fn feature(name : & str) -> Self

Capability:fmt

License payload and capability types

Item
Capability :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

Capability:from

License payload and capability types

Item
Capability :: fn from(s : & str) -> Self
Capability :: fn from(s : String) -> Self

Capability:is

License payload and capability types

Item
Capability :: fn is_module(& self) -> bool
Capability :: fn is_feature(& self) -> bool
Capability :: fn is_limit(& self) -> bool

Capability:limit

License payload and capability types

Item
Capability :: fn limit(name : & str) -> Self

Capability:matches

License payload and capability types

Item
Capability :: fn matches(& self, pattern : & str) -> bool

Capability:module

License payload and capability types

Item
Capability :: fn module(name : & str) -> Self

Capability:name

License payload and capability types

Item
Capability :: fn name(& self) -> Option <& str>

Capability:namespace

License payload and capability types

Item
Capability :: fn namespace(& self) -> Option <& str>

Capability:new

License payload and capability types

Item
Capability :: fn new(value : impl Into <String>) -> Self

LicensePayload

License payload and capability types

Item
pub struct LicensePayload
LicensePayload :: fn builder(license_id : Uuid, customer_id : impl Into <String>) -> LicensePayloadBuilder
LicensePayload :: fn has_capability(& self, cap : & str) -> bool
LicensePayload :: fn limit(& self, name : & str) -> Option <u64>
LicensePayload :: fn modules(& self) -> impl Iterator <Item = & str>
LicensePayload :: fn features(& self) -> impl Iterator <Item = & str>
LicensePayload :: fn is_time_valid(& self, now : DateTime <Utc>) -> bool
LicensePayload :: fn is_in_grace_period(& self, now : DateTime <Utc>) -> bool
LicensePayload :: fn is_revoked(& self) -> bool

LicensePayloadBuilder:LicensePayloadBuilder

License payload and capability types

Item
pub struct LicensePayloadBuilder

LicensePayloadBuilder:build

License payload and capability types

Item
LicensePayloadBuilder :: fn build(self) -> LicensePayload

LicensePayloadBuilder:capability

License payload and capability types

Item
LicensePayloadBuilder :: fn capability(mut self, cap : impl Into <Capability>) -> Self

LicensePayloadBuilder:environment

License payload and capability types

Item
LicensePayloadBuilder :: fn environment(mut self, environment : impl Into <String>) -> Self

LicensePayloadBuilder:expires

License payload and capability types

Item
LicensePayloadBuilder :: fn expires_at(mut self, expires_at : DateTime <Utc>) -> Self

LicensePayloadBuilder:feature

License payload and capability types

Item
LicensePayloadBuilder :: fn feature(mut self, name : & str) -> Self

LicensePayloadBuilder:grace

License payload and capability types

Item
LicensePayloadBuilder :: fn grace_period_days(mut self, days : u32) -> Self

LicensePayloadBuilder:hardware

License payload and capability types

Item
LicensePayloadBuilder :: fn hardware(mut self, binding : crate::hardware::HardwareBinding) -> Self

LicensePayloadBuilder:issued

License payload and capability types

Item
LicensePayloadBuilder :: fn issued_at(mut self, issued_at : DateTime <Utc>) -> Self

LicensePayloadBuilder:limit

License payload and capability types

Item
LicensePayloadBuilder :: fn limit(mut self, name : & str, value : u64) -> Self

LicensePayloadBuilder:metadata

License payload and capability types

Item
LicensePayloadBuilder :: fn metadata(mut self, key : impl Into <String>, value : serde_json::Value) -> Self

LicensePayloadBuilder:module

License payload and capability types

Item
LicensePayloadBuilder :: fn module(mut self, name : & str) -> Self

LicensePayloadBuilder:new

License payload and capability types

Item
LicensePayloadBuilder :: fn new(license_id : Uuid, customer_id : impl Into <String>) -> Self

LicensePayloadBuilder:not

License payload and capability types

Item
LicensePayloadBuilder :: fn not_before(mut self, not_before : DateTime <Utc>) -> Self

LicensePayloadBuilder:perpetual

License payload and capability types

Item
LicensePayloadBuilder :: fn perpetual(mut self) -> Self

SignedLicense

License payload and capability types

Item
pub struct SignedLicense
SignedLicense :: fn new(payload : & LicensePayload, signature : & u8) -> Result <Self, serde_json::Error>
SignedLicense :: fn payload_bytes(& self) -> Result <Vec <u8>, base64::DecodeError>
SignedLicense :: fn signature_bytes(& self) -> Result <Vec <u8>, base64::DecodeError>

verification (other)

License signature verification

Item
pub const LICENSE_PUBLIC_KEY: & u8; 32
fn verify_license(signed : & SignedLicense) -> LicenseResult <LicensePayload>
fn verify_license_with_key(signed : & SignedLicense, public_key : & u8; 32,) -> LicenseResult <LicensePayload>
fn sign_license(payload : & LicensePayload, signing_key : & foundation_crypto_sign::SigningKey,) -> LicenseResult <SignedLicense>
fn generate_keypair() ->(foundation_crypto_sign::SigningKey, foundation_crypto_sign::VerifyingKey,)

How to use it

From this crate's own rustdoc:


## License File Format

Licenses are JSON files containing a base64-encoded payload and signature:

Module structure

foundation_license

flowchart TD
  n_foundation_license["foundation_license"]
  n_foundation_license --> n_api["api"]
  n_api --> n_api__handlers["handlers"]
  n_foundation_license --> n_audit["audit"]
  n_foundation_license --> n_enforcement["enforcement"]
  n_foundation_license --> n_error["error"]
  n_foundation_license --> n_hardware["hardware"]
  n_foundation_license --> n_middleware["middleware"]
  n_foundation_license --> n_prelude["prelude"]
  n_foundation_license --> n_state["state"]
  n_foundation_license --> n_status["status"]
  n_foundation_license --> n_types["types"]
  n_foundation_license --> n_verification["verification"]

Public surface

`api`

ItemWhat it is
pub struct LicenseStatusResponseResponse for GET /api/license/status This is the ONLY license information exposed to the admin UI
pub struct LimitSummarySummary of a limit capability.
LicenseStatusResponse :: fn from_current_state() -> SelfBuilds the license status response from the current state.
pub struct CapabilityCheckResponseChecks if a specific capability is available (for UI conditional rendering)
CapabilityCheckResponse :: fn check(capability : & str) -> SelfChecks if a capability is available.

`api::handlers`

ItemWhat it is
async fn get_license_status() -> Json <LicenseStatusResponse>Handler for GET /api/license/status
async fn check_capability(Path(capability) : Path <String>,) ->(StatusCode, Json <CapabilityCheckResponse>)Handler for GET /api/license/capability/:capability

`audit`

ItemWhat it is
pub enum LicenseAuditEventTypes of license-related audit events.
pub struct LicenseAuditEntryStructured audit log entry for license events.
pub enum AuditOutcomeOutcome of an audited operation.
LicenseAuditEntry :: fn new(event : LicenseAuditEvent, status : LicenseStatus, outcome : AuditOutcome) -> SelfCreates a new audit entry.
LicenseAuditEntry :: fn with_actor(mut self, actor : impl Into <String>) -> SelfSets the actor for this entry.
LicenseAuditEntry :: fn with_capability(mut self, capability : impl Into <String>) -> SelfSets the capability for this entry.
LicenseAuditEntry :: fn with_context(mut self, context : serde_json::Value) -> SelfSets additional context.
LicenseAuditEntry :: fn emit(self)Emits this audit entry via tracing
fn audit_license_loaded(status : LicenseStatus)Emits a license loaded audit event.
fn audit_capability_denied(capability : & str, status : LicenseStatus, actor : Option <& str>)Emits a capability denied audit event.
fn audit_capability_granted(capability : & str, status : LicenseStatus, actor : Option <& str>)Emits a capability granted audit event.
fn audit_limit_exceeded(limit_name : & str, current : u64, maximum : u64, status : LicenseStatus, actor : Option <& str>,)Emits a limit exceeded audit event.

`enforcement`

ItemWhat it is
fn enforce_capability(capability : & str, actor : Option <& str>) -> LicenseResult <()>Enforces a required capability at the service layer
fn enforce_limit(limit_name : & str, current_value : u64, actor : Option <& str>,) -> LicenseResult <()>Enforces a limit capability at the service layer
fn has_capability(capability : & str) -> boolChecks if a capability is available without enforcing
fn license_status() -> LicenseStatusReturns the current license status.
fn is_licensed() -> boolReturns true if the license allows normal operations.
pub struct EnforcementDenialEnforcement result for API responses.
EnforcementDenial :: fn from(error : & LicenseError) -> Self
pub struct CapabilityGuardGuard type for service-level enforcement
CapabilityGuard :: fn acquire(capability : & str, actor : Option <& str>) -> LicenseResult <Self>Attempts to create a capability guard
CapabilityGuard :: fn capability(& self) -> & strReturns the capability this guard protects.

`error`

ItemWhat it is
pub enum LicenseErrorPrimary error type for license operations.
LicenseError :: fn error_code(& self) -> & 'static strReturns a stable error code for API responses.
LicenseError :: fn required_capability(& self) -> Option <& str>Returns the capability that was required (if applicable).
LicenseError :: fn license_status(& self) -> LicenseStatusReturns the license status associated with this error.
LicenseError :: fn user_message(& self) -> & strReturns a human-readable message suitable for end users
pub type LicenseResult<T>: Result <T, LicenseError>Result type alias for license operations.

`hardware`

ItemWhat it is
pub struct HardwareBindingThe licensed host fingerprint carried inside a signed license — component HMAC digests (never raw values), mirroring operations_host_inventory::MachineFingerprint.
pub const ACCEPT_THRESHOLD: u32Minimum matched score to accept a node-lock (of a max 125)
pub struct HardwareMatchResult of scoring an observed fingerprint against a licensed HardwareBinding.
fn match_hardware(licensed : & HardwareBinding, observed : & BTreeMap <String, String>,) -> HardwareMatchScore an observed fingerprint (component→digest) against a licensed binding.
pub enum AccessModeThe access mode a license grants right now (grace-then-fail, ADR 0018).
pub struct EntitlementThe evaluated entitlement
Entitlement :: fn emergency(reason : impl Into <String>) -> SelfThe safe fallback: paid capabilities OFF, evidence access ON
fn evaluate(payload : & LicensePayload, signature_valid : bool, observed : Option <& BTreeMap <String, String>>, now : DateTime <Utc>, hardware_grace_until : Option <DateTime <Utc>>,) -> EntitlementEvaluate the entitlement for a license under the grace-then-fail policy

`middleware`

ItemWhat it is
pub struct LicenseErrorResponseResponse type for license enforcement errors.
LicenseErrorResponse :: fn into_response(self) -> Response
LicenseErrorResponse :: fn from(error : LicenseError) -> Self
async fn require_valid_license(request : Request, next : Next) -> ResponseMiddleware that requires a valid license for all routes
fn require_capability_middleware(capability : & 'static str,) -> impl Fn(Request, Next) -> std::pin::Pin <Box <dyn std::future::Future <Output = Response> + Send>> + Clone + Send + 'staticCreates middleware that requires a specific capability
pub struct RequireCapabilityExtractor that validates a capability before handling a request
RequireCapability :: async fn from_request_parts(_parts : & mut axum::http::request::Parts, _state : & S,) -> Result <Self, Self::Rejection>
pub trait LicenseRouterExtExtension trait for Router to add license-protected routes.
axum::Router<S> :: fn require_license(self) -> Self
axum::Router<S> :: fn require_capability(self, capability : & 'static str) -> Self

`state`

ItemWhat it is
pub struct LicenseStateThe loaded license state
LicenseState :: fn status(& self) -> LicenseStatusReturns the current license status.
LicenseState :: fn is_valid(& self) -> boolReturns true if the license is valid for normal operations.
LicenseState :: fn has_capability(& self, cap : & str) -> boolChecks if the license has a specific capability
LicenseState :: fn require(& self, cap : & str) -> LicenseResult <()>Requires a specific capability, returning an error if not available
LicenseState :: fn limit(& self, name : & str) -> Option <u64>Returns the value of a limit capability.
LicenseState :: fn check_limit(& self, name : & str, current : u64) -> LicenseResult <()>Checks if the current value exceeds a limit
LicenseState :: fn expires_at(& self) -> Option <DateTime <Utc>>Returns when the license expires (None for perpetual or missing).
LicenseState :: fn license_id(& self) -> Option <uuid::Uuid>Returns the license ID (if loaded).
LicenseState :: fn customer_id(& self) -> Option <& str>Returns the customer ID (if loaded).
LicenseState :: fn loaded_at(& self) -> DateTime <Utc>Returns when the license was loaded.
LicenseState :: fn enabled_modules(& self) -> Vec <& str>Returns the list of enabled modules.
LicenseState :: fn enabled_features(& self) -> Vec <& str>Returns the list of enabled features.
LicenseState :: fn limits(& self) -> std::collections::HashMap <String, u64>Returns all limits as a map.
fn initialize_license(path : impl AsRef <Path>, public_key : & u8; 32, environment : Option <& str>,) -> & 'static LicenseStateInitializes the global license state from a file
fn get_license() -> & 'static LicenseStateGets the global license state
fn try_get_license() -> Option <& 'static LicenseState>Tries to get the global license state
fn create_test_state(payload : LicensePayload) -> LicenseStateCreates a license state for testing without file I/O.

`status`

ItemWhat it is
pub enum LicenseStatusThe current status of a license.
LicenseStatus :: fn is_operational(& self) -> boolReturns true if the license allows normal operation.
LicenseStatus :: fn is_terminal(& self) -> boolReturns true if the license is in a terminal invalid state.
LicenseStatus :: fn needs_attention(& self) -> boolReturns true if the license needs attention (expired or grace).
LicenseStatus :: fn description(& self) -> & 'static strReturns a human-readable description of the status.
LicenseStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

`types`

ItemWhat it is
pub struct CapabilityA capability granted by a license
Capability :: fn new(value : impl Into <String>) -> SelfCreates a new capability.
Capability :: fn module(name : & str) -> SelfCreates a module capability.
Capability :: fn feature(name : & str) -> SelfCreates a feature capability.
Capability :: fn limit(name : & str) -> SelfCreates a limit capability.
Capability :: fn as_str(& self) -> & strReturns the full capability string.
Capability :: fn namespace(& self) -> Option <& str>Returns the namespace (part before the colon).
Capability :: fn name(& self) -> Option <& str>Returns the name (part after the colon).
Capability :: fn is_module(& self) -> boolReturns true if this is a module capability.
Capability :: fn is_feature(& self) -> boolReturns true if this is a feature capability.
Capability :: fn is_limit(& self) -> boolReturns true if this is a limit capability.
Capability :: fn matches(& self, pattern : & str) -> boolChecks if this capability matches a pattern
Capability :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
Capability :: fn from(s : & str) -> Self
Capability :: fn from(s : String) -> Self
pub struct LicensePayloadThe payload portion of a signed license
LicensePayload :: fn builder(license_id : Uuid, customer_id : impl Into <String>) -> LicensePayloadBuilderCreates a new license payload builder.
LicensePayload :: fn has_capability(& self, cap : & str) -> boolChecks if this license has a specific capability.
LicensePayload :: fn limit(& self, name : & str) -> Option <u64>Returns the value of a limit capability.
LicensePayload :: fn modules(& self) -> impl Iterator <Item = & str>Returns all module capabilities.
LicensePayload :: fn features(& self) -> impl Iterator <Item = & str>Returns all feature capabilities.
LicensePayload :: fn is_time_valid(& self, now : DateTime <Utc>) -> boolChecks if the license is within its validity period.
LicensePayload :: fn is_in_grace_period(& self, now : DateTime <Utc>) -> boolChecks if the license is in the grace period.
LicensePayload :: fn is_revoked(& self) -> boolChecks if the license has been revoked.
pub struct LicensePayloadBuilderBuilder for creating license payloads.
LicensePayloadBuilder :: fn new(license_id : Uuid, customer_id : impl Into <String>) -> Self
LicensePayloadBuilder :: fn hardware(mut self, binding : crate::hardware::HardwareBinding) -> SelfNode-lock this license to a host HardwareBinding.
LicensePayloadBuilder :: fn issued_at(mut self, issued_at : DateTime <Utc>) -> Self
LicensePayloadBuilder :: fn expires_at(mut self, expires_at : DateTime <Utc>) -> Self
LicensePayloadBuilder :: fn perpetual(mut self) -> Self
LicensePayloadBuilder :: fn not_before(mut self, not_before : DateTime <Utc>) -> Self
LicensePayloadBuilder :: fn environment(mut self, environment : impl Into <String>) -> Self
LicensePayloadBuilder :: fn grace_period_days(mut self, days : u32) -> Self
LicensePayloadBuilder :: fn capability(mut self, cap : impl Into <Capability>) -> Self
LicensePayloadBuilder :: fn module(mut self, name : & str) -> Self
LicensePayloadBuilder :: fn feature(mut self, name : & str) -> Self
LicensePayloadBuilder :: fn limit(mut self, name : & str, value : u64) -> Self
LicensePayloadBuilder :: fn metadata(mut self, key : impl Into <String>, value : serde_json::Value) -> Self
LicensePayloadBuilder :: fn build(self) -> LicensePayload
pub struct SignedLicenseA signed license artifact containing payload and signature.
SignedLicense :: fn new(payload : & LicensePayload, signature : & u8) -> Result <Self, serde_json::Error>Creates a new signed license from payload and signature bytes.
SignedLicense :: fn payload_bytes(& self) -> Result <Vec <u8>, base64::DecodeError>Decodes the payload bytes for verification.
SignedLicense :: fn signature_bytes(& self) -> Result <Vec <u8>, base64::DecodeError>Decodes the signature bytes for verification.

`verification`

ItemWhat it is
pub const LICENSE_PUBLIC_KEY: & u8; 32The compiled-in public key for license verification
fn verify_license(signed : & SignedLicense) -> LicenseResult <LicensePayload>Verifies a signed license and extracts the payload
fn verify_license_with_key(signed : & SignedLicense, public_key : & u8; 32,) -> LicenseResult <LicensePayload>Verifies a signed license with a specific public key
fn sign_license(payload : & LicensePayload, signing_key : & foundation_crypto_sign::SigningKey,) -> LicenseResult <SignedLicense>Signs a license payload with a private key
fn generate_keypair() ->(foundation_crypto_sign::SigningKey, foundation_crypto_sign::VerifyingKey,)Generates a new Ed25519 keypair for license signing

Re-exports. Exported here, defined elsewhere.

ExportDefined in
Capabilitycrate::types::Capability
LICENSE_PUBLIC_KEYverification::LICENSE_PUBLIC_KEY
LicenseRouterExtcrate::middleware::LicenseRouterExt
LicenseStatuscrate::status::LicenseStatus
LicenseStatusstatus::LicenseStatus
{Capability,LicensePayload,SignedLicense}types::{Capability,LicensePayload,SignedLicense}
{CapabilityCheckResponse,LicenseStatusResponse,LimitSummary}api::{CapabilityCheckResponse,LicenseStatusResponse,LimitSummary}
{LicenseError,LicenseResult}crate::error::{LicenseError,LicenseResult}
{LicenseError,LicenseResult}error::{LicenseError,LicenseResult}
{audit_capability_denied,audit_capability_granted,audit_license_loaded,audit_limit_exceeded,AuditOutcome,LicenseAuditEntry,LicenseAuditEvent,}audit::{audit_capability_denied,audit_capability_granted,audit_license_loaded,audit_limit_exceeded,AuditOutcome,LicenseAuditEntry,LicenseAuditEvent,}
{enforce_capability,enforce_limit,has_capability,is_licensed,license_status,CapabilityGuard,EnforcementDenial,}enforcement::{enforce_capability,enforce_limit,has_capability,is_licensed,license_status,CapabilityGuard,EnforcementDenial,}
{enforce_capability,enforce_limit,has_capability,is_licensed}crate::enforcement::{enforce_capability,enforce_limit,has_capability,is_licensed}
{evaluate,match_hardware,AccessMode,Entitlement,HardwareBinding,HardwareMatch,ACCEPT_THRESHOLD,}hardware::{evaluate,match_hardware,AccessMode,Entitlement,HardwareBinding,HardwareMatch,ACCEPT_THRESHOLD,}
{get_license,initialize_license,try_get_license,LicenseState}state::{get_license,initialize_license,try_get_license,LicenseState}
{get_license,initialize_license}crate::state::{get_license,initialize_license}
{require_capability_middleware,require_valid_license,LicenseErrorResponse,LicenseRouterExt,}middleware::{require_capability_middleware,require_valid_license,LicenseErrorResponse,LicenseRouterExt,}

Boundary

Depends on no other workspace tier.

Shares tier foundation with 27 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (27 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)foundation
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/foundation/license
Vocabulary in force (lexicon)current

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-crypto-sign`foundationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
axum^0.7multipartyesalways
base64^0.22noalways
chrono^0.4serdenoalways
rand^0.8noalways
serde^1derivenoalways
serde_json^1noalways
thiserror^2noalways
tokio^1fullnoalways
tracing^0.1noalways
uuid^1v4, v7, serde, jsnoalways

Development, in this workspace.

CrateTierOptionalOnly on
`foundation-crypto-sign`foundationnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
ed25519-dalek^2noalways
tokio-test^0.4noalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_license["application-license"] -->|uses| SELF
  SELF["foundation-license"]
  SELF -->|development| n_foundation_crypto_sign["foundation-crypto-sign"]
  SELF -->|runtime| n_foundation_crypto_sign["foundation-crypto-sign"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
axumdep:axumno
defaultyes
keygenfoundation-crypto-sign/keygenno
signingno
flowchart LR
  n_axum["axum"] --> n_dep_axum["dep:axum"]
  n_default["default"]
  n_keygen["keygen"] --> n_foundation_crypto_sign_keygen["foundation-crypto-sign/keygen"]
  n_signing["signing"]

Targets

KindNameSource
libfoundation_license`src/lib.rs`

Error model

Error typeNamed by
LicenseErrorLicenseErrorResponse, LicenseResult

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessnone detected
network I/Oyes
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

1 workspace crate depends on this one: application-license.

Verification

KindCount
Unit tests43
Integration tests0
Examples0
Doctests1

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
api300
api::handlers200
audit700
enforcement700
error200
hardware705
middleware500
state500
status100
types402
verification503

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc102125
Public modules with a //! block1112
pie showData
    title Public items with rustdoc
    "Documented" : 102
    "No rustdoc detected" : 23

Metrics

MetricValue
Rust source files11
Source lines3160
Code lines2124
Public API items125
Public modules12
Tests43
Examples0
Cargo features4
Direct runtime dependencies12
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 2
    "enum" : 5
    "function" : 23
    "method" : 77
    "struct" : 16
    "trait" : 1
    "type alias" : 1
pie showData
    title Rust source composition
    "Code" : 2124
    "Blank or comment" : 1036

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las foundation · Manual