Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Server Configuration & Security Guide

This document details the configuration topology, cryptographic secret references, mandatory TLS setup, and operational parameters for the OpenFAB Rocket backend service.


Configuration Overview

OpenFAB uses a structured, type-safe configuration model backed by serde. Configuration can be supplied via an OpenFab.toml file or overridden using environment variables prefixed with OPENFAB_.

Mandatory Security Defaults

  • Strict TLS Enforcement: Plain HTTP execution is disabled. The server requires valid X.509 certificate and private key paths before initializing routes.
  • Deterministic HMAC Token Protection: All API keys, activation codes, and session tokens are hashed using HMAC-SHA256 with a dedicated server-side secret key before entering PostgreSQL.
  • Secret Isolation (SecretRef): Sensitive credentials (database passwords, object store keys, cryptographic seeds) must be loaded via file references (file:///path/to/secret) or environment variables, keeping secrets out of repository tracking.

Standardized OpenFab.toml Prototype

Below is the complete, canonical configuration file with sane defaults:

[server]
address = "127.0.0.1"
port = 7777
max_upload_limit_mb = 100
static_dir = "static"

[tls]
cert_path = "/etc/openfab/certs/server.crt"
key_path = "/etc/openfab/secrets/server.key"

[database]
url = "file:///etc/openfab/secrets/db_url.txt"
max_connections = 16
min_connections = 2

[storage]
endpoint = "localhost:3900"
bucket = "openfab"
access_key = "OPENFAB_STORAGE_ACCESS_KEY"
secret_key = "file:///etc/openfab/secrets/store.key"
secure = true
primary_hash_alg = "blake3"

[auth]
allow_registration = true
hmac_secret = "file:///etc/openfab/secrets/hmac.key"

[auth.oidc]
name = "LaunchSpace Keycloak"
client_id = "openfab"
client_secret = "file:///etc/openfab/secrets/keycloak.txt"
issuer_url = "[https://sso.example.com/realms/master](https://sso.example.com/realms/master)"
redirect_url = "[https://openfab.example.com:7777](https://openfab.example.com:7777)"
jwt_privkey_path = "/etc/openfab/secrets/backend.key.pem"
post_login_redirect = "/accounts/dashboard"

Cryptographic Secrets Inventory

The OpenFAB server requires several cryptographic secrets to be provisioned on disk prior to launch. File permissions must be set to 0600 (chmod 600), owned by the service user.

Secret Key FileRequiredPurposeFormat / Algorithm
hmac.keyYesHMAC-SHA256 seed for deterministic hashing of API keys & activation codes.Random high-entropy byte sequence (minimum 32 bytes).
server.keyYesPrivate key for web server TLS termination.PEM-encoded PKCS#8 or RSA private key.
server.crtYesServer certificate chain.PEM-encoded X.509 certificate.
store.keyYesAuthentication secret for object storage (S3/MinIO/Garage).UTF-8 secret string.
backend.key.pemYesRSA private key used by OidcSigner to sign local session tokens and JWTs.PEM-encoded RSA Private Key (-----BEGIN RSA PRIVATE KEY-----).
keycloak.txtOptionalOIDC Client Secret (if OIDC auto-registration is enabled).Standard string secret from IdP.

Environment Variable Overrides

(this will be the standard after figment configuration is implemented) For containerized deployment environments (e.g., Docker, Podman, Kubernetes), any configuration option can be set or overridden using OPENFAB_ environment variables:

Environment VariableEquivalent TOML FieldDescription
OPENFAB_SERVER_ADDRESSserver.addrNetwork interface IP binding.
OPENFAB_SERVER_PORTserver.portHTTP/TLS listener port.
OPENFAB_TLS_CERT_PATHtls.cert_pathPath to TLS certificate.
OPENFAB_TLS_KEY_PATHtls.key_pathPath to TLS private key.
OPENFAB_DATABASE_URLdatabase.urlPostgreSQL connection string or file:// ref.
OPENFAB_AUTH_HMAC_SECRETauth.hmac_secretSecret key or file:// reference for HMAC operations.
OPENFAB_STORAGE_SECRET_KEYstorage.secret_keyStorage secret or file:// reference.

Limits & Runtime Tuning

  • Upload Limits: The default max_upload_limit_mb is set to 100MB for data-form and file inputs to accommodate large parametric models, multi-layer 3MF files, and dense binary G-code payloads.
  • Database Pool: The PostgreSQL connection pool defaults to 16 maximum concurrent connections with 2 idle connections maintained for low-latency dispatching.

API Integration & Third-Party Tooling

This guide provides an overview for developers looking to build integrations, CLI utilities, or third-party client applications for the platform.


1. Interactive API Documentation (Swagger UI)

For an interactive, real-time reference of all available REST endpoints, request schemas, and response types, consult the built-in Swagger UI.

  • Local Development: http://localhost:7777/swagger-ui/
  • Production / Remote: https://<your-domain>/api/swagger-ui/

The Swagger UI allows you to inspect model schemas, test queries directly against a running server instance, and inspect expected status codes (e.g., 401 Unauthorized, 412 Precondition Failed, 422 Unprocessable Entity).


2. Official Rust SDK Crate

If you are developing third-party tools or microservices in Rust, you can use the official SDK crate rather than implementing raw HTTP logic.

Installation

Add the SDK dependency to your Cargo.toml:

[dependencies]
openfab-sdk = "0.1" # Adjust crate name/version as appropriate
tokio = { version = "1", features = ["full"] }

Quick Example

use openfab_sdk::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize client with base URL and Bearer Access Token
    let client = Client::new("https://api.yourdomain.com", "your_bearer_token_here")?;

    // Perform operations via the client SDK
    let user = client.users().me().await?;
    println!("Authenticated as: {}", user.email);

    Ok(())
}

3. Authentication & Bearer Tokens

All protected API endpoints require authentication using standard HTTP Bearer Tokens in the Authorization header.

Header Format

Authorization: Bearer <your_access_token>

Obtaining an Access Token (web UI only)

  1. OIDC / SSO Authorization Flow: Complete the OpenID Connect web flow to acquire an ID/Access token pair.
  2. Account Activation / Local Login: Submit user credentials or complete account activation via the /accounts/activate endpoint to acquire a session token.

Security Guidelines

  • Token Storage: Store tokens securely (e.g., using OS keyring services for CLI tools, or secure, HTTP-only cookies for web applications).
  • Transit Security: All production API endpoints strictly enforce HTTPS/TLS. Non-TLS requests will be rejected.

4. API Architecture & Key Components

The platform API is structured around clear domain boundaries to simplify building custom tools:

Primary Domain Modules

  • Identity & Accounts (/accounts, /auth)
    • Handles user registration, OIDC account linking, account activation, and credential management.
    • Enforces strict identity collision checks (returns 409 Conflict on email collision rather than silent linking). (For security reasons this will be excluded from the standard REST API until further notice.)

Error Handling & Status Code Taxonomy

The API adheres to a strict error taxonomy to simplify programmatic client logic:

Status CodeMeaningCommon Cause
401 UnauthorizedAuthentication FailureMissing, invalid, or expired Bearer token.
403 ForbiddenPermission DeniedAuthenticated user lacks specific DB/RBAC permissions.
409 ConflictIdentity CollisionEmail already exists under another account provider.
412 Precondition FailedState RequirementAccount activation required (is_active == false).
422 Unprocessable EntityValidation FailureInvalid request parameters or form fields.

5. Building Third-Party Tooling

When creating custom integrations (such as CLI tools, desktop wrappers using Slint/Tauri, or web widgets):

  1. Use the OpenAPI Spec: You can download the raw OpenAPI JSON/YAML definition directly from /api/openapi.json to auto-generate client bindings for other languages (Python, Go, TypeScript).
  2. Handle Precondition Errors: Always check for 412 Precondition Failed responses to gracefully prompt users to complete email activation or administrator setup.
  3. Respect Rate Limits: Ensure long-running scripts handle exponential backoff on retries.