Skip to content
Directory & LifecycleMarkdown

Turn access off and on

Stop a user's sign-in and tokens at once with one field, or from a date you set, and give everything back by setting it again.

AvailableAPI

Two fields on every user decide whether they may sign in: status and accountExpiry. Set status to inactive, or let accountExpiry pass, and from that moment the user can’t sign in and no app can get a new token for them, anywhere in the realm. Nothing about them is removed, so setting them active again gives back everything they had.

  • Privilege: RealmOwner in the realm, or a privilege of your own that may change users. See Who may do what.
  • Where: the API, with your session in $CVYUH_SESSION (see Call the API).
  • The user exists. Both fields are on the shipped user type; nothing needs adding.

A user may sign in only while their status is active and their accountExpiry, if set, is still in the future. Once either stops being true:

  • their sign-in is refused;
  • no app can get a new token for them, and their refresh tokens stop working;
  • token introspection reports their tokens as inactive, and the userinfo endpoint stops answering for them.

Set status back to active, or move accountExpiry later, and they can sign in again. Their groups, entitlements, secrets and agents are where they left them.

Expiry is checked at the moment of use. Nothing runs at the expiry time; each sign-in and each token request compares it with the clock. That makes accountExpiry the simplest way to give a contractor or an intern access that ends by itself.

Setting a user inactive stops every new token at once, and every refresh. An access token issued before then is a signed token that an app can check by itself, so it stays valid, at an app that checks it that way, until it expires. Access tokens are short-lived (five minutes unless your realm sets otherwise; see Access tokens). An app or API that introspects each token sees it as inactive at once.

Turn a user’s access off:

Terminal window
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d '{ "status": "inactive" }'

Send { "status": "active" } to turn it back on.

End a user’s access at a set time, written as an RFC 3339 time with its offset, such as 2027-03-31T18:00:00Z:

Terminal window
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d '{ "accountExpiry": "2027-03-31T18:00:00Z" }'

Then read the user back and check that accountExpiry holds the time you meant. Send { "accountExpiry": null } to remove the expiry; leave it out altogether for access with no end.

  • At sign-in, an inactive or expired user is refused with 401 and the code INVALID_CREDENTIALS, the same status and code as a wrong password. An app signing them in through OAuth gets access_denied. The reason is kept for you, on the audit trail (below); tell the user yourself, if they should know.
  • In an app they’re already signed in to, nothing changes until the app needs a new token. Then the app is refused with invalid_grant, and the user is sent to sign in again, which fails. The userinfo endpoint answers the app 401 (invalid_token). Sessions already open stay open until they end or you end them.
  • An agent acting for them gets no new token for them.
WhatDefaultRange
statusactive, filled on every write that leaves it outactive or inactive; anything else is refused 400
accountExpiryNot set: no endAn RFC 3339 time with its offset
How soon a change takes effectAt the next sign-in, token request or refresh
An access token already issuedValid until it expires, at apps that check it themselvesFive minutes by default
  • The change itself is recorded as PATCHED (or UPDATED for a PUT), with status or accountExpiry before and after, in the user’s change history.
  • Each refused sign-in is recorded as LOGIN_FAILED under the user’s id, with the reason: AUTH_USER_INACTIVE for an inactive user, AUTH_ACCOUNT_EXPIRED for one past their expiry. The reason is on the audit trail only, never in the answer to the sign-in. See What is recorded.
  • Each refused token request is recorded as TOKEN_ISSUED, with why it was refused.
SymptomCauseFix
A user past their accountExpiry can still sign inThe time isn’t an RFC 3339 time with an offset (for example 2027-03-31 or 31/03/2027), so the realm can’t read itWrite it again as 2027-03-31T18:00:00Z, and read it back
An inactive user is still using an appThe app holds a session or an access token issued before you set them inactiveEnd their sessions (see Offboard a leaver); the access token ends within its lifetime
A user you didn’t change can’t sign inTheir record has no status, which reads as inactive. This happens only to a record written without the realm filling itSet { "status": "active" }
A write of status is refused 400A value other than active or inactiveSend one of the two
  • Sessions already open are not ended. Sign-in and token issue stop at once, but a session the user already holds stays until it ends or you end it. To end it now, see Offboard a leaver.
  • A missing status reads as inactive. The realm fills active on every write that leaves it out, so this only matters for a record written some other way: it is refused at sign-in, not let through.
  • Agents follow their user. An agent acting for an inactive user gets no new token for them. An agent the user owns has an identity of its own, and goes on until you stop it: see Stop an agent.
  • Inactive is reversible; delete isn’t. Deleting a user removes them, every link to them and their personal vault, and leaves the agents they owned without an owner. Keep them inactive while you may need them back, or need their record for an audit.