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

Users and roles

An instance with the password sign-in (RUSTYBIN_CONTROL_AUTH=password, the default) is shared by a team: an admin adds people, gives them roles, disables or removes them. Nobody but its owner ever sees or types a password: people join through a one-time invitation link and choose their own, and change it themselves. With single sign-on people sign in with the team's identity provider instead: they have no password here, and the provider's groups give their roles.

A role is a set of named permissions. Five roles are built in and never change; custom roles pick any permissions.

RoleForPermissions
viewerLooking around: the console read-onlyevery *.read except traffic.read, audit.read and users.read
testerRunning what others builtviewer plus traffic.read, tests.run, scenarios.run, harness.read, harness.run, assist.use, mcp.inspect
editorBuilding mocks and teststester plus every mocks.*, tests.write, checkpoints.*, assist.jobs, portal.publish, registry.write, config.export, git.read, traffic.clear
adminEverythingevery permission
portal_readerReading the API portal's closed itemsportal.read

A role that grants users.manage or settings.security is privileged (it can change who may do what) and is marked so in every view. The first admin ("user one") is the console user of the sign-in settings (console.user, RUSTYBIN_CONSOLE_USER): its password stays in console.password_hash and the environment, as before.

Invite someone

POST /_rustybin/users (users.manage) creates the user, invited (disabled until they accept), and answers the link https://<host>/ui/#/join/<token> once (for a user whose only role is portal_reader, the API portal's join page, https://<host>/portal/#/join/<token>, so a tester never sees the console):

POST {{password_url}}/_rustybin/users
Authorization: Bearer {{admin}}
Content-Type: application/json
{ "name": "docs-alice", "display_name": "Alice Doe", "email": "alice@example.com", "roles": ["editor"] }
HTTP 201
[Captures]
invitation: jsonpath "$.invitation.token"
[Asserts]
jsonpath "$.user.name" == "docs-alice"
jsonpath "$.user.status" == "invited"
jsonpath "$.invitation.url" contains "/ui/#/join/rbi_"
jsonpath "$.invitation.token" startsWith "rbi_"
jsonpath "$.invitation.expires_at" exists
jsonpath "$.invitation.reset" == false

The token is 32 random bytes, kept only as a SHA-256: it is in this answer and nowhere else (never stored, never logged, never in a list). It works once, for 72 hours; at most 100 invitations are open at once. The list shows that an invitation is open, never its link:

GET {{password_url}}/_rustybin/users
Authorization: Bearer {{admin}}
HTTP 200
[Asserts]
jsonpath "$.users[?(@.name == 'rustybin')].first_admin" == true
jsonpath "$.users[?(@.name == 'docs-alice')].status" == "invited"
jsonpath "$.users[?(@.name == 'docs-alice')].invitation.expires_at" exists
jsonpath "$.open_invitations" == 1
body not contains "{{invitation}}"

The person opens the link, chooses a password (8 to 256 characters, not the default) and is signed in. The page is POST /_rustybin/join, open like the sign-in and rate limited the same way (5 failures per client address and minute, 20 from every address together in the invitations' own lane, so junk tokens never hold back a sign-in):

# The person opens the link and chooses a password; the answer signs them in.
POST {{password_url}}/_rustybin/join
Content-Type: application/json
{ "token": "{{invitation}}", "password": "alice-secret-k3Qx" }
HTTP 200
[Captures]
alice: jsonpath "$.token"
[Asserts]
jsonpath "$.user" == "docs-alice"
jsonpath "$.joined" == true
jsonpath "$.token_type" == "Bearer"

# The link works once.
POST {{password_url}}/_rustybin/join
Content-Type: application/json
{ "token": "{{invitation}}", "password": "another-secret-1" }
HTTP 401
[Asserts]
jsonpath "$.reason" == "invalid_invitation"

Your own account

Every signed-in user reaches /_rustybin/me: who they are, their roles and permissions, their display name and email (PATCH), their password (PUT /_rustybin/me/password, with the current one) and their sign-in sessions (GET, DELETE /_rustybin/me/sessions, DELETE /_rustybin/me/sessions/{id}). A password change ends the user's other sessions and answers a fresh token (the first admin's, the instance's sign-in setting, ends every session, as in 0.4). The 0.3 route PUT /_rustybin/password is the same for the caller (and still takes the first admin's new user name); the admin token or a control JWT, which are not users, change the first admin's there only with users.manage.

GET {{password_url}}/_rustybin/me
Authorization: Bearer {{alice}}
HTTP 200
[Asserts]
jsonpath "$.name" == "docs-alice"
jsonpath "$.display_name" == "Alice Doe"
jsonpath "$.roles[0]" == "editor"
jsonpath "$.permissions" contains "mocks.write"
jsonpath "$.permissions" not contains "users.read"
jsonpath "$.sessions" == 1

PATCH {{password_url}}/_rustybin/me
Authorization: Bearer {{alice}}
Content-Type: application/json
{ "display_name": "Alice D.", "email": null }
HTTP 200
[Asserts]
jsonpath "$.display_name" == "Alice D."
jsonpath "$.email" == null

GET {{password_url}}/_rustybin/users
Authorization: Bearer {{alice}}
HTTP 403
[Asserts]
jsonpath "$.reason" == "permission_required"
jsonpath "$.permission" == "users.read"
PUT {{password_url}}/_rustybin/me/password
Authorization: Bearer {{alice}}
Content-Type: application/json
{ "current_password": "alice-secret-k3Qx", "new_password": "alice-secret-2-Pz" }
HTTP 200
[Captures]
alice: jsonpath "$.token"
[Asserts]
jsonpath "$.changed" == true
jsonpath "$.user" == "docs-alice"

GET {{password_url}}/_rustybin/me/sessions
Authorization: Bearer {{alice}}
HTTP 200
[Asserts]
jsonpath "$.count" == 1
jsonpath "$.current" exists

Roles

GET /_rustybin/roles (users.read) lists every role with its permissions, whether it is privileged and how many users hold it, plus the permission table (name, group, summary) the console draws its matrix from. PUT /_rustybin/roles/{name} creates or changes a custom role, POST /_rustybin/roles creates one (409 when the name is taken), DELETE removes one nobody holds. A name has 1 to 40 lower case letters, digits, _ and -; at most 50 custom roles. Roles work in every control-auth mode: a control JWT's rb_roles may name a custom role.

GET {{password_url}}/_rustybin/roles
Authorization: Bearer {{admin}}
HTTP 200
[Asserts]
jsonpath "$.roles[*].name" contains "viewer"
jsonpath "$.roles[?(@.name == 'admin')].privileged" == true
jsonpath "$.roles[?(@.name == 'editor')].users" == 1
jsonpath "$.permissions[0].name" == "instance.read"

PUT {{password_url}}/_rustybin/roles/catalog-reader
Authorization: Bearer {{admin}}
Content-Type: application/json
{ "description": "Reads mocks and traffic", "permissions": ["mocks.read", "traffic.read"] }
HTTP 200
[Asserts]
jsonpath "$.created" == true
jsonpath "$.privileged" == false
jsonpath "$.built_in" == false

A user's roles change with PATCH /_rustybin/users/{id} (an id or the sign-in name); permissions are resolved at every request, so the change applies to the user's next one:

PATCH {{password_url}}/_rustybin/users/docs-alice
Authorization: Bearer {{admin}}
Content-Type: application/json
{ "roles": ["catalog-reader"] }
HTTP 200
[Asserts]
jsonpath "$.roles[0]" == "catalog-reader"

# The next request already has the new permissions.
GET {{password_url}}/_rustybin/me
Authorization: Bearer {{alice}}
HTTP 200
[Asserts]
jsonpath "$.permissions" count == 2

POST {{password_url}}/_rustybin/mocks
Authorization: Bearer {{alice}}
Content-Type: application/json
{ "name": "nope", "spec": "openapi: 3.0.3\ninfo: {title: x, version: '1'}\npaths: {}\n" }
HTTP 403
[Asserts]
jsonpath "$.permission" == "mocks.write"

The guard rails

  • The last enabled user with the admin role is never disabled, demoted or deleted (409 last_admin).
  • Nobody changes their own roles (403 own_roles): ask someone else who manages users.
  • The first admin is never deleted (409 first_admin): its sign-in is the instance's sign-in settings; disable it instead.
  • A custom role somebody holds is not deleted (409 role_in_use); a built-in role never changes (400 built_in).
  • Nobody grants more than they hold: a caller gives a user only roles whose permissions it holds, manages (changes, disables, deletes, resets, ends a session of) only users whose permissions it holds, and saves only roles within its own. An admin holds every permission; this binds a custom role with users.manage. The 403 names the first permission missing. Signing everyone out (DELETE /_rustybin/sessions) needs every permission, and mapping a provider's group to a role (sso.role_map, sso.default_roles) needs the role's permissions.
  • An invited user joins through the invitation, never by being enabled (409 invited).
  • In a project the same rules hold for a user's roles there, and the last enabled admin is counted instance-wide: a project's admin role never keeps nor replaces one. A custom role that a project's member holds is in use too.

Roles in projects: POST /_rustybin/users takes projects ([{project, roles}]); with some, the instance roles may be empty and the user sees those projects only. Each user's answer lists their projects (sso: true for roles a single sign-on group gives). See Projects.

PATCH {{password_url}}/_rustybin/users/rustybin
Authorization: Bearer {{admin}}
Content-Type: application/json
{ "roles": ["viewer"] }
HTTP 403
[Asserts]
jsonpath "$.reason" == "own_roles"

DELETE {{password_url}}/_rustybin/users/rustybin
Authorization: Bearer {{admin}}
HTTP 409
[Asserts]
jsonpath "$.reason" == "first_admin"

DELETE {{password_url}}/_rustybin/roles/catalog-reader
Authorization: Bearer {{admin}}
HTTP 409
[Asserts]
jsonpath "$.reason" == "role_in_use"

Resets, sessions, disabling

A forgotten password is a new invitation: POST /_rustybin/users/{id}/invite answers a new link (a reset) that replaces the open one. The old password works until the link is accepted; accepting it ends the user's sessions. The first admin's password is a sign-in setting: while RUSTYBIN_SETTINGS_LOCK holds it, their reset link is refused (409 locked) before it is used, so the link stays valid and nobody is signed out.

POST {{password_url}}/_rustybin/users/docs-alice/invite
Authorization: Bearer {{admin}}
HTTP 201
[Captures]
reset: jsonpath "$.invitation.token"
[Asserts]
jsonpath "$.invitation.reset" == true

# The old password works until the link is accepted.
POST {{password_url}}/_rustybin/login
Content-Type: application/json
{ "username": "docs-alice", "password": "alice-secret-2-Pz" }
HTTP 200

POST {{password_url}}/_rustybin/join
Content-Type: application/json
{ "token": "{{reset}}", "password": "alice-secret-3-Qw" }
HTTP 200
[Asserts]
jsonpath "$.reset" == true

# Accepted: the old password and the old sessions are gone.
POST {{password_url}}/_rustybin/login
Content-Type: application/json
{ "username": "docs-alice", "password": "alice-secret-2-Pz" }
HTTP 401

GET {{password_url}}/_rustybin/me
Authorization: Bearer {{alice}}
HTTP 401

GET /_rustybin/users/{id}/sessions lists a user's sessions, DELETE signs them out everywhere. A user has at most 16 listed sessions: a sign-in past them ends the user's oldest, so one user signing in again and again never pushes out another's:

GET {{password_url}}/_rustybin/users/docs-alice/sessions
Authorization: Bearer {{admin}}
HTTP 200
[Asserts]
jsonpath "$.count" == 1

DELETE {{password_url}}/_rustybin/users/docs-alice/sessions
Authorization: Bearer {{admin}}
HTTP 200
[Asserts]
jsonpath "$.ended" == 1

Disabling a user ("disabled": true) ends their sessions at once and drops their open invitation; their sign-in gets the same answer as a wrong password, so nobody learns the account exists. Enabling them again does not bring an old token back. Disabling or deleting a user also revokes every AI agent acting for them (their sign-in and OAuth agents: Agents act for a user); enabling the user again leaves those agents revoked until someone restores them.

PATCH {{password_url}}/_rustybin/users/docs-alice
Authorization: Bearer {{admin}}
Content-Type: application/json
{ "disabled": true }
HTTP 200
[Asserts]
jsonpath "$.status" == "disabled"

# A disabled user gets the answer of a wrong password.
POST {{password_url}}/_rustybin/login
Content-Type: application/json
{ "username": "docs-alice", "password": "alice-secret-3-Qw" }
HTTP 401
[Asserts]
jsonpath "$.reason" == "invalid_credentials"

As code

rustybin.yaml carries roles: (the custom roles) and users: (name, display name, email, roles, disabled; never a password or a hash: a document with one does not load that section). Applying needs users.manage. A user the document creates is invited and the apply answers the link to send them (a user it creates disabled gets none until enabled; a file loaded at startup has nobody to answer, so its new users wait for POST /_rustybin/users/{id}/invite). With prune, users and custom roles the document does not name are deleted, but never the first admin, the applying user, the last enabled admin, or a role somebody still holds.

# rustybin.yaml carries users: and roles: (never a password): a user the
# document creates is invited, and the answer has the link.
POST {{password_url}}/_rustybin/config/apply
Authorization: Bearer {{admin}}
Content-Type: application/json
{ "document": "version: 2\nroles:\n- name: catalog-reader\n  description: Reads mocks and traffic\n  permissions: [mocks.read, traffic.read]\nusers:\n- name: docs-bob\n  display_name: Bob\n  roles: [catalog-reader]\n" }
HTTP 200
[Asserts]
jsonpath "$.ok" == true
jsonpath "$.changes[*].key" contains "docs-bob"
jsonpath "$.results.users.created[0]" == "docs-bob"
jsonpath "$.results.users.invitations[0].url" contains "/ui/#/join/rbi_"

GET {{password_url}}/_rustybin/config/export?format=json
Authorization: Bearer {{admin}}
HTTP 200
[Asserts]
jsonpath "$.users[?(@.name == 'docs-bob')].roles[0]" == "catalog-reader"
jsonpath "$.roles[0].name" == "catalog-reader"
body not contains "argon2"

A document pulled from source control is untrusted: anyone who can push would otherwise make themselves admin. It changes display names and emails only. A new user, a change of a user's roles or of disabled, a prune of users, and a privileged role defined, changed or pruned are reported in problems and kept as they are.

In the console

Management, Users and roles: the users with their roles, status and last sign-in; Invite with the link to copy (shown once); per user Roles, Disable or Enable, Reset (or New link while invited) and delete; the roles' permission matrix with the privileged roles marked; a form for custom roles. The account menu (your name in the top bar) opens My account: your profile, your permissions, your password and your sessions. The link of an invitation opens the console's join page, which takes the token out of the address bar at once. Invite a portal reader invites with the portal_reader role alone: the link opens the API portal, and a console sign-in with that login is sent there.

Limits

WhatLimit
Users500, in <state>/users.json (mode 0600; in memory without a state directory)
Open invitations100, 72 hours each, one per user
Custom roles50, 1 to 40 characters a name, 200 a description
Roles per user16
Display name, email100 and 254 characters

On every surface

SurfaceWhere
APIGET, POST /_rustybin/users; GET, PATCH, DELETE /_rustybin/users/{id}; POST /_rustybin/users/{id}/invite; GET, DELETE /_rustybin/users/{id}/sessions; GET, POST /_rustybin/roles; GET, PUT, DELETE /_rustybin/roles/{name}; GET, PATCH /_rustybin/me; PUT /_rustybin/me/password (and the 0.3 PUT /_rustybin/password); GET, DELETE /_rustybin/me/sessions, DELETE /_rustybin/me/sessions/{id}; POST /_rustybin/join (open)
ConsoleManagement, Users and roles; the account menu's My account; the join page an invitation link opens
CLIrustybin users list, invite, show, update, disable, enable, sessions, delete; rustybin roles list, show, save, delete; rustybin me (update, sessions, end-session); rustybin passwd (reference)
Management MCPlist_users, invite_user (confirmed; answers the link once), update_user (confirmed when it grants a privileged role), delete_user (confirmed), list_roles, save_role (confirmed when privileged), delete_role; list_sessions and end_session with user. No tool takes or returns a password or a hash (agent page)
rustybin.yamlusers: and roles: (instance as code)