Skip to content

Authentication

Two kinds of callers: API tokens (CLI, scripts, agents, MCP) and sessions (the console, a person in a browser). Both resolve to a principal with a workspace, an optional project, and a set of scopes.

Endpoints: Sign-in and account (sign-in, sessions, MFA, single sign-on), API tokens (token management).

Authorization: Bearer myd_<52 lowercase base32 characters>
  • Secrets start with myd_. Only a SHA-256 hash is stored; the secret is shown once, in the response to POST /v1/tokens. Lists show a prefix (myd_ + 6 characters) to recognize a token.
  • A token belongs to one workspace (the one it was created in) and optionally one project. X-Mayadyn-Tenant is ignored for tokens.
  • Effective scopes = scopes given at creation ∩ scopes of the creator’s current role. Demoting the creator narrows every token they made.
  • A token stops working when it is revoked, expires, or its creator is no longer an accepted member of the workspace.
  • A token is never a session: it cannot sign out, change account settings (MFA, linked identities), create workspaces, answer invitations, change workspace sign-in rules or SSO, or remove its own user from the workspace.
  • last_used_at is updated at most once a minute.

An invalid, expired or revoked token:

{"code": "unauthenticated", "message": "the API token is invalid, expired or revoked",
"hint": "Create a new token in the console under API tokens."}

A header that is not Bearer …, or a bearer value that does not start with myd_: 401 unauthenticated “sign in or send an API token”.

A token with the admin scope can create tokens (POST /v1/tokens):

  • The child’s scopes must be a subset of the parent’s effective scopes (otherwise 403 “you cannot grant the X scope you do not have”).
  • A project token can only create tokens for its own project; the child gets that project even if project_id is omitted.
  • The child never outlives the parent: its expiry is capped at the parent’s.
  • The child stops working when any token up its chain is revoked or expires (checked on every request, up to 32 levels).
  • The child carries the parent’s sign-in factors (see workspace rules below).

A token created with project_id:

  • sees only its project’s connections, resources, apps, operations and tokens;
  • GET /v1/projects returns only its project;
  • is refused (403 permission_denied “a project token cannot manage the whole workspace”) on: GET/POST /v1/members, PATCH/DELETE /v1/members/{user_id}, POST /v1/projects, DELETE /v1/projects/{id}, GET /v1/audit, PATCH /v1/tenant, GET/PUT/DELETE /v1/tenant/sso;
  • new connections go to its project (a project_id naming another project is not found).

POST /v1/auth/login (or sign-up, MFA completion, or a single sign-on callback) sets the session cookie:

Name __Host-mayadyn_session
Value mys_… (opaque; only its hash is stored)
Attributes Path=/, HttpOnly, Secure, SameSite=Strict
Lifetime 7 days, sliding: renewed to 7 days when used after more than an hour

A session’s scopes come from the person’s role in the workspace named by X-Mayadyn-Tenant.

X-Mayadyn-Tenant: acme # slug, or
X-Mayadyn-Tenant: 6f1c2a9e-3b7d-4c1e-9a52-1d8e4b7f0c31 # workspace id
  • Required on every workspace route for sessions; without it: 400 tenant_required “this request needs a tenant”, hint “Send the X-Mayadyn-Tenant header with a tenant slug from GET /v1/me.”
  • Naming a workspace the person is not an accepted member of (or one that does not exist): 404 not_found “tenant not found”, on any route, including account routes.
  • Account routes (/v1/me, /v1/auth/*, /v1/tenants, /v1/invitations*) work without it.
X-Mayadyn-CSRF: 1
  • Required on every cookie-authenticated request whose method is not GET or HEAD. Missing: 403 csrf “missing X-Mayadyn-CSRF header”. Browsers cannot add a custom header cross-site without a CORS preflight, which Mayadyn never grants.
  • Always required on POST /v1/auth/signup, /login, /verify and /mfa, cookie or not.
  • Not needed with a bearer token.
Scope Endpoints that require it
read GET on tenant, members, projects, connections (incl. /setup), resources, apps (incl. releases, logs), operations, audit, tenant SSO; DELETE /v1/members/{own user id} (leaving)
write POST /v1/vms, POST /v1/vms/{id}/start, /stop, POST /v1/connections/{ref}/verify, /sync, POST /v1/apps, /deploy, /rollback, PUT /v1/apps/{ref}/secrets
destroy DELETE /v1/vms/{id}, DELETE /v1/apps/{ref}
destroy + admin DELETE /v1/connections/{ref}
admin POST /v1/connections, PUT /v1/connections/{ref}/credentials, POST /v1/members, PATCH /v1/members/{user_id}, DELETE /v1/members/{other user}, POST /v1/projects, DELETE /v1/projects/{id}, GET/POST /v1/tokens, DELETE /v1/tokens/{id} (any token), PATCH /v1/tenant
none GET /v1/catalog, GET /v1/me, account routes

POST /v1/connections and PUT /v1/connections/{ref}/credentials need admin; the verification they run is part of the call (an on-demand POST /v1/connections/{ref}/verify needs write). See Connections.

A missing scope:

{"code": "permission_denied", "message": "this action needs the write permission",
"hint": "Use a token with the write scope, or ask a tenant admin to raise your role."}

Every 403 on a workspace route is recorded in the workspace’s audit log as request.denied with the method and route pattern (not the body).

Role Scopes Also
owner read, write, destroy, admin only owners add, promote to, demote from or remove owner; only owners change workspace SSO
admin read, write, destroy, admin
operator read, write cannot create tokens (needs admin)
viewer read

A workspace always keeps at least one accepted owner (409 conflict “a tenant needs at least one owner”).

A workspace can require two-step sign-in (require_mfa) and/or its own single sign-on (require_sso); see Workspace and Workspace single sign-on. They apply to every request that acts in the workspace, by session or token.

On workspace routes, a session that does not meet a rule gets:

Code Status Condition Hint
sso_required 403 require_sso and the session did not sign in through this workspace’s SSO “Sign in at /v1/auth/sso/<slug>/start (the console’s SSO button).”
mfa_required 403 require_mfa and the session has no second factor that counts here “Turn on two-step sign-in under Security, then sign in again.”

A second factor counts when the session used Mayadyn’s own TOTP or a recovery code, or signed in through this workspace’s SSO and the identity provider asserted MFA (amr contains mfa). Another workspace’s IdP, or Google/Microsoft sign-in, does not count.

Account routes still work, so the person can turn MFA on.

Judged by how the session that created the token signed in (a child token inherits its parent’s):

{"code": "sso_required", "message": "this workspace requires single sign-on, and this token was not created through it",
"hint": "Create a new token from a session signed in with the workspace's single sign-on."}
{"code": "mfa_required", "message": "this workspace requires two-step sign-in, and this token was created without it",
"hint": "Create a new token from a session signed in with two-step sign-in."}

Turning a rule on therefore disables existing tokens that do not meet it.

A session that signed in only through a workspace’s SSO is confined to that workspace:

  • X-Mayadyn-Tenant naming any other workspace: 404 not_found.
  • GET /v1/me lists only that workspace.
  • Account changes are refused (403 “a workspace single sign-on session cannot change account settings”): TOTP setup/enable/disable, listing or unlinking identities, linking new sign-ins, creating workspaces, answering invitations, PUT /v1/tenant/sso.

GET /v1/me returns session_amr: how the session signed in.

Value Meaning
password email and password
oidc:google, oidc:microsoft global sign-in provider
sso:<workspace id> that workspace’s single sign-on
idp_mfa the identity provider asserted MFA
totp Mayadyn TOTP code
recovery Mayadyn recovery code