1. Authentication (fleetmesh-auth)#

fleetmesh-auth provides identity verification and session management for FleetMesh web applications, administrative interfaces, and standalone mesh services. Applications can embed a FleetmeshAuthEngine instance—mounting its /api/fauth/* routes and sign-in panel directly—or deploy it as a standalone HTTP service via python3 -m fleetmesh_auth. The package depends only on fleetmesh-core; PostgreSQL session persistence requires the postgres extra.

pip install --pre fleetmesh-auth
pip install --pre 'fleetmesh-auth[postgres]'

1.1. Authentication Providers#

Two authentication providers are built in:

sovereign_key (SovereignKeyBunkerProvider)

Authenticates cryptographic keys and DIDs by verifying signatures over server-issued challenges. Supported clients include NIP-07 browser extensions, private keys or DIDs entered into the sign-in panel (which signs locally in the browser and transmits only the public key and signature; the server unconditionally rejects raw secret keys with private_key_not_accepted), and NIP-46 bunkers. Note that NIP-46 bunker authentication requires a challenge signature from the remote signer, and the bundled sign-in panel does not yet implement the NIP-46 handshake protocol; consequently, its bunker tab cannot complete a login end to end. This provider also verifies portable passes (fmpass_…): user-signed NIP-98 (kind 27235) tickets minted client-side in the browser and valid for a single sign-in within their configured lifetime (up to one hour).

local_operator (LocalOperatorProvider)

Authenticates the local node operator using MESHNODE_OPERATOR_TOKEN, meshctl control credentials, or an authorized operator public key. If no operator token is configured, operator-token authentication is refused; no default credential exists.

Integration with external account systems is implemented through provider plugins (Authentication Provider Plugins (API Version 1)).

1.2. Roles#

By default, a key-based login is assigned the creator role. A key receives operator privileges only when it matches the co-hosted application’s own operator or node key, or when the application’s user directory assigns it an admin or node_operator role. Additional privileged keys (formatted as 64-character hex, npub1…, or did:nostr:…) can be declared via FLEETMESH_AUTH_OPERATOR_PUBKEYS and FLEETMESH_AUTH_ADMIN_PUBKEYS. The admin and node_operator roles mutually imply one another. For single-operator deployments, passing allow_any_sovereign_key=True in Python code grants operator privileges to every verified sovereign key.

1.3. Configuration#

Variable

Effect

FLEETMESH_AUTH_ENABLED_METHODS, …_DISABLED_METHODS

Authentication methods displayed by the sign-in panel and accepted by the server (service_provider, bunker_nip07, private_key, did, api_key, passkey, portable_ticket, operator_token).

FLEETMESH_AUTH_ENABLED_PROVIDERS, …_DISABLED_PROVIDERS

Active or excluded authentication providers, identified by provider_id.

FLEETMESH_AUTH_OPERATOR_PUBKEYS, FLEETMESH_AUTH_ADMIN_PUBKEYS

Public keys granted node_operator or admin roles upon login.

FLEETMESH_AUTH_PLUGINS

External provider plugins loaded from PYTHONPATH as module:Class; installed packages with entry points are discovered automatically.

FLEETMESH_AUTH_<PROVIDER>_<NAME>

Provider-specific configuration parameters read by from_settings.

FLEETMESH_AUTH_PRESETS_JSON

JSON definitions for custom or overridden sign-in panel presets.

MESHNODE_OPERATOR_TOKEN, MESHNODE_OPERATOR_USER

Local operator authentication token and display name.

List-valued variables accept comma- or whitespace-delimited entries; malformed entries are logged and skipped. Environment settings are parsed by fleetmesh_auth.settings.

1.4. Standalone Service#

Running python3 -m fleetmesh_auth (or the fleetmesh-auth entry-point script) starts a standalone HTTP server exposing the /api/fauth/* routes and sign-in portal. Configuration precedence is command-line flags, followed by environment variables, followed by built-in defaults:

Flag

Variable

Default

--host

FLEETMESH_AUTH_HOST

127.0.0.1

--port

FLEETMESH_AUTH_PORT

8099

--db

FLEETMESH_AUTH_DB

:memory: (SQLite path)

--store-url

FLEETMESH_AUTH_STORE_URL

empty (uses SQLite at --db; set postgres://… for a shared store)

--domain

FLEETMESH_AUTH_DOMAIN

fleetmesh.local

--admin-addr

FLEETMESH_AUTH_ADMIN_ADDR

empty (administrative listener disabled)

--cors-origin (repeatable)

FLEETMESH_AUTH_CORS_ORIGINS

empty (cross-origin access disabled)

Both the primary and administrative listeners bind to loopback and serve plain HTTP. Production deployments MUST place a TLS-terminating reverse proxy in front of the primary listener and restrict the administrative listener (/healthz, /readyz, /metrics) to internal networks. Binding to a non-loopback interface is permitted but emits a startup warning. Cross-origin access requires an explicit allowlist of bare origins; when unconfigured, no CORS response headers are emitted.

1.5. Persistence#

Active sessions, single-use challenges, redeemed authentication event IDs, and WebAuthn passkey records are persisted in an AuthStore implementation: either SqliteAuthStore (default) or PostgresAuthStore (selected automatically by make_store based on a filesystem path or postgres:// URL). Both backends index sessions by the SHA-256 digest of the session token and never store plaintext bearer tokens. Multi-replica deployments MUST use the PostgreSQL backend so that session validation, challenge consumption, and replay tracking are consistent across all replicas.