Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested fields not patched correctly when path field omitted #224

Open
finrod2002 opened this issue Jun 5, 2024 · 6 comments · May be fixed by #225
Open

Nested fields not patched correctly when path field omitted #224

finrod2002 opened this issue Jun 5, 2024 · 6 comments · May be fixed by #225

Comments

@finrod2002
Copy link

finrod2002 commented Jun 5, 2024

Describe the bug

When using the following code

final PatchRequest patchToBeApplied = new ObjectMapper()
            .readValue(patchRequest, PatchRequest.class);

final GenericScimResource resource = new ObjectMapper()
            .readValue(resourceJson, GenericScimResource.class);
            
 patchToBeApplied.apply(value);

in the result the nested fields are added instead of replaced.

patchRequest has the following body

{
    "Operations": [
        {
            "op": "replace",
            "value": {
                "name.familyName": "test",
                "name.formatted": "test test2"
            }
        }
    ],
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:PatchOp"
    ]
}

something like the following is produced

{
  "schemas" : [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ],
  ...
  ...
  ...
  "name" : {
    "familyName" : "Young",
    "givenName" : "Joy"
  },
  ...
  ...
  ...
  "name.familyName" : "test",
  "name.formatted" : "test test2"
}

To Reproduce

  1. Given following java code
final PatchRequest patchToBeApplied = new ObjectMapper()
            .readValue(patchRequest, PatchRequest.class);

final GenericScimResource resource = new ObjectMapper()
            .readValue(resourceJson, GenericScimResource.class);
            
 patchToBeApplied.apply(value);
  1. With resourceJson set to the following JSON
{
  "schemas" : [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ],
  "externalId" : "externalId-1",
  "meta" : {
    "resourceType" : "User"
  },
  "userName" : "user1",
  "name" : {
    "familyName" : "Young",
    "givenName" : "Joy"
  },
  "displayName" : "Joy Young",
  "active" : true,
  "emails" : [ {
    "value" : "[email protected]",
    "type" : "work",
    "primary" : true
  }, {
    "value" : "[email protected]",
    "type" : "work",
    "primary" : false
  } ],
  "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" : {
    "department" : null,
    "manager" : null
  }
}
  1. With patchToBeApplied set to
{
    "Operations": [
        {
            "op": "replace",
            "value": {
                "name.familyName": "test",
                "name.formatted": "test test2"
            }
        }
    ],
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:PatchOp"
    ]
}
  1. Result is
{
  "schemas" : [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ],
  "externalId" : "externalId-1",
  "meta" : {
    "resourceType" : "User"
  },
  "userName" : "user1",
  "name" : {
    "familyName" : "Young",
    "givenName" : "Joy"
  },
  "displayName" : "Joy Young",
  "active" : true,
  "emails" : [ {
    "value" : "[email protected]",
    "type" : "work",
    "primary" : true
  }, {
    "value" : "[email protected]",
    "type" : "work",
    "primary" : false
  } ],
  "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" : {
    "department" : null,
    "manager" : null
  },
  "name.familyName" : "test",
  "name.formatted" : "test test2"
}

Expected behavior
The following pached JSON would be excpected.

{
  "schemas" : [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ],
  "externalId" : "externalId-1",
  "meta" : {
    "resourceType" : "User"
  },
  "userName" : "user1",
  "name" : {
    "familyName" : "test",
    "givenName" : "Joy",
    "formatted" : "test test2"
  },
  "displayName" : "Joy Young",
  "active" : true,
  "emails" : [ {
    "value" : "[email protected]",
    "type" : "work",
    "primary" : true
  }, {
    "value" : "[email protected]",
    "type" : "work",
    "primary" : false
  } ],
  "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" : {
    "department" : null,
    "manager" : null
  }
}

Additional context
Add any other context about the problem here. For example:

  • JDK version 21
  • SCIM 2 SDK version 3.0.0

Edit1: Improve JSON code formatting
Edit2: Add Java sample code

@finrod2002 finrod2002 linked a pull request Jun 7, 2024 that will close this issue
@kqarryzada
Copy link
Collaborator

@finrod2002, which SCIM service provider were you using that generated PATCH requests of this form?

@finrod2002
Copy link
Author

@kqarryzada

This was Microsoft/Entra/Azure Scim provider. I use the validator here, this has to pass before an app can be published in the Microsoft Enterprise gallery.

https://scimvalidator.microsoft.com/

@willemvermeer
Copy link

Hi @finrod2002 did you ever find a solution for this problem? I am also testing my SCIM implementation from MS-Azure SCIM validator and facing the same issue.
Thanks,
Willem

@finrod2002
Copy link
Author

@willemvermeer

Yes, I've solved it. At least lets say it works good enough for me. Here is the pull request:

#225

@willemvermeer
Copy link

Nice work - so it's up to the maintainer @kqarryzada to review & merge your PR - that would be great, thanks

@finrod2002
Copy link
Author

@willemvermeer

Not sure it will ever be merged. They clearly state, they aren’t accepting any third party contributions.

https://github.com/pingidentity/scim2/blob/master/CONTRIBUTING.md#contributing-code-changes

So your best bet is to clone the fork and build your own JAR, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants