Skip to content

Commit

Permalink
OpenID4VP: Use VCR wallet when matching credential definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul committed Sep 8, 2023
1 parent 11f516e commit fab6bef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 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
5 changes: 4 additions & 1 deletion auth/api/iam/openid4vp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/nuts-foundation/go-did/vc"
"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/vdr/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -90,8 +91,10 @@ func TestWrapper_handlePresentationRequest(t *testing.T) {
ctrl := gomock.NewController(t)
mockVDR := types.NewMockVDR(ctrl)
mockVCR := vcr.NewMockVCR(ctrl)
mockWallet := holder.NewMockWallet(ctrl)
mockVCR.EXPECT().Wallet().Return(mockWallet)
instance := New(nil, mockVCR, mockVDR)
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)

params := map[string]string{
Expand Down

0 comments on commit fab6bef

Please sign in to comment.