scim icon indicating copy to clipboard operation
scim copied to clipboard

Validation Failure For PATCH

Open Avinash-Kamath opened this issue 1 year ago • 2 comments

Patch request validation fails for below request body even though its a valid request

{
    "Operations": [
        {
            "op": "add",
            "value": {
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                    "employeeNumber": "123",
                    "costCenter" :"AU"
                }
            }
        }
    ],
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:PatchOp"
    ]
}

Avinash-Kamath avatar Sep 26 '24 12:09 Avinash-Kamath

I was curious, so I investigated on my end as well.

Check this behavior by adding the following test case to TestOperationValidator_ValidateUpdate in internal/patch/update_test.go:

{valid: map[string]interface{}{"op": "add", "value": map[string]interface{}{"test:PatchExtension": []interface{}{map[string]interface{}{"attr1": "value"}}}}},

This error seems to be caused by github.com/scim2/filter-parser/v2 . The URIPrefix is resolved to urn:ietf:params:scim:schemas:extension:enterprise:2.0, but :Users is dropped.

Since the process designed for resolve filters is used, the resolution position of : seems to be misaligned.

ivixvi avatar Dec 30 '24 08:12 ivixvi

~I was able to confirm the RFC specification regarding this.~ As outlined in the Filtering section, a path consisting only of the specified URI does not seem to be a valid path.

The "path" attribute is described by the following ABNF syntax rule:

               PATH = attrPath / valuePath [subAttr]

                  Figure 7: SCIM PATCH PATH Rule

The ABNF rules "attrPath", "valuePath", and "subAttr" are defined in Section 3.4.2.2. The "valuePath" rule allows specific values of a complex multi-valued attribute to be selected.

https://datatracker.ietf.org/doc/html/rfc7644#section-3.5.2


P.S.

It seems I forgot about the original request during my investigation. This request does not specify a path, so it's unclear whether it falls under the restrictions for path.

ivixvi avatar Dec 30 '24 08:12 ivixvi