Skip to content

FIX: correctly support blank values in mapped fields#137

Merged
ZogStriP merged 1 commit intomainfrom
fix-correctly-handle-empty-string-in-mapped-fields
Nov 25, 2025
Merged

FIX: correctly support blank values in mapped fields#137
ZogStriP merged 1 commit intomainfrom
fix-correctly-handle-empty-string-in-mapped-fields

Conversation

@ZogStriP
Copy link
Member

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

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
@ZogStriP ZogStriP requested a review from nattsw November 24, 2025 17:08
@ZogStriP ZogStriP merged commit 38b8203 into main Nov 25, 2025
4 checks passed
@ZogStriP ZogStriP deleted the fix-correctly-handle-empty-string-in-mapped-fields branch November 25, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants