Zum Inhalt springen
Produkte

// Referenz

Security model

How Fleeger authenticates people and services, decides what each of them may do, and keeps infrastructure secrets safe. The agents’ side — the NATS trust chain, per-location isolation and revocation — is covered in the documents linked at the end.

Authentication

Login is SurrealDB RECORD access: auth-svc runs a SIGNIN query that verifies the username and an argon2 password hash, and returns a SurrealDB-signed JWT. The token encodes the user's record id. Verification re-authenticates that token against db=auth; no separate signing secret is managed by the application. The access has no SIGNUP clause: accounts are created only through auth-svc's API and CLI, never by a client signing up against SurrealDB directly.

Authorization and per-location roles

A user's effective permissions are the union of their directly-granted permissions and the permissions of every role assigned to them. Permissions are wildcard-matchable strings (*, location.*, location.view).

Role assignments are per-location. The roles edge (user → role) carries a location field: NONE means the role is granted globally (every location), otherwise it is scoped to that one location id. This lets you delegate one location without granting anything elsewhere — e.g. a homelab-operator role assigned for homelab only. See RBAC & per-location access for the full model, the location-scoped permission functions, and how the Access UI maps onto them.

Enforcement is SurrealDB-native: db=auth defines fn::user_has_permission_at / fn::auth_user_has_permission_at (and the global-only …_has_permission), and gateway-svc calls the location-aware form to gate each request. The gateway maps HTTP method + path to a permission and resolves the target location the request acts on (the id in /api/locations/{id}/…, the agent id for offboarding, the location field of a control action's body). A role satisfies the check when it is assigned globally or for that specific location.

Path prefix GET POST PUT/PATCH DELETE
/api/locations location.view location.create location.edit location.delete
/api/resources resource.view resource.create resource.edit resource.delete
/api/control control.view control.execute — —
/api/users, /api/roles, /api/permissions iam.manage iam.manage iam.manage iam.manage

Creating a resource, POST /api/locations/{id}/resources, is the exception under /api/locations: it needs resource.create and location.edit at that location; location.create only creates locations. So is a checkpoint rollback, POST /api/locations/{id}/rollback: it needs resource.edit and location.edit there, and resource.create and resource.delete too unless it is a safe rollback.

Built-in roles: admin (*), operator and viewer (location.view, resource.view). Built-in roles cannot be edited or deleted; create a custom role for anything else (e.g. a controller role that adds control.view + control.execute).

How permissions are enforced

db=auth owns the logic as SurrealDB functions (migration 0005_rbac_per_location):

  • fn::user_effective_permissions_at($user, $location) — the union above.
  • fn::user_has_permission_at($user, $perm, $location) — wildcard-aware check.
  • fn::auth_user_has_permission_at($perm, $location) — the same for the currently authenticated token ($auth).

gateway-svc is the single choke point. For every request it:

  1. maps method + path to the required permission (e.g. POST /api/control/... → control.execute);
  2. resolves the target location the request acts on;
  3. calls fn::auth_user_has_permission_at(perm, location) and returns 403 if it is false.

How the location is resolved:

Request Target location
/api/locations/{id} and /api/locations/{id}/… {id}
/api/agents/{id} (offboard) {id} (the agent is the location)
/api/control/actions (POST) the location field of the JSON body
/api/control/audit (GET) the ?location= query, if present
everything else (list, metrics, logs, alerts, IAM) global (NONE)

Why the body, not a query param, for a control action? The enforced location must be the exact value control-svc will act on. If the gateway scoped on a query parameter, a caller could pass a location it may control while the body targeted one it may not. The gateway buffers and parses the body, checks that location, and hands the body back for forwarding.

From: RBAC & per-location access

Service-to-service authentication

The backend services (auth-svc, inventory-svc, ingestion-svc, alerting-svc) are not exposed to the internet, but they don't trust the pod network either: every data route requires a shared internal token (FLEEGER_INTERNAL_TOKEN, header X-Fleeger-Internal). gateway-svc attaches it to every call to these services (and to its own offboard cascade), never to VictoriaMetrics, Loki or the NATS monitor, and alerting-svc attaches it when it polls ingestion-svc/inventory-svc. A request that reaches a service port without the token gets 401 — so a compromised or curious neighbour on the network can't call inventory-svc directly to read credentials. Only /health, /version, and /metrics stay open (for probes and scraping). The gateway strips any client-supplied X-Fleeger-Internal header before forwarding, so the token can't be spoofed from outside.

Credential storage

Infrastructure credentials (e.g. a Proxmox API secret) must be retrievable by services unattended, so they are encrypted with a service-held master key (AES-256-GCM) rather than a per-user password. inventory-svc stores only ciphertext (base64(nonce || ciphertext)) in a credential record; a Resource.credential_ref links to it. Plaintext never touches the database, so a database dump alone never exposes a secret. The master key is provided out of band (FLEEGER_CREDENTIAL_KEY, a Kubernetes Secret in production).

See also

// Zusammenarbeit

Bereit, Ihre digitale Infrastruktur zu bauen?

Ob individuelle Automatisierung für Ihr Unternehmen oder ein durchgeplantes Netzwerk für Ihr Zuhause — lassen Sie uns über das Projekt sprechen.