Skip to content

Commit

Permalink
remove requirement retraction ID is scoped to issuer
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul committed Nov 30, 2023
1 parent 7c25c86 commit 0306b39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
13 changes: 2 additions & 11 deletions discovery/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
ssi "github.com/nuts-foundation/go-did"
"github.com/nuts-foundation/go-did/did"
"github.com/nuts-foundation/go-did/vc"
"github.com/nuts-foundation/nuts-node/core"
"github.com/nuts-foundation/nuts-node/storage"
Expand Down Expand Up @@ -186,9 +185,8 @@ func (m *Module) validateRetraction(serviceID string, presentation vc.Verifiable
if len(presentation.VerifiableCredential) > 0 {
return errors.New("retraction presentation must not contain credentials")
}
// Check that the retraction refers to a presentation that:
// - is owned by the signer (same DID)
// - exists (if not, it might've already been removed due to expiry, or superseeded by a newer presentation)
// Check that the retraction refers to an existing presentation.
// If not, it might've already been removed due to expiry or superseded by a newer presentation.
var retractJTIString string
if retractJTIRaw, ok := presentation.JWT().Get("retract_jti"); !ok {
return errors.New("retraction presentation does not contain 'retract_jti' claim")
Expand All @@ -198,13 +196,6 @@ func (m *Module) validateRetraction(serviceID string, presentation vc.Verifiable
}
}
signerDID, _ := credential.PresentationSigner(presentation) // checked before
retractJTI, err := did.ParseDIDURL(retractJTIString)
if err != nil {
return fmt.Errorf("retraction presentation 'retract_jti' claim is not a valid DID URL: %w", err)
}
if !signerDID.Equals(retractJTI.DID) {
return errors.New("retraction presentation 'retract_jti' claim DID does not match JWT issuer")
}
exists, err := m.store.exists(serviceID, signerDID.String(), retractJTIString)
if err != nil {
return err
Expand Down
18 changes: 0 additions & 18 deletions discovery/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,6 @@ func Test_Module_Add(t *testing.T) {
err := m.Add(testServiceID, vp)
assert.EqualError(t, err, "retraction presentation 'retract_jti' claim is not a string")
})
t.Run("'retract_jti' claim in not a valid DID", func(t *testing.T) {
m, _ := setupModule(t, storageEngine)
vp := createPresentationCustom(aliceDID, func(claims map[string]interface{}, vp *vc.VerifiablePresentation) {
vp.Type = append(vp.Type, retractionPresentationType)
claims["retract_jti"] = "not a DID"
})
err := m.Add(testServiceID, vp)
assert.EqualError(t, err, "retraction presentation 'retract_jti' claim is not a valid DID URL: invalid DID")
})
t.Run("'retract_jti' claim does not reference a presentation of the signer", func(t *testing.T) {
m, _ := setupModule(t, storageEngine)
vp := createPresentationCustom(aliceDID, func(claims map[string]interface{}, vp *vc.VerifiablePresentation) {
vp.Type = append(vp.Type, retractionPresentationType)
claims["retract_jti"] = bobDID.String()
})
err := m.Add(testServiceID, vp)
assert.EqualError(t, err, "retraction presentation 'retract_jti' claim DID does not match JWT issuer")
})
})
}

Expand Down

0 comments on commit 0306b39

Please sign in to comment.