User Management¶
PhyCloud supports first-class user accounts scoped under a tenant. A user can authenticate via password, SSO (future), or PATs, and every action performed under a user session is attributed to that user in audit logs.
Data Model¶
| Table | Description |
|---|---|
users | User identity: id, tenant_id, email, display_name, status |
user_credentials | Argon2id password hash (absent for SSO-only users) |
user_sessions | Active and revoked sessions |
user_invites | Single-use invite tokens |
The First Admin¶
A fresh platform has no users, and API keys can't manage users, so the first admin comes from bootstrap:
# Bootstrap the platform with its first admin (invited: the output has a token)
phyware cloud bootstrap init --admin-email admin@example.com
# ...or set the admin's password right away
PHYWARE_ADMIN_PASSWORD=… phyware cloud bootstrap init --admin-email admin@example.com
# A platform already bootstrapped without a user (works while it has none)
phyware cloud bootstrap admin --admin-email admin@example.com
The platform's first admin can manage users, API keys and tenants. Each new tenant can get its own first admin, who manages that tenant's users and keys:
Over the API, POST /bootstrap and POST /api/v1/admin/tenants take an optional admin_user: {"email", "password"?, "display_name"?}, and POST /bootstrap/admin (with X-Bootstrap-Token) takes the same object.
Invite Flow¶
Admins create invites; users accept them, set a password and log in.
# Admin invites a user
phyware users invite --email alice@example.com --scopes events:read,events:write
# User accepts the invite (sets their password)
phyware users accept-invite --token <invite-token>
# ...and logs in; later commands use the session
phyware auth password-login --email alice@example.com --tenant acme
A user's sessions get exactly the scopes their invite granted. An invite can only grant scopes the inviter holds, so nobody can invite their way above their own access. Users created before scopes were stored get events:read, events:write and users:read.
CLI Reference¶
phyware users invite¶
Creates an invite token for a new user. The token is shown once — share it with the user via a secure channel.
phyware users list¶
Lists all users for the current tenant.
phyware users get¶
Fetches the profile of a single user.
phyware users deactivate¶
Soft-deletes a user (status → deactivated). Existing sessions expire naturally.
API Reference¶
| Method | Path | Scope | Description |
|---|---|---|---|
POST | /bootstrap/admin | bootstrap token | The platform's first admin user |
POST | /api/v1/users/invite | admin:users | Create invite |
POST | /api/v1/users/accept-invite | — | Accept invite + set password |
GET | /api/v1/users/me | users:read | Current user profile |
GET | /api/v1/users | admin:users | List users |
GET | /api/v1/users/{id} | admin:users | Get user |
PUT | /api/v1/users/{id} | admin:users | Update user |
POST | /api/v1/users/{id}/deactivate | admin:users | Deactivate user |
Scopes¶
| Scope | Description |
|---|---|
admin:users | Full user management (invite, list, get, update, deactivate). Held only by users, never by API keys: user administration stays with people. |
users:read | Read own profile (/users/me) |