Skip to content
Directory & LifecycleMarkdown

The identity model

How the directory is built, users, groups and agents as types linked to each other, and the one API that reads and writes them all.

AvailableAPIJSON Schema 2020-12, RFC 7396, RFC 6902, RFC 9110

Everything in the directory is an object of a type. Users, groups and agents are the three types every realm starts with; a type of your own, such as a cost center or a department, works exactly the same way. Learn the pattern once and you can read and write anything the realm keeps.

Humans and agents live in the same directory, side by side. A user can own an agent, an agent can act for a user, and both are found, linked and audited through the same calls. See Agents in the directory.

  • Privilege: RealmViewer to read; RealmOwner, or a privilege of your own, to write. The table in Who may do what has the detail.
  • Where: the API, with your session in $CVYUH_SESSION (see Call the API).

Each type is a JSON Schema (draft 2020-12) that lists its attributes, the kind of value each one takes, and its links, the attributes that point at objects of another type. It also carries policies, the rules every write must pass, such as “uid is required and unique”.

Besides its profile and groups, a user carries what other products keep about them: the entitlements they hold, their second factors, their session limits, their vault and their devices. See Add and change users.

Each realm has its own copy of these types, made when the realm was created. You can add to your realm’s copy, as long as you keep every shipped attribute on it. See Attributes and validation and Custom types.

An object is an id, a revision and attributes

Section titled “An object is an id, a revision and attributes”

Every object answers in the same shape:

{
"id": "<internal id>",
"objectId": "maya",
"typeName": "user",
"rev": 4,
"attributes": { "uid": "maya", "email": "maya@example.com", "status": "active" },
"createTime": "<RFC 3339 time>",
"updateTime": "<RFC 3339 time>"
}

objectId is the id you name the object by in every address. rev goes up with every change; the realm also sends it as the ETag header, and you send it back in If-Match so that a write made over someone else’s change is refused (412) rather than lost.

Section titled “A link is stored once and read from both ends”

A link joins two objects and is stored once. A group’s member and a user’s memberOf are the two ends of the same links; an agent’s businessOwner and a user’s ownedAgents are another pair. Add a link from either end and both change, in one step. A link can carry properties of its own, such as the window on an entitlement grant.

Reads leave links out unless you ask for them with expand: ?expand=memberOf for the links themselves, ?expand=memberOf/* for the objects they point at. Each expanded link carries the far object’s objectId, its type and its attributes in object.

Each object keeps its own history: /objects/v1/{type}/{id}/history lists every change to it, newest first, 50 to a page unless you set pageSize (at most 500). The entries come from the realm’s audit trail (see Change history), and leave out every value no read would show, such as a password. One entry, for Maya’s phone number changed:

{
"id": "<record id>",
"eventType": "PATCHED",
"eventTime": "<RFC 3339 time>",
"objectId": "<internal id>",
"changedBy": "<administrator's id>",
"subjectRev": 5,
"changedFields": ["telephoneNumber"],
"before": { "uid": "maya", "telephoneNumber": "+44 20 7946 0000" },
"after": { "uid": "maya", "telephoneNumber": "+44 20 7946 0999" },
"edgeChanges": null
}

eventType is CREATED, PATCHED, UPDATED (a PUT, or a link added or removed, listed in edgeChanges) or DELETED. Entries also carry the request’s trace identifiers. The history is kept for the life of the realm, like the rest of the audit trail, with nothing to set: see Retention and clean-up. A deleted object’s history can’t be read at its address any more, but its records stay on the trail.

Every call here is checked against what the caller may administer in the realm, from the privileges their groups hold (see Delegated administration). Reads (GET, QUERY) need READ; every other call needs MODIFY.

ToPrivilege that’s enough
Read and search users, groups, agents and types, and read historyRealmViewer
Create, change, link and delete objects; change types and the identity bindingRealmOwner
A narrower role, such as “may change users and nothing else”A privilege of your own, with a template such as *REALM/identitySource/user/* and MODIFY

The shipped user and group are administered as identitySource (*REALM/identitySource/user/*, *REALM/identitySource/group/*); every other type, agent and your own included, as entity (*REALM/entity/agent/*), and type definitions as *REALM/entity/type/*. A call outside the caller’s privileges is refused 403. Every page in this docset names the privilege it needs under Before you begin.

There’s nothing to turn on. Every type is reached at the same addresses, as a realm administrator with your session in $CVYUH_SESSION (see Call the API). On https://foobar.cvyuh.com/api/v0/am:

ToCall
List the realm’s typesGET /types/v1
Read one typeGET /types/v1/{type}
CreatePOST /objects/v1/{type}?id={id}, or PUT /objects/v1/{type}/{id} with If-None-Match: *
List and searchGET /objects/v1/{type}. See Search and paging
ReadGET /objects/v1/{type}/{id}
Change some attributesPATCH /objects/v1/{type}/{id}: an object is a merge patch, a list a JSON Patch
Replace all of themPUT /objects/v1/{type}/{id} with If-Match
DeleteDELETE /objects/v1/{type}/{id} with If-Match
LinkPOST /objects/v1/{type}/{id}/relationships/{link} with { "targetId": "{id}" }
List linksGET /objects/v1/{type}/{id}/relationships/{link}
UnlinkDELETE /objects/v1/{type}/{id}/relationships/{link}/{target id}
Read the historyGET /objects/v1/{type}/{id}/history

For example, Maya’s history:

Terminal window
curl https://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya/history \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
WhatDefault or limit
A list’s page20 objects unless you set pageSize, at most 100; a larger pageSize is cut to 100
A history page50 entries unless you set pageSize, at most 500
Links returned by expandAt most 10,000 per link attribute; past that the read is refused 413, and you page the links instead
Depth of nested expansion4 levels
A request bodyAbout 2 MB; a larger one is refused 400
Attributes per type, value sizeNo fixed cap; give an attribute max-length to bound it
Rate of callsNo rate limit today; see Bring users in for pacing a load

Every refusal answers a JSON body { "code", "message", "detail" }:

AnswerCodeWhat it means
400POLICY_VIOLATION, SCHEMA_VALIDATION_FAILEDA rule of the type, or its schema, refused the write; detail names each failure
400INVALID_REQUESTThe request itself is malformed: bad JSON, an unknown filter field, a malformed If-Match
403FORBIDDENThe caller’s privileges don’t cover the call
404NOT_FOUNDNo such object or type
405METHOD_NOT_ALLOWEDA type was patched or deleted
409ALREADY_EXISTSThe id is taken
412REVISION_CONFLICTIf-Match named a revision that’s no longer current, or If-Match: * an object that isn’t there
413PAYLOAD_TOO_LARGEAn expand would return more than 10,000 links
428PRECONDITION_REQUIREDA type was saved without If-Match

Every write to an object is on the audit trail and in its history: CREATED, PATCHED, UPDATED (a PUT, or a link made or removed) and DELETED. A type’s definition being created or saved is recorded as CREATED or UPDATED, with the definition before and after. See What is recorded.

  • If-Match: * asks only that the object exists. It writes whatever the revision is now, and answers 412 if the object isn’t there. A malformed If-Match is refused 400.
  • Creating with an id that’s taken is refused. Leave out ?id= and the realm makes an id for you.
  • What you can see is what you may read. Every call is checked against what the caller may administer in the realm; see Who may do what.
  • Your realm’s types are its own copies. Its user, group and agent were made from the shipped definitions when the realm was created, so an improvement to the shipped types doesn’t reach a realm that already exists. See What’s next for attributes.
  • An attribute the type doesn’t define is stored as sent, unchecked and not searchable. Define what you write.
  • Every body is JSON, sent as Content-Type: application/json.