FIX: correctly support blank values in mapped fields#137
Merged
Conversation
When more than one field in mapped to the same attribute via the "attribute_statements" site setting, we used to take the first value that was "truthy" in Ruby (and "" <empty string> is truthy). cf. https://github.com/omniauth/omniauth-saml/blob/7c6206e8005cd5695271bd81b73f9de050f5da3a/lib/omniauth/strategies/saml.rb#L134-L140 This overrides the "find_attribute_key" method andchanges the behaviour to take the first non blank value when there are more than one value mapped to an attribute. Also refactored the way we generate request_attributes and attribute_statements. Internal ref - t/167303
blake-discourse
approved these changes
Nov 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When more than one field in mapped to the same attribute via the "attribute_statements" site setting, we used to take the first value that was "truthy" in Ruby (and "" is truthy).
cf. https://github.com/omniauth/omniauth-saml/blob/7c6206e8005cd5695271bd81b73f9de050f5da3a/lib/omniauth/strategies/saml.rb#L134-L140
This overrides the "find_attribute_key" method andchanges the behaviour to take the first non blank value when there are more than one value mapped to an attribute.
Also refactored the way we generate request_attributes and attribute_statements.
Internal ref - t/167303