CodamAIDocs
Topicdone

Strict mode: error or silently ignore

Whether a request that is not allowed returns an error or is silently trimmed. Where this applies and why strict is the default.

Variants
strict: missing role → 403lenient: read → 404, query → 403lenient: writing → 403 with its own keylenient: reference in the response → nullnested create strict/lenientonly configurable globally

What this is about

What should happen when a request asks for something that is not allowed? There are two answers:

  • Strict: CDMS rejects the request with an error that says exactly what is missing.
  • Lenient: CDMS leaves out what is not allowed and returns the rest. Where that is not possible, a more general error comes back.

Which answer applies is set by strict mode. It is on by default.

Where it is set

Strict mode applies to a whole CDMS instance: to all models and all requests. You set it with the environment variable STRICT_MODE. If it is missing, true applies.

A client cannot switch it, and a single model cannot be set differently.

The matrix

CaseStrict mode onStrict mode off
read by id, read role missing403 missing-permission|<read role>404 not-found
search, read role missing403 missing-permission|<read role>403 empty-request-left
single reference in the response, role missing403 missing-permission|<role>field is null, no error
list in the response, role missing403 missing-permission|<role>403 empty-request-left for the whole request
create, role missing403 missing-permission|<role>403 missing-create-role
change (PUT, PATCH), role missing403 missing-permission|<role>403 missing-update-role
delete, role missing, also in the cascade403 missing-permission|<role>403 missing-delete-role
read history, role missing403 missing-permission|<role>403 missing-read-role / missing-history-role
rollback, role missing403 missing-permission|<role>403 missing-rollback-role
create or change a child along, role and field role missing403 missing-permission|<field role or role>403 missing-create-role / missing-update-role
new child in a list, relation without CREATE400 recursive-create-not-allowed|<field>entry is skipped
new child as single reference, relation without CREATE400 recursive-create-not-allowed|<field>the field becomes empty

The last two rows are not about a role but about the flags of the relation. See The four cases in nested writing.

Strict and lenient compared

What the client learns
Strict mode on
default
  • every missing role → 403
  • the key names the missing role
  • the client knows right away which role it needs
  • same request, same result for every person
Strict mode off
lenient
  • single references without the role become null
  • read by id without the role → 404
  • writing → 403 without the role name
  • an answer with null looks like an empty field

Reading in detail

POST /hr/employee/read/{id} with response ["*", { "field": "company" }]
Strict moderole employeerole companyAnswer
onno–403 missing-permission|<role of employee>
onyesno403 missing-permission|<role of company>
offno–404 not-found
offyesno200, company is null
–yesyes200 with company

Why strict is the default

  • Errors show up. A missing role shows up in the first test, not only when a person wonders about empty fields.
  • null stays unambiguous. With strict mode, null in an answer means: not set or invisible. Without it, it can also mean: role missing.
  • The key helps. missing-permission|audit-question-read tells you exactly which role you have to grant.

The filters of the row level do not depend on strict mode. Invisible rows always return 404 or are missing from the list. See Why invisible objects return 404.

Pitfalls

Where to go next

Sources in the code and the knowledge base
  • commons – RequestContext (STRICT_MODE)
  • CDMS/cdms-authorization – AbstractAuthorizationLayer.classAccess, MissingPermissionException
  • CDMS/cdms-system-layer – AbstractLayer (recursiveRead, recursiveQuery, recursivePrepare, recursiveDelete, queryHistory, enterField, fetchAndSetModel, fetchAndSetList), AbstractSystemLayer (readObject, queryObjects, historyRollback)
  • CDMS/cdms-integrationtest – AbstractRoleDenialTest, RequestContextTestFilter
  • documentation/40-sicherheit/04-strict-mode.md
Search