What the client checks#
scim2-client checks the payloads it sends as closely as the ones it receives. A client checking what it wrote may look redundant, since the server is going to check it again. They are not the same check, and the local one does more than refuse.
Why a client checks its own requests#
A payload refused locally never leaves the process. The exception names the attribute at fault
and carries the whole ValidationError, where the
server would have returned a 400 whose detail is one sentence written by its author.
The check also shapes the payload, which is the part a server cannot do for the client. Each
operation is validated and serialized under the Context matching it, and
a context drops the attributes that operation has no business sending: the id an
application filled on a resource it is about to create is left out of the POST, because
RFC7643 §7 makes it read-only and the server assigns it. Turning the
check off with check_request_payload therefore turns the
filtering off too, and the payload is sent exactly as it was given.
What a response is checked against#
The Content-Type comes first, since a body that is not SCIM JSON cannot be read as one.
RFC7644 §8.1 names application/scim+json, and
application/json is accepted alongside it because older implementations use it.
A response without body has no type to check.
A failure must then carry a SCIM error (RFC7644 §3.12). Only a
2xx or a 304 response is a success. Any other response without an
Error body raises UnexpectedStatusCodeException,
whatever the status codes the operation expects. Otherwise, a 401 answered by a proxy would
read as a success with no content. A failure whose body is not JSON, such as an HTML page,
raises it too, so the status code is reported rather than the format of the body.
The body is then read as an Error when its schemas say so. This
happens before the status code is examined, so a server returning a well-formed SCIM error
under a status code the operation does not define raises that error, not
UnexpectedStatusCodeException.
The status code is checked next, against the list the operation defines — the class attributes
of SCIMClient hold them, each one sourced from the section of
RFC7644 that defines the operation.
The payload is validated last, under the response context of the operation, and against the
resource types that operation could return. A payload whose schemas match none of them
raises before any attribute is read: validated against a model it does not describe, it would
report faults that are not there.
Why the default is to refuse#
scim2-models refuses anything the specifications do not describe unless it is given a
ScimPolicy saying otherwise, and scim2-client neither widens nor narrows
that. Its reasons, and the consequence that a client reads a response as strictly as a server
reads a request, are set out in
its own explanation.
The application is left with a choice at two grains. A check covers a whole payload and is turned
off on the client or on one call. A policy states one departure and leaves the rest of the
validation standing; it travels with the ScimProvider describing the server,
so it applies to the payloads the client reads and to the ones it writes.
Tolerate a non-conformant peer shows both.