This document details how the SCIM component processes patch requests, and the commands it generates to be passed into the PartialUpdate
method on IScimStore
.
Patch Requests
For your store to be able to handle patch requests, you will need to process a collection of PatchCommands
. The PatchCommand
object will contain the type of operation that it represents, either Add
, Remove
or Replace
. For Add
and Replace
commands, there will be a Value
property that contains the value to be used in the operation and the Path
property, which represents the property that needs to be modified on the resource.
The Path
in a PatchCommand
is a PathExpression
, containing a collection of AttributePathExpression
that makes up the path of the property the patch command relates to. By default, the SCIM component will output patch commands that always have the Path
property set, even if the incoming request omits it. This is to avoid having implementers of PartialUpdate
implement two paths for modifying a resource.
Default Behaviour
{
"op": "replace",
"value": {
"name.givenName": "newGivenName"
}
}
{
"op": "replace",
"path": "name",
"value": {
"givenName": "newGivenName"
}
}
Will both produce a PatchCommand
that can represented like the following
{
"path": "urn:ietf:params:scim:schemas:core:2.0:User:name:givenName"
"value": "newGivenName"
}
Whole Object Replacements
To change this behaviour, set the EnableWholeObjectPatchCommands
flag to true in the ScimServiceProviderConfigOptions
object passed into AddScimServiceProvider
. When set to true, patch requests without a path
will generate a PatchCommand
who's Value
property is an instance of the Resource
with the relevant properties set. As an example, the following replace command:
{
"op": "replace",
"value": {
...
"name": {
...
"familyName": "family"
...
},
"userName": "userName"
...
}
}
Will output a PatchCommand
ressembling the following representation:
{
"op": "replace",
"value": {
...
"name": {
...
"familyName": "family"
...
},
"userName": "userName"
...
}
}
When you receive this PatchCommand
you will have to check which properties have been updated on the Value
object and modify the Resource
using these.