Skip to content

Ensure that the EncryptedKey is passed to the DecryptionKeyLocator for SAML - #23203

Merged
mposolda merged 1 commit into
keycloak:mainfrom
rmartinc:issue-22974
Sep 20, 2023
Merged

Ensure that the EncryptedKey is passed to the DecryptionKeyLocator for SAML#23203
mposolda merged 1 commit into
keycloak:mainfrom
rmartinc:issue-22974

Conversation

@rmartinc

Copy link
Copy Markdown
Contributor

Closes #22974

Two little issues in SAML decryption of elements:

  • The EncyptedKey sometimes is outside the EncryptedData (next sibling). And it was not passed to the SAMLDecryptionKeysLocator. So the locator couldn't filter by the encryption alg set in the response. This threw a NPE iterating the keys. Code also changed to not decode the EncyptedKey twice (if it was already inside the data) and to avoid keys without private key.
  • Besides the admin console is showing/hiding the encryption algorithm property if the wantAuthnRequestsSigned is ON. That makes no sense, the encryption alg is only used to force the alg in decrypting the received elements, not when we sign the requests. I have moved it to show/hide when wantAssertionsEncrypted is ON. (I think that there is no lint or test errors, but I'm never sure. 😄 )

The combination of the two problems threw the NPE in the related issue. The alg was not forced (because the box was hidden and the user didn't see how to force it) and then the EncryptedKey was outside the EncrypedData in okta. Test added to modify the XML and be similar to the one produced by okta.

@rmartinc
rmartinc requested review from a team as code owners September 13, 2023 10:10
@ghost ghost added team/ui labels Sep 13, 2023
@cypress

cypress Bot commented Sep 13, 2023

Copy link
Copy Markdown

Passing run #8994 ↗︎

0 527 48 0 Flakiness 0

Details:

Merge 1a26027 into 617044f...
Project: Keycloak Admin UI Commit: 9607771f7b ℹ️
Status: Passed Duration: 12:44 💡
Started: Sep 20, 2023 8:45 AM Ended: Sep 20, 2023 8:58 AM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We recently made some changes to the way labels are handled, so the namespace can now be omitted.

Suggested change
fieldLabelId="identity-provider:encryptionAlgorithm"
fieldLabelId="encryptionAlgorithm"

@rmartinc rmartinc Sep 14, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jonkoops I had just moved it! 😄 Done now!

But one question, modifying this I saw that the help message was not OK. I needed to also change the helpText={th("encryptionAlgorithmHelp")} (adding suffix Help) in the HelpItem. I see all the HelpItem (at least in the saml provider) are not showing the proper help message. I just modified the one that I was moving.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you log a separate issue for that one? I think this might be because of the recent changes made to the labels. ping @edewit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created: #23255 (It just happens in main, not in 22.0.3.)

jonkoops
jonkoops previously approved these changes Sep 14, 2023
@ghost

ghost commented Sep 14, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.webauthn.AppInitiatedActionWebAuthnTest#proceedSetupWebAuthnLogoutOtherSessionsChecked

Keycloak CI - WebAuthn IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 0.644
  (Session info: headless chrome=116.0.5845.187)
Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'fv-az436-812', ip: '10.1.0.146', os.name: 'Linux', os.arch: 'amd64', os.version: '6.2.0-1011-azure', java.version: '17.0.8.1'
...

Report flaky test

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

pedroigor
pedroigor previously approved these changes Sep 14, 2023
@rmartinc

Copy link
Copy Markdown
Contributor Author

I give up today, something is failing today. Tomorrow I will rebase and try again.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ghost

ghost commented Sep 14, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.ui.account2.DeleteAccountTest#navigationTest

Keycloak CI - Account Console IT (firefox)

org.awaitility.core.ConditionTimeoutException: Assertion condition defined as a org.keycloak.testsuite.util.URLAssert URL expected to begin with: https://localhost:8543/auth/realms/test/protocol/openid-connect/auth ; actual URL: https://localhost:8543/auth/realms/test/account/#/personal-info within 10 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:119)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:31)
	at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985)
...

Report flaky test

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ghost

ghost commented Sep 15, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.x509.X509BrowserCRLTest#loginSuccessWithCRLSignedWithIntermediateCA3FromTruststore

Keycloak CI - FIPS IT (non-strict)

java.lang.RuntimeException: Could not create statement
	at org.jboss.arquillian.junit.Arquillian.methodBlock(Arquillian.java:313)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
...

Report flaky test

@rmartinc

Copy link
Copy Markdown
Contributor Author

@jonkoops It seems that the Account UI E2E is failing consistently. And I see it happens in other PRs (for example #23271). I have not changed anything in account so I think I'm not guilty here. 😄
The other failure seems to be spureous because something with node not being executable at themes.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ghost

ghost commented Sep 19, 2023

Copy link
Copy Markdown

Unreported flaky test detected

If the below flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.x509.X509BrowserCRLTest#loginSuccessWithCRLSignedWithIntermediateCA3FromTruststore

Keycloak CI - FIPS IT (non-strict)

java.lang.RuntimeException: Could not create statement
	at org.jboss.arquillian.junit.Arquillian.methodBlock(Arquillian.java:313)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
...

Report flaky test

@jonkoops

Copy link
Copy Markdown
Contributor

It seems that the Account UI E2E is failing consistently.

This should be fixed now, could you rebase your PR on main and see if everything passes?

@rmartinc
rmartinc dismissed stale reviews from pedroigor and jonkoops via 1a26027 September 20, 2023 08:36
@rmartinc

Copy link
Copy Markdown
Contributor Author

OK! All CI passed now. Thanks @jonkoops! @pedroigor ready to merge now if you don't see anything more.

@mposolda mposolda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rmartinc @jonkoops @pedroigor Thanks everyone for the work on this and the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullpointerException when using encrypted SAML assertions

4 participants