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

Prevent adding empty renamed attribute #1322

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

MKodde
Copy link
Member

@MKodde MKodde commented Sep 5, 2024

When Manage configures an override for an attribute name. But the targetted attribute is not in the assertion, then Engine would add an empty attribute with the overridden value to the assertion. The SAML2 lib would then warn us that an empty attribute value can not be processed.

To fix that. I added a test statement that verifies if the targetted attribute is present in the assertion. If not, the substitution is not made and a warning is logged.

See, Fixes: #1321

@MKodde MKodde force-pushed the bugfix/prevent-invalid-release-as branch from 272a819 to 0d700e4 Compare September 5, 2024 06:37
$oldAttributeName
)
);
unset($attributes[$oldAttributeName]);
Copy link
Member Author

Choose a reason for hiding this comment

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

@thijskh in this testcase; edupersontargetedId is in the assertion but is set to be an empty array as value.

The enforcer now tests if the value is empty, and pops it out of the assertion. Is that expected behavior for Engine? I think, prior to this change. EB would allow this.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed. The problem only occurs when the attribute is completely unset. So I would limit the solution to that only.

$oldAttributeName
)
);
unset($attributes[$oldAttributeName]);
Copy link
Member

Choose a reason for hiding this comment

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

Indeed. The problem only occurs when the attribute is completely unset. So I would limit the solution to that only.

@@ -37,6 +37,29 @@ public function enforce(array $attributes, array $releaseAsOverrides)
{
foreach ($releaseAsOverrides as $oldAttributeName => $overrideValue) {
$newAttributeName = $overrideValue[0]['release_as'];
if (!array_key_exists($oldAttributeName, $attributes)) {
$this->logger->warning(
Copy link
Member

Choose a reason for hiding this comment

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

I think this is in principle also 'normal' behaviour. The ARP specification of release_as basically should be read as "If this attribute is released, then use this name". So if it's not present it should not be causing warning level messages. Info is probably fine.

@MKodde MKodde force-pushed the bugfix/prevent-invalid-release-as branch from 0d700e4 to 4a1307c Compare September 5, 2024 06:50
@MKodde MKodde requested a review from mharte-ib September 5, 2024 07:10
@MKodde MKodde force-pushed the bugfix/prevent-invalid-release-as branch from 4a1307c to 653e72c Compare September 5, 2024 07:52
@MKodde MKodde force-pushed the bugfix/prevent-invalid-release-as branch from 653e72c to 9f9ca82 Compare September 5, 2024 13:52
Issue: #1321 describes it perfectly. When Manage configures an override
for an attribute name. But the targetted attribute is not in the assertion, then
Engine would add an empty attribute with the overridden value to the
assertion. The SAML2 lib would then warn us that an empty attribute
value can not be processed.

To fix that. I added a test statement that verifies if the targetted
attribute is present in the assertion. If not, the substitution is not
made and a warning is logged.

It is not allowed to rename an attribute with a null value.
It is allowed to rename an empty attribute.

See: #1321
@MKodde MKodde force-pushed the bugfix/prevent-invalid-release-as branch from 9f9ca82 to 550c91a Compare September 5, 2024 13:53
@MKodde MKodde merged commit 37c1787 into main Sep 10, 2024
2 checks passed
@MKodde MKodde deleted the bugfix/prevent-invalid-release-as branch September 10, 2024 09:48
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.

Warning triggered when release_as set for attribute without values
3 participants