Product access (Enterprise)
Adjust Square has three products: ContentsCapture, ContentsVision and ContentsEstimation. ContentsEstimation is the source of truth for who may open what. This page is the ContentsVision half of that (Jira AS-1602 and AS-1603, epic AS-1596).
- SMB customers are unchanged. One account opens all three products. Nothing on this page applies to them: no record is ever pushed, nothing is refused, and the product switcher shows every product, as it always has.
- An Enterprise deployment gets an access layer that only ever restricts, with four switches per person per team: the ContentsCapture app, the ContentsCapture admin console, ContentsVision, and ContentsEstimation. Only Adjust Square platform staff change them, in ContentsEstimation, where every change is audited.
ContentsVision does not ask ContentsEstimation anything at sign-in. ContentsEstimation pushes each person's record here, ContentsVision keeps its own copy, and every decision is made from that copy. So neither app needs the other to be reachable to decide what to show or refuse.
What ContentsVision recorded before this
Nothing per person and per product. For the record, as found in the code before AS-1602:
- A user row is created the first time a valid Adjust Square format JWT arrives (
core/auth_deps.py). Anyone holding a valid token for the deployment got in. users.is_activeexists and defaults to true, but nothing ever set it to false and sign-in never read it. It only filters the assignee list and a training report.- What a person may do inside ContentsVision is the access profile (
access.profile,access.overrides), and the internal admin allowlist (ADMIN_EXTERNAL_USER_IDS). Neither says whether the person may open the product at all.
The pushed record
Agreed between the three products. ContentsVision ignores unknown extra fields, so the sender may add one without breaking it.
{
"ce_team_id": "11111111-1111-4111-8111-111111111111",
"ce_user_id": "33333333-3333-4333-8333-333333333333",
"enterprise": true,
"active": true,
"access": {"capture_app": true, "capture_admin": false, "vision": true, "estimation": true},
"urls": {
"estimation": "https://ce.customer.example",
"vision": "https://cv.customer.example",
"capture_admin": "https://capture-admin.customer.example"
},
"version": 7,
"updated_at": "2026-11-18T19:04:11Z"
}
| Field | Rule here |
|---|---|
ce_team_id, ce_user_id | UUIDs. Required. |
email | Required. Trimmed and stored in lower case. |
enterprise, active, the four access switches | Real JSON booleans, all required. "yes" or 1 is rejected. |
urls.estimation | Required. An http(s) address, or "". |
urls.vision | An http(s) address, "" or null. |
urls.capture_admin | An http(s) address or "". |
version | Integer, 0 or more. Only ever increases for a person and team. |
updated_at | ISO 8601. Stored as naive UTC. |
ce_team_legacy_id | Optional, not in the agreed shape. The integer team id (see Which team). |
Anything that is not an http(s) address in urls is rejected, not stored: these values become links in the app.
The push routes
All three are machine to machine, with no user session. They are authenticated exactly like the Contents Capture provisioning route ContentsEstimation already calls: Authorization: Bearer <CONTENTS_CAPTURE_PROVISIONING_SECRET> (the value ContentsEstimation holds as CONTENTSVISION_PROVISIONING_SECRET), compared with hmac.compare_digest. 503 when the secret is not set on this server, 401 on a mismatch. Code: api/routes/product_access.py.
GET /api/integrations/product-access/capabilities
What this ContentsVision accepts. A ContentsVision from before AS-1602 has no such route and answers 404, which is how a sender tells it apart and does not push to it.
{
"service": "contentsvision",
"product_access": {
"version": 1,
"single": true,
"batch": true,
"max_batch": 500,
"enforces": ["vision", "active"],
"optional_fields": ["ce_team_legacy_id"]
}
}
product_access.version is the contract version (services/product_access.CONTRACT_VERSION), bumped when the contract changes in a way a sender must know about.
POST /api/integrations/product-access
Body: one record. Answers:
| HTTP | result | Meaning |
|---|---|---|
200 | stored | The record is now what this app holds. |
200 | ignored_older | This app already holds this version or a newer one. Nothing changed. stored_version says which. |
422 | rejected | The record is not valid. Nothing changed. reason is invalid_record and message names each wrong field (never a value). |
Same body shape for all three:
{
"result": "stored",
"ce_team_id": "11111111-1111-4111-8111-111111111111",
"ce_user_id": "33333333-3333-4333-8333-333333333333",
"stored_version": 7,
"reason": null,
"message": null
}
A version equal to the stored one is ignored_older too ("not newer"), so re-sending the same record is safe and changes nothing. stored_version is null on a rejected record.
POST /api/integrations/product-access/batch
Body: {"records": [ ...records... ]}, at most 500 (413 beyond that; 422 when there is no records list). This is the reconcile run. Always 200 when the envelope is readable: each record gets its own answer, in request order, and one bad record never stops the others. Each record is committed on its own.
{
"results": [
{"index": 0, "result": "stored", "ce_team_id": "...", "ce_user_id": "...", "email": "[email protected]", "stored_version": 1, "reason": null, "message": null},
{"index": 1, "result": "ignored_older", "ce_team_id": "...", "ce_user_id": "...", "email": "[email protected]", "stored_version": 9, "reason": null, "message": null},
{"index": 2, "result": "rejected", "ce_team_id": "...", "ce_user_id": "...", "email": "[email protected]", "stored_version": null, "reason": "invalid_record", "message": "version: Input should be a valid integer"}
],
"counts": {"stored": 1, "ignored_older": 1, "rejected": 1}
}
index is the record's position in the request, from 0. On a rejected record the three identifying fields are echoed as sent when they were text, else null.
What is stored
Table product_access (models/product_access.py), one row per (ce_team_id, email), see the data model. It holds all four switches, active, enterprise, the three addresses, version, updated_at and when this app received it.
- Keyed by email, not by a users row. A record for somebody who has never signed in to ContentsVision is stored like any other and applies the moment they first arrive. Nothing is created in
usersorteamsby a push. - A person is found by
ce_user_idfirst, then by email, within the team. So a person whose email changed in ContentsEstimation keeps one row, with the new email. - Nothing in this app edits a row. Only the push routes write the table.
Which team a record applies to
ContentsVision knows a ContentsEstimation team only by an integer: the sign-in token's current_team_id, which is Team.legacy_id in ContentsEstimation and teams.external_id here. The agreed record names the team by its UUID, which nothing in ContentsVision can be matched against. So:
- A record that carries the optional
ce_team_legacy_idapplies only when the person is signed in on that team. This is the precise, per team behaviour, and the sender should include it. - A record without it applies on whatever team the person signs in on. If the person has several such records (several teams), the most restrictive wins: a switch that is off in any of them is off, and the addresses come from the newest. That is the safe reading of a layer that only restricts.
- A record for the exact team always beats the team-less ones. A record for a different named team does not apply.
Once a row has learned its ce_team_legacy_id, a later push without the field keeps it.
Who is refused, and when
core/auth_deps.py _refuse_if_access_off, called from get_current_user, so on every authenticated request:
visionfalse:403, headerX-Access-Denied: vision_access_off, detail "Your access to ContentsVision is switched off. If you think this is a mistake, email [email protected]."activefalse:403, headerX-Access-Denied: account_inactive, detail "Your account is deactivated. If you think this is a mistake, email [email protected]."- No stored record, or a record with
enterprisefalse: nothing is checked and nothing changes.
Because it is in the one dependency every signed-in route passes through, it does not matter how the person arrived: the ContentsEstimation hand-off, a direct sign-in at this deployment's own address, a shared cookie, or the local sign-in bypass. (ContentsEstimation also refuses to hand a person off when their switch is off; that is a courtesy. This is the lock.) On a JWT sign-in the check runs before the user and team are found or created, so a refused newcomer leaves no rows behind.
The other three switches are stored for the product switcher only. ContentsVision does not enforce another product's switch.
Never restricted: internal admins (the ADMIN_EXTERNAL_USER_IDS allowlist, that is Adjust Square staff), and an admin's impersonation session (a token carrying impersonated_by), the same as in ContentsEstimation.
How quickly an already signed-in person loses access
- On the server: at once. Their very next request after the push is stored is refused. There is no cache and no token to wait out.
- In an open browser tab: within 60 seconds, without the person doing anything.
lib/auth.tsxasksGET /api/auth/accessonce a minute (ACCESS_CHECK_MS) while the tab is visible, and as soon as a hidden tab is looked at again. Any click that calls the API in the meantime is refused immediately.
Either way the browser recognises the X-Access-Denied header (accessDeniedReason in lib/sessionGuard.mjs, watched by components/SessionGuard.tsx on every /api/* response except /api/public/*), clears the local session (handleAccessOff in lib/session.ts, which also records the PostHog access_off event) and shows the public page /no-access: a plain sentence and [email protected]. That page makes no API call, so it cannot loop. Restoring access (a newer push) lets the person sign in again straight away.
GET /api/auth/access returns {"product_access": ...} and nothing else. It exists because GET /api/auth/me writes a "Signed in" activity row when called with a bearer token, which a once-a-minute check must not do.
The product switcher (AS-1603)
GET /api/auth/me (and /api/auth/access) carry product_access:
{
"enterprise": true,
"products": {"capture_app": true, "capture_admin": false, "vision": true, "estimation": false},
"urls": {"estimation": "https://ce.customer.example", "vision": "https://cv.customer.example", "capture_admin": "https://capture-admin.customer.example"}
}
It is null when nothing applies: no record, an SMB person, or an internal admin.
components/ProductSwitcher.tsx is the one "Switch product" menu in the top left corner (it existed before, with links picked by hostname; AS-1603 extended it, there is no second menu). What it lists is the pure function switcherMenu(access, hostUrls) in lib/productLinks.mjs:
| Listed | |
|---|---|
product_access is null | ContentsVision, ContentsCapture, ContentsEstimation, linked from the hostname table. No "Guides and training". Exactly as before. |
| a record applies | ContentsVision (always, marked current, even when it is the only one left); ContentsCapture only when capture_admin is true (the entry opens the admin console; the phone app is not a link); ContentsEstimation only when estimation is true; then Guides and training, which opens <urls.estimation>/start. |
- Addresses come from the record's
urls. A missing or unusable one falls back to the hostname table. - A switch counts as on only when it is exactly
true. - The menu follows a change within a minute (the same check as above), with no reload.
- Clicking ContentsEstimation asks
GET /api/sso/contents-estimation/authorizefor the hand-off address and goes there when it leads to the same site as the entry, so the person arrives signed in. If the hand-off is not set up, is slow, or points elsewhere, the plain link is used. - Each row shows that product's kit mark (
frontend/public/brand/<product>/*-mark.svg, the transparent mark with no tile), not a generic icon. The kit solids are ContentsVision#8A6FF8(gradient#A897FFto#6A4CF0), ContentsCapture#FF7410(gradient#FFA41Cto#FA4A00), ContentsEstimation#1E8CF2(gradient#4DB0FFto#0B6CE6). Those hexes are the--product-*variables inglobals.css..product-tile-*keeps a tint of the same solid for anything that still paints a tile.
Hiding an entry is a courtesy. Each product refuses a person on its own server.
Turning it on for a deployment
Nothing to switch on in ContentsVision: it is driven entirely by what is pushed.
CONTENTS_CAPTURE_PROVISIONING_SECRETmust be set here and equal ContentsEstimation'sCONTENTSVISION_PROVISIONING_SECRET(it already is wherever the automatic ContentsCapture connection works).- Release this ContentsVision before ContentsEstimation starts pushing. ContentsEstimation reads the capabilities route and does not push to an older ContentsVision.
To see what is held for a person, read the table:
sqlite3 storage/inventory.db "select email, ce_team_legacy_id, enterprise, active, vision, estimation, capture_admin, capture_app, version, updated_at from product_access where email = '[email protected]';"
Tests
backend/tests/test_product_access.py: the door (secret), capabilities, store, ignore older, per person and team versions, email change, every kind of malformed record, batch, a record before first sign-in, an already signed-in person, a deactivated account, SMB, no record, team matching, staff, impersonation, the local bypass.frontend/src/lib/productLinks.test.mjs(run bybackend/tests/test_product_switcher.py): the menu with no record, all access, one product removed, only ContentsVision left.frontend/src/lib/sessionGuard.test.mjs: which responses mean "access switched off".
Not covered
- ContentsVision does not audit pushes. The audit trail is ContentsEstimation's.
- There is no screen in ContentsVision to view or change a record. Staff do that in ContentsEstimation.
- A record is never deleted here. A person removed in ContentsEstimation should be pushed with
activefalse.