Repository navigation
[OID4VCI] Add support for authorization_code grant - Part4 - #46950
Conversation
bdea149 to
6d173cb
Compare
There was a problem hiding this comment.
LGTM, only some minor remarks
There was a problem hiding this comment.
not finished yet, I will continue tomorrow with the review
9bb0976 to
58c5517
Compare
There was a problem hiding this comment.
@tdiesler Thanks for the PR!
During the review, I spot few things. Especially during the pre-authorized code grant, the credential-request does not check at all that offerState exists as it is always null. This is due the fact that client session note CREDENTIAL_OFFER_ID_NOTE is null in the credential request (as this client session is different than the one used in pre-authorized grant request and moreover pre-authorized grant uses transient user session). It seems we have some gaps in the test coverage since this was not caught by the automated tests.
Storing of the offerId inside client session is not ideal even for authorization-code grant as there is single AuthenticatedClientSession per browser session, however there might be more access tokens for various different VC with multiple different offers inside same browser session.
It should rather work better if the offer ID is stored directly inside access token instead of client session. This fixes the issues above and makes sure that correct access-token, which was returned from the token-response related to credential-offer will also consume the same credential-offer inside credential request.
This "contract" between access-token and credential-offer was available before this PR as credential_identifier from access token was used as a link to obtain credential offer. However this contract was now lost with latest changes as credential_identifier is not used for this purpose anymore. So we need something else inside access token to make sure this correlation between access-token and credential-offer still exists.
I've sent PR tdiesler#2 to your branch, which adds offer ID as claim into the access token instead of using client session note. It is stored within authorization_details, which should be OK as OID4VC specification mentions in the section 5.1 Additional authorization_details data fields MAY be defined and used when the type value is openid_credential. Note that this effectively defines an authorization details type that is never considered invalid due to unknown fields.. Merging that PR should automatically update this PR.
I've also added some test scenarios, which should work (and AFAIK they pretty much worked before your PR, but stopped working).
UR a hero :-) Yes, some time ago I also discovered the credential offer id as always null in the credential request, traced it back to the transient user session and came to the conclusion that this id should be stored in the access token directly (as a proprietary claim) - exactly as you say and I'm very grateful for you making the effort of fixing it. I wanted to raise this issue as a follow-up as soon as everyone can see it. I'll have a look and get back to you when I've managed to digest your proposed changes - thanks. |
25064e2 to
58c5517
Compare
Signed-off-by: Thomas Diesler <tdiesler@proton.me>
Signed-off-by: Thomas Diesler <tdiesler@proton.me>
…ated tests. Signed-off-by: mposolda <mposolda@gmail.com>
|
@mposolda The generated authorization_details for the offer state did not contain the credential_offer_id. It slipped through because equality & hashCode ignored it too. I fixed that and renamed OFFER_ID => CREDENTIAL_OFFER_ID as will be done in part5 anyway. Otherwise, great - thanks. |
1d14706 to
b800e32
Compare
Signed-off-by: Thomas Diesler <tdiesler@proton.me>
…lity/hashCode Signed-off-by: Thomas Diesler <tdiesler@proton.me>
Signed-off-by: Thomas Diesler <tdiesler@proton.me>
b800e32
10000
to
8467a95
Compare
@tdiesler Yes, I did not originally added the offer_id to the authzDetails entry in the cache as offerState itself is saved in the cache by the corresponding The tests I've added could be probably simplified (The code for doing the login and whole accessToken obtain could be likely extracted to some private method as it is same code used by multiple tests). But that can be done as a follow-up though :-) PR looks good to me as well. Thanks for the latest updates! |
|
Hallelujah :-D |
…k#46950) closes keycloak#47100 Signed-off-by: Thomas Diesler <tdiesler@proton.me> Signed-off-by: mposolda <mposolda@gmail.com> Co-authored-by: mposolda <mposolda@gmail.com>
closes #47100
related #46385
[OID4VCI] Add support for authorization_code grant - Part4