-
Notifications
You must be signed in to change notification settings - Fork 3
fix: retain Presentation layer during decoding to allow nonce extraction #115
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
base: dev
Are you sure you want to change the base?
Conversation
…once extraction method
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
oid4vp/src/oid4vp.rs
Outdated
| }; | ||
| use crate::dcql::dcql_query::CredentialQueryId; | ||
| use crate::token::verifiable_presentation_jwt::VerifiablePresentationJwt; | ||
| // use crate::token::verifiable_presentation_jwt_builder::VerifiablePresentationJwtBuilder; |
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.
Can this be removed?
| Self::InvalidEncryptionParameters => StatusCode::BAD_REQUEST, | ||
| Self::InvalidToken => StatusCode::UNAUTHORIZED, | ||
| Self::InvalidNonce => StatusCode::BAD_REQUEST, | ||
| Self::CredentialRequestDenied => StatusCode::FORBIDDEN, |
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.
Shouldn't this one also be StatusCode::BAD_REQUEST?:
| pub fn nonce(&self) -> Option<String> { | ||
| // Making the assumption that all VPs in the token have the same nonce | ||
| for presentations in self.presentations.values() { | ||
| for vp in presentations { | ||
| if let Some(nonce) = vp.nonce() { | ||
| return Some(nonce.clone()); | ||
| // TODO: (Edge case)What if different VPs have different nonces? | ||
| } | ||
| } | ||
| } | ||
| None | ||
| } |
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.
Currently the function returns the first nonce, so all the other nonces are ignored. Maybe instead of this getter function you could add a validate_nonce function or something like that which takes the original nonce and validates all the presentation's nonces against it?
Description of change
Previously, the
decode_authorization_responsefunction would extract only the inner VerifiableCredentialJwt level of the vp_token. This meant that the "outer" VerifiablePresentationJwt (VP) shell of the token was discarded after decoding.Because the nonce claim resides on the Presentation layer and not the Credential layer, it was impossible to perform nonce validation in our authorization_request Aggregate.
This PR changes the format of the DecodedVpToken struct to store the full VerifiablePresentationJwt wrapper. The decoding logic has been updated to:
A helper method .nonce() was also added to DecodedVpToken to allow the Aggregate in our ssi-agent to easily extract the nonce from the verified presentations.
Links to any relevant issues
Be sure to reference any related issues by adding
fixes issue #.How the change has been tested
Describe the tests that you ran to verify your changes.
Make sure to provide instructions for the maintainer as well as any relevant configurations.
Definition of Done checklist
Add an
xto the boxes that are relevant to your changes.