lessonly / scim_rails

SCIM Adapter for Rails.
MIT License
68 stars 76 forks source link

A PATCH to deprovision a user is rejected as invalid #32

Closed mdilts closed 4 years ago

mdilts commented 4 years ago

The PATCH endpoint is unable to deprovision someone using:

[{"op": "replace", "value": { "active": false }}]

This operation is returned as an invalid PATCH request. Setting “active” to true will reprovision a person successfully.

To repro:

curl -X PATCH 'http://dev:api_key@localhost:3000/scim/v2/Users/819216' -d '{"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], "Operations": [{"op": "replace", "value": { "active": false }}]}' -H 'Content-Type: application/scim+json'
rreinhardt9 commented 4 years ago

Arg! You are so right, thanks for catching this!

This was caused by my work on #29

Specifically these lines:

https://github.com/lessonly/scim_rails/blob/0b5c207fca9aca403d1b3a9be2fd4b1645d41aa1/app/controllers/scim_rails/scim_users_controller.rb#L142-L146

I need to be checking for the presence of an active value attribute; what is happening here is I'm depending on it being "truthy" but "false" is not truthy, so the check short circuits when supplying a value of false.

This needs to be updated to check for the presence of the value key, not the "truthiness" of it's value. Maybe something like this using has_key?

 def valid_patch_operation?(operation) 
   operation["op"] == "replace" && 
     operation["value"] && 
     operation["value"].has_key?("active") 
 end