Repository navigation
[OID4VCI] Generate pre-authorized codes using the JWT format - #46450
Conversation
5b60b20 to
c4c4f3a
Compare
|
@IngridPuppet Thank you very much for this PR, it’s greatly appreciated. I had a quick question regarding the use of "typ": "oid4vci-pre-auth-code+jwt" instead of "typ": "JWT". Could you please share the rationale behind this choice? Additionally, are there any IANA registrations, standards, or other authoritative references that define or recommend this type or format? If there isn’t a clear standard definition or established best practice supporting it, I would kindly ask that we align this with the existing standards. Thank you very much for your consideration. |
Hi @VinodAnandan. I understand your point and acknowledge that the |
e72644d to
5f6cf2c
Compare
Unreported flaky test detectedIf the 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.forms.MultipleTabsLoginTest#testLoginAfterLogoutFromDifferentTabKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#loginActionWithoutExecutionKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRequiredActionKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#expiredAuthenticationAction_expiredCodeExpiredExecutionKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#testWithAuthSessionExpiredInTheMiddle_badRedirectUriKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#testEmptyBaseUrlKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#testRestartFailureWithDifferentClientAfterAuthSessionExpirationKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#expiredAuthenticationAction_currentCodeExpiredExecutionKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#testLogoutDifferentBrowserWithAuthenticationSessionStillPresentKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsLoginAndPassiveCheckKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredInTheMiddleKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#loginActionWithoutExecutionInRequiredActionsKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRefreshInTab1Keycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#testLoginPageRefreshKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#loginWithDifferentClientsKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRegisterClickKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#expiredAuthenticationAction_expiredCodeCurrentExecutionKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.forms.MultipleTabsLoginTest#testInjectRedirectUriInClientDataAfterAuthSessionExpirationKeycloak CI - Forms IT (chrome) |
Unreported flaky test detectedIf the 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.oid4vc.issuance.credentialoffer.preauth.JwtPreAuthCodeHandlerTest#shouldGenerateValidPreAuthCode |
|
@IngridPuppet Could you please update the JWT format in the PR description with the latest changes. |
Sure. Done. |
b99423c to
c04b0b8
Compare
|
It's probably not a good idea to serialize the CredentialOfferState directly into the JWT
What you show above has no |
|
This branch is actually quite a bit behind current main. The CredentialOfferState is now an immutable object that contains |
Hello @tdiesler - Thank you for taking a look. Indeed, the PR needs updating after the recent merge of #46199. I'll do so taking your points into consideration.
Currently, the state is not directly serialized. The model is reused but only public fields are injected into the JWT. Of course, this does not include a potentially sensitive Given these concerns, I acknowledge that introducing a separate model looks more appropriate. I'll update the PR accordingly. |
|
Perhaps it's worth building your thing on top of #46466 - there we introduce a |
5aee986 to
6cfebf7
Compare
|
Hello @tdiesler - The PR has been rebuilt on top of the recent changes in |
There was a problem hiding this comment.
@IngridPuppet Thanks for the PR!
I did not yet reviewed, but is it possible to rebase please? There is this change 53e7bdf , which may require some additional updates in your PR (the new feature feature would be needed to be enabled in the migrated test).
6cfebf7 to
3767469
Compare
|
Hello @mposolda - PR rebased. Could you take a look when you have a chance? |
|
@mposolda This PR aims to enhance the security of the pre-authorized code grant. As you may know, this flow does not benefit from protections using PKCE, which can make it more susceptible to risks like phishing, brute force attacks, malware, accidental exposure, replay attacks, and MITM interception. Using a signed JWT instead of a random string helps strengthen the overall security model. The PR has already been reviewed and approved by @tnorimat and @tdiesler . We are hoping to include it in the 26.6 release, and would greatly appreciate your support in reviewing and progressing it when you have a moment. |
3767469 to
00a415b
Compare
There was a problem hiding this comment.
@IngridPuppet Thanks for this PR and sorry for late review. Added some comments inline. Can you please check?
|
@IngridPuppet Will be probably good to rebase on top of latest main after recently merged 931d232 (There are no conflicts with your PR, but just to be sure that tests are still OK). Thanks! |
6b33ea1 to
f061712
Compare
Closes keycloak#45231 Signed-off-by: Ingrid Kamga <Ingrid.Kamga@adorsys.com> Signed-off-by: Ingrid Kamga <xingridkamga@gmail.com>
f061712 to
898ab15
Compare
Signed-off-by: Ingrid Kamga <Ingrid.Kamga@adorsys.com>
898ab15 to
c5a894e
Compare
There was a problem hiding this comment.
@IngridPuppet @tdiesler @tnorimat @VinodAnandan Thanks for the update and reviews!
…k#46450) Closes keycloak#45231 Signed-off-by: Ingrid Kamga <Ingrid.Kamga@adorsys.com> Signed-off-by: Ingrid Kamga <xingridkamga@gmail.com>
Closes #45231
The implemented JWT format looks like this (updated with review comments):
{ "header" : { "alg" : "HS512", "typ" : "JWT", "kid" : "a109ad9d-0144-40c9-80e7-42dc7e55b2e6" }, "payload" : { "exp" : 1774447450, "iat" : 1774447420, "iss" : "http://localhost:8080/realms/test", "aud" : "http://localhost:8080/realms/test/protocol/openid-connect/token", "context" : { "credentials_offer_id" : "jPYrg61ZmpG0Dwb7qSn3B5AmiyJuScjtflP001s-jZlacJxhnnx5p8zwAni4GJUQ-pWO_EhZZrzOx1cugo5zjw", "target_client_id" : "oid4vci-client", "target_user_id" : "0599083e-fb4b-4e9f-8e05-685adfab65a5", "nonce" : "OCYXrKWen1TFaCwXvx5RYYwWdEfGbYF1fqlsqnwoO3FCHG5SL-s2fbvTScNLwKtgKvVj8E2tSEUIXDo4Z3dXdQ", "authorization_details" : [ { "type" : "openid_credential", "credential_configuration_id" : "jwt-credential-config-id", "credential_identifiers" : [ "jwt-credential" ] } ] }, "salt" : "fVLiYLHQ6ALVRF2V2KXyZ5AVh284h2k1TZMBO6k6fF0" }, "signature" : "oLYISMsP4ZlwfDNl8joXQ58kZPVL8yECbAOa3AX_vPCjIpLD9XUKFvJgbUo34CG1h56YMFIOj9qN48_iZit-1A" }