Skip to content

Commit

Permalink
OpenID4VP: Use VCR wallet when matching credential definitions (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul authored Sep 25, 2023
1 parent 1c62eba commit 7238d6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
12 changes: 2 additions & 10 deletions auth/api/iam/openid4vp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (
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/jsonld"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/credential"
"github.com/nuts-foundation/nuts-node/vcr/holder"
"net/http"
Expand Down Expand Up @@ -107,15 +105,9 @@ func (r *Wrapper) handlePresentationRequest(params map[string]string, session *S

// TODO: https://github.com/nuts-foundation/nuts-node/issues/2357
// TODO: Retrieve presentation definition
// TODO: Match on wallet instead
searchTerms := []vcr.SearchTerm{
{IRIPath: jsonld.CredentialSubjectPath, Type: vcr.Exact, Value: session.OwnDID.String()},
{IRIPath: jsonld.OrganizationNamePath, Type: vcr.NotNil},
{IRIPath: jsonld.OrganizationCityPath, Type: vcr.NotNil},
}
credentials, err := r.vcr.Search(ctx, searchTerms, false, nil)
credentials, err := r.vcr.Wallet().List(ctx, session.OwnDID)
if err != nil {
return nil, fmt.Errorf("unable to search for credentials: %w", err)
return nil, err
}
var ownCredentials []vc.VerifiableCredential
for _, cred := range credentials {
Expand Down
7 changes: 5 additions & 2 deletions auth/api/iam/openid4vp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/nuts-foundation/nuts-node/auth"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/credential"
"github.com/nuts-foundation/nuts-node/vcr/holder"
"github.com/nuts-foundation/nuts-node/vcr/pe"
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -94,11 +95,13 @@ func TestWrapper_handlePresentationRequest(t *testing.T) {
_ = peStore.LoadFromFile("test/presentation_definition_mapping.json")
mockVDR := types.NewMockVDR(ctrl)
mockVCR := vcr.NewMockVCR(ctrl)
mockWallet := holder.NewMockWallet(ctrl)
mockVCR.EXPECT().Wallet().Return(mockWallet)
mockAuth := auth.NewMockAuthenticationServices(ctrl)
instance := New(mockAuth, mockVCR, mockVDR)
mockAuth.EXPECT().PresentationDefinitions().Return(peStore)
mockVCR.EXPECT().Search(gomock.Any(), gomock.Any(), false, nil).Return(walletCredentials, nil)
mockWallet.EXPECT().List(gomock.Any(), holderDID).Return(walletCredentials, nil)
mockVDR.EXPECT().IsOwner(gomock.Any(), holderDID).Return(true, nil)
instance := New(mockAuth, mockVCR, mockVDR)

params := map[string]string{
"scope": "eOverdracht-overdrachtsbericht",
Expand Down

0 comments on commit 7238d6f

Please sign in to comment.