Skip to content

Conversation

@scottyhagan
Copy link

Why?

When the ScimUsersController#patch_update endpoint was hit and had an operation with a path value that used SCIM's schema extensions urn:ietf:params:scim:schemas:extension:enterprise:2.0:User, it would not parse this parameter properly resulting in the underlying attribute never getting updated.

What?

Added a handler for scenarios where we receive a paramater that is part of SCIM's schema extensions. It isn't pretty but it gets the job done.
Also refactored a case statement that didn't handle when the operation sent the active attribute as "True" or "False". Simplified it to cast it as a boolean to handle that scenario and get rid of the case statement

@scottyhagan scottyhagan self-assigned this Aug 19, 2021
# Must use .to_s.downcase to handle strings "True" and "False"
# Which is sent by Azure AD
# Other possible inputs (true, "true", false, "false", 0, 1, nil)
ActiveModel::Type::Boolean.new.cast(active_param.to_s.downcase)
Copy link

@pluus pluus Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm 💭 two thoughts on this.

  1. I can't find tests around this... where can I find them?
  2. Looks like we're casting any value now instead of raising ScimRails::ExceptionHandler::InvalidActiveParam on some values that shouldn't be used.

For example, the following inputs are now valid.

[5] pry(main)> ActiveModel::Type::Boolean.new.cast({}.to_s.downcase)
=> true  
[7] pry(main)> ActiveModel::Type::Boolean.new.cast([].to_s.downcase)
=> true

Is it an intentional change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your your point but as i put in the comments on the line above so far we know the possible inputs from various identity providers and what we know are possible inputs are (true, "true", "True", false, "false", "False", 0, 1, nil). So based on this I still think its an adequate solution

@scottyhagan scottyhagan merged commit 0017ff4 into master Aug 26, 2021
@amaury-sie amaury-sie deleted the bugfix-scim-azure branch June 14, 2023 22:52
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 this pull request may close these issues.

4 participants