Skip to content

Conversation

@gerardsn
Copy link
Member

@gerardsn gerardsn commented Jul 4, 2023

new approach to validation of credential and credential_definition #2037 and #2050
per commit:

  1. Add OfferedCredential and CredentialDefinition types to make validation and parsing easier
  2. Add Format specific CredentialDefinition validation on CredentialRequest and CredentialOffer
  3. Compare CredentialDefinition with received/issued VC and partial revert of OIDC4VCI: compare offered and received credential types for equality #2272

@gerardsn gerardsn marked this pull request as ready for review July 4, 2023 12:56
@gerardsn gerardsn marked this pull request as draft July 4, 2023 13:53
@gerardsn gerardsn marked this pull request as ready for review July 4, 2023 15:17
@gerardsn gerardsn changed the title OpenID4VCI: Add OfferedCredential and CredentialDefinition types OpenID4VCI: Validate credential_definition and compare with credential Jul 4, 2023
@gerardsn gerardsn linked an issue Jul 4, 2023 that may be closed by this pull request
Copy link
Member

@woutslakhorst woutslakhorst left a comment

Choose a reason for hiding this comment

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

Just some comments

if isOffer {
return errors.New("invalid credential_definition: credentialSubject not allowed in offer")
}
// TODO: add credentialSubject validation.
Copy link
Member

Choose a reason for hiding this comment

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

a todo

Copy link
Member Author

Choose a reason for hiding this comment

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

we currently do not use the credentialSubject, and I am not sure what to validate here. We could add some basic validation but that might give us more issues later on if the validation turns out to be incorrect.

Copy link
Member

Choose a reason for hiding this comment

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

then it's not a todo for the code. If we need to remember something, it should be listed in an issue not in the code.

Copy link
Member Author

@gerardsn gerardsn Jul 7, 2023

Choose a reason for hiding this comment

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

created issue #2320 and referenced in to TODO

@gerardsn gerardsn requested a review from woutslakhorst July 6, 2023 10:17
)

// ValidateCredentialDefinition validates the CredentialDefinition according to the VerifiableCredentialJSONLDFormat format
func ValidateCredentialDefinition(definition *CredentialDefinition, isOffer bool) error {
Copy link
Member

Choose a reason for hiding this comment

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

you could put this func on CredentialDefinition, making the nil check obsolete

Copy link
Member Author

Choose a reason for hiding this comment

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

doesn't that just move the nil check outside this function before calling the validator on the CredentialDefinition?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've made it a function on the CredentialDefinition, but it still contains the nil check.

Copy link
Member

Choose a reason for hiding this comment

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

That's because of the pointer receiver. Do we always need a definition on an offer. Then the offer can also remove the pointer from the definition. You'll get an empty struct but validation would fail for that as well. Less pointers equals easier life.

Copy link
Member Author

@gerardsn gerardsn Jul 7, 2023

Choose a reason for hiding this comment

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

the CredentialDefinition is optional since it is only part of the verifiable credential flows, not de mDL flows. We only support ldp_vc for now where it is required. So I could remove the pointer, but then we'd have to add an Empty() check to assert that it was provided.

Copy link
Member Author

@gerardsn gerardsn Jul 7, 2023

Choose a reason for hiding this comment

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

Unless you don't care about the specific error and just let it fail on missing @context. I prefer the current solution as it is closest to the spec and therefor easiest to understand/extend.

@reinkrul reinkrul self-requested a review July 6, 2023 12:54
@gerardsn gerardsn force-pushed the oidc/add-OfferedCredential-and-CredentialDefinition-types branch from 6f0dfbd to 5af0a00 Compare July 10, 2023 07:57
@gerardsn gerardsn merged commit ca12cd0 into master Jul 10, 2023
@gerardsn gerardsn deleted the oidc/add-OfferedCredential-and-CredentialDefinition-types branch July 10, 2023 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate requested credential definition and format

4 participants