Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/explanation/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Authentication tells who calls, OpenFGA decides what they may do (`internal/auth
| read instances, images | `can_read_instances`, `can_read_images` | `instances:read`, `images:read` |
| write instances | `can_write_instances` | `instances:write` |
| write images | `can_write_images` | `images:write` |
| read, write memberships and keys | `can_read_memberships`, `can_write_memberships` | `memberships:read`, `memberships:write` |
| read, write memberships, and keys | `can_read_memberships`, `can_write_memberships` | `memberships:read`, `memberships:write` |

A user gets those through a role (`admin` over `operator` over `user` over `viewer`). A key does what its owner may **and** what its scopes name: the scope is checked first (`instances:write` does not give `instances:read`), then OpenFGA is asked about the owner. `Authorizer.Require(action, ...)` is the middleware of a route: `404` when the caller cannot read the tenant (a tenant that is not yours is not shown to exist), `403` when it can but may not do this, `503` when OpenFGA cannot answer. A decision that cannot be taken is never an "allowed". `Authorizer.PlatformAdmin` tells who creates, resizes and deletes tenants: the members of the Authentik group `PLATFORM_ADMIN_GROUP` (the model has no relation for it). A token carries its groups; a key does not, so the API asks Authentik whether its owner is a member of that group (`internal/authentik`, `AUTHENTIK_URL` and `AUTHENTIK_TOKEN`: the token of a service account that may read that one group and nothing else, the members remembered for `AUTHENTIK_CACHE_TTL`; if the group cannot be read, that is an error, never "nobody is in it"): a key stops being an administrator's within `AUTHENTIK_CACHE_TTL` of its owner leaving the group. The scopes `tenants:read` and `tenants:write` gate what a platform administrator's key does on tenants. `GET /v1/whoami` says whether the caller may write tenants. Members are added in Authentik, the group itself is created by the blueprint in Hangar.

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/images-and-instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ verified: 2026-10-28
Both live in the namespace `t-<tenant>` of the `phorge.fr` group; the platform administrators may act on any tenant that exists.

- **An instance starts from an image of its tenant**, never from a bare image name: the API refuses an image that does not exist in the tenant (`422`) and one that is not `Ready` yet (`409`, `image_not_ready`). While it is pulled (a few minutes) an instance would report problems that are not one and be called `Failed` after three minutes.
- **Images** are pulled from the `images` server (linuxcontainers.org) only, as virtual machines for the architecture of the compute nodes. The Image kind is the only gate to the image servers, so the API restricts the remote. An image cannot be changed, only deleted and pulled again.
- **Images** are pulled from the `images` server (linuxcontainers.org) only, as virtual machines for the architecture of the compute nodes. The Image kind is the only gate to the image servers, so the API restricts the remote. An image cannot be changed, only deleted, and pulled again.
- **Deleting an image** that instances start from is a `409` that names them. Delete them first.
- **Instances**: `cpu` 1 to 16, `memoryMiB` 256 to 65536, `diskGiB` 1 to 500, the rest is the defaults of the XRD (what is not given is not sent). `PATCH` changes `running` (start and stop keep the same VM), `cpu`, `memoryMiB`, `diskGiB` and `sshPublicKeys`, applied live. The image, `nesting` and `secureBoot` cannot change: delete and create.
- **The quota of the plan is Incus's**: a refusal such as `Reached maximum number of instances` comes back as the `problems` of the instance, which becomes `Failed` after three minutes. Stopped VMs count. An instance whose first start failed is stuck: delete it and create it again.
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/memberships-and-api-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ verified: 2026-10-28

# Memberships and API keys

- **A membership gives a user a role** on a tenant (`admin`, `operator`, `user`, `viewer`). Memberships are objects of the tenant's namespace, read and written only by the admins of the tenant (the relations `can_read_memberships` and `can_write_memberships`) or a platform administrator. A membership cannot be edited, because a role is an OpenFGA tuple that cannot be changed in place: to change a role, delete the membership and create another. There is one per user and tenant: its name is derived from the email, so a second one is a `409`. The owner of a tenant already is admin through the tenant and a membership for it is refused (`409`, `owner_is_admin`): to hand a tenant over, give someone else the `admin` role. Only users are supported, a group is refused (nothing writes the tuples a group needs).
- **A membership gives a user a role** on a tenant (`admin`, `operator`, `user`, `viewer`). Memberships are objects of the tenant's namespace, read and written only by the admins of the tenant (the relations `can_read_memberships` and `can_write_memberships`) or a platform administrator. A membership cannot be edited, because a role is an OpenFGA tuple that cannot be changed in place: to change a role, delete the membership, and create another. There is one per user and tenant: its name is derived from the email, so a second one is a `409`. The owner of a tenant already is admin through the tenant and a membership for it is refused (`409`, `owner_is_admin`): to hand a tenant over, give someone else the `admin` role. Only users are supported, a group is refused (nothing writes the tuples a group needs).
- **Deleting a membership is not an instant revocation**: the object goes at once, its tuples within about a minute (measured on the cluster in the test below).
- **An API key is personal**: it belongs to the user who created it, not to a tenant, and acts as them within its scopes (`tenants:read`, `tenants:write`, `instances:read|write`, `images:read|write`, `memberships:read|write`). It is `phk_<id>_<secret>`: the id locates the object with one get, the secret is 32 random bytes in hex. The answer to its creation holds the key, **once**; only the SHA-256 of the secret is stored (`spec.hash`), so no read ever shows it again.
- **Only a person manages keys**, signed in with Authentik: a key cannot create, read or delete keys. `API_KEY_CREATION` says who creates and changes them (the platform administrators, or any person); anyone lists and revokes their own (a key can always be revoked). Someone else's key answers `404`.
- **Only a person manages keys**, signed in with Authentik: a key cannot create, read, or delete keys. `API_KEY_CREATION` says who creates and changes them (the platform administrators, or any person); anyone lists and revokes their own (a key can always be revoked). Someone else's key answers `404`.
- **A key never exceeds its owner**, because the owner is what is asked at every request. A key expires: with `API_KEY_MAX_LIFETIME` set, `expiresAt` is required and capped to it.
- **A key stops at its `expiresAt` to the second**: the authentication checks the date itself and does not wait for the composition. A key that is being deleted stops at once too. The list shows `expired` as soon as the date has passed.
- A key cannot be rotated: delete it and create another.
2 changes: 1 addition & 1 deletion docs/reference/tenants.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ verified: 2026-10-28

# Tenants

A tenant is a `Tenant` object of the `phorge.fr` group in `phorge-system` (`internal/kube/tenants.go`); Crossplane makes its namespace `t-<name>`, its Incus project and its network.
A tenant is a `Tenant` object of the `phorge.fr` group in `phorge-system` (`internal/kube/tenants.go`); Crossplane makes its namespace `t-<name>`, its Incus project, and its network.

- **Create** answers `202` with a `Location`: poll it until `phase` is `Ready`. `phase` is `Provisioning`, `Ready`, `Deleting`, or `Failed` when the tenant has not become ready for 3 minutes and `problems` holds the error of Incus or OpenFGA, shown as it is.
- **Patch** changes `plan` and `displayName`. The owner cannot change (it is an OpenFGA tuple): a body that holds it is refused. To hand a tenant over, give the new person the `admin` role with a membership.
Expand Down
Loading