-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add shim for Web Crypto API to admin and account console #33480
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
Conversation
shawkins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - we have similar logic to SecureContextResolver in SslRequired. SslRequired potentially does a DNS lookup to resolve the InetAddress. It might be good as a follow up to consolidate this logic - granted we'll probably be deprecating the SslRequired setting soon. cc @ahus1
Sounds logical to me, I am not familiar with this code, so I don't know how much overlap there is. Let's log an issue to follow up on it 👍 |
douglaspalmer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ok, added #33484 |
|
Looks like the tests are failing because HtmlUnit is once again too dumb to interpret even the most basic JavaScript syntax. Sigh. I'll do some work to turn it into a caveman version. |
8c1ed4f to
57c4027
Compare
This comment was marked as outdated.
This comment was marked as outdated.
57c4027 to
786b074
Compare
|
Ok, should be fixed now. @edewit @shawkins @douglaspalmer can I ask you for another review? |
douglaspalmer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
shawkins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ahus1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving it as it solves the problem at hand. The warning message "Keycloak JS should only be used in a secure context" could be more specific. It doesn't contain any why, the "secure context" is a bit a vague as it requires the crypto API, and "should" is also off as it requires the crypto API (unless someone uses a shim, which is not mentioned here).
As the log message is normally not shown (only if you enable logging for the JS library), I would be ok to continue as is for the sake of KC26.
One small wording in the upgrading guide. Might be worth adding it to the release notes as well.
docs/documentation/upgrading/topics/changes/changes-26_0_0.adoc
Outdated
Show resolved
Hide resolved
This comment was marked as off-topic.
This comment was marked as off-topic.
786b074 to
f42ca0c
Compare
ahus1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating the release notes.
Approving with the same comment as before: "I'm approving it as it solves the problem at hand. The warning message "Keycloak JS should only be used in a secure context" could be more specific. It doesn't contain any why, the "secure context" is a bit a vague as it requires the crypto API, and "should" is also off as it requires the crypto API (unless someone uses a shim, which is not mentioned here).
As the log message is normally not shown (only if you enable logging for the JS library), I would be ok to continue as is for the sake of KC26."
|
Sorry I missed your comment @ahus1, let me reply here.
Agreed. The URL in the message explains that some APIs are not available in the browser if not in a secure context. But we could do a better job, but I think that will suffice for now. This is not specifically about the Web Crypto API, but about a whole sub-set of APIs that are only available in a secure context that we might want make use of in the future. For example, the new cookie store APIs and possibly the FedCM API. Hence I don't want to advise the user to polyfill/shim this behaviour, as that could break in unexpected manners in the future. The Web Crypto API is only used in PKCE flows (which is the default but can be opted out of), if it is not enabled the Web Crypto API is not used. Hence it is not a hard requirement in all scenarios. |
Closes keycloak#33330 Signed-off-by: Jon Koops <[email protected]>
f42ca0c to
fd8fd1b
Compare
Upon closer inspection, we're also using the same API to generate UUIDs. We are however not using the appropriate |
Closes #33330
Adds a shim for the Web Crypto API to admin and account console so they continue to work, even when being served from an non-secure context. This moves the polyfilling responsibility to Keycloak rather than Keycloak JS.