Skip to content

Commit 3894b35

Browse files
backport fix vdr v1 CreateDID KeyFlags (#3615)
1 parent 9ef4d10 commit 3894b35

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

docs/_static/vdr/v1.yaml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ paths:
1111
/internal/vdr/v1/did:
1212
post:
1313
summary: Creates a new Nuts DID
14+
deprecated: true
1415
description: |
15-
The DID Document will be created according to the given request. If a combination of options is not allowed, a 400 is returned.
16-
The default values for selfControl, assertionMethod, keyAgreement, and capabilityInvocation are true. The default for controllers is an empty list. All other options default to false.
17-
Only a single keypair will be generated. All enabled methods will reuse the same key pair. A seperate keypair will be generated to generate the DID if SelfControl is false.
16+
Starting with v6.0.0, the entire body will be ignored and default values will be used.
17+
The default values are: selfControl = true, assertionMethod = true, keyAgreement = true, capabilityInvocation = true, capabilityDelegation = true, authentication = true and controllers = [].
18+
19+
Only a single keypair will be generated. All enabled methods will reuse the same key pair.
1820
1921
error returns:
2022
* 400 - Invalid (combination of) options
@@ -272,7 +274,7 @@ components:
272274
authentication:
273275
type: boolean
274276
description: indicates if the generated key pair can be used for authentication.
275-
default: false
277+
default: true
276278
capabilityInvocation:
277279
type: boolean
278280
description: |
@@ -288,6 +290,17 @@ components:
288290
type: boolean
289291
description: indicates if the generated key pair can be used for Key agreements.
290292
default: true
293+
selfControl:
294+
type: boolean
295+
description: whether the generated DID Document can be altered with its own capabilityInvocation key.
296+
default: true
297+
controllers:
298+
type: array
299+
items:
300+
type: string
301+
description: |
302+
List of DID controllers. The DID controllers are the entities that can alter the DID Document.
303+
default: []
291304
VerificationMethodRelationship:
292305
properties:
293306
assertionMethod:
@@ -313,10 +326,6 @@ components:
313326
type: boolean
314327
description: indicates if the generated key pair can be used for Key agreements.
315328
default: true
316-
selfControl:
317-
type: boolean
318-
description: whether the generated DID Document can be altered with its own capabilityInvocation key.
319-
default: true
320329
securitySchemes:
321330
jwtBearerAuth:
322331
type: http

docs/pages/release_notes.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
Release notes
33
#############
44

5+
***************
6+
Peanut (v6.0.6)
7+
***************
8+
9+
Release date: 2024-12-16
10+
11+
- `#3610 <https://github.com/nuts-foundation/nuts-node/issues/3610>`_: Fix DID Creation with VDR V1 API.
12+
The Body for POST /internal/vdr/v1/did is now completely ignored, defaults are used.
13+
14+
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v6.0.5...v6.0.6
15+
516
***************
617
Peanut (v6.0.5)
718
***************

vdr/api/v1/api.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,9 @@ func (a *Wrapper) Routes(router core.EchoRouter) {
125125
}
126126

127127
// CreateDID creates a new DID Document and returns it.
128-
func (a *Wrapper) CreateDID(ctx context.Context, request CreateDIDRequestObject) (CreateDIDResponseObject, error) {
129-
options := didsubject.DefaultCreationOptions()
130-
131-
defaultKeyFlags := didnuts.DefaultKeyFlags()
132-
keyFlags := request.Body.VerificationMethodRelationship.ToFlags(defaultKeyFlags)
133-
if keyFlags != defaultKeyFlags {
134-
options = options.With(keyFlags)
135-
}
136-
options = options.With(didsubject.NutsLegacyNamingOption{})
128+
func (a *Wrapper) CreateDID(ctx context.Context, _ CreateDIDRequestObject) (CreateDIDResponseObject, error) {
129+
// request body is ignored, defaults are used.
130+
options := didsubject.DefaultCreationOptions().With(didsubject.NutsLegacyNamingOption{})
137131

138132
docs, _, err := a.SubjectManager.Create(ctx, options)
139133
// if this operation leads to an error, it may return a 500

vdr/api/v1/api_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package v1
2222
import (
2323
"context"
2424
"errors"
25+
"github.com/nuts-foundation/nuts-node/core/to"
2526
"github.com/nuts-foundation/nuts-node/storage/orm"
2627
"github.com/nuts-foundation/nuts-node/vdr/didsubject"
2728
"net/http"
@@ -48,7 +49,7 @@ func TestWrapper_CreateDID(t *testing.T) {
4849

4950
t.Run("ok - defaults", func(t *testing.T) {
5051
ctx := newMockContext(t)
51-
request := DIDCreateRequest{}
52+
request := DIDCreateRequest{SelfControl: to.Ptr(false)} // SelfControl value is overwritten with default
5253
ctx.subjectManager.EXPECT().Create(gomock.Any(), didsubject.DefaultCreationOptions().With(didsubject.NutsLegacyNamingOption{})).Return([]did.Document{*didDoc}, "subject", nil)
5354

5455
response, err := ctx.client.CreateDID(nil, CreateDIDRequestObject{Body: &request})

0 commit comments

Comments
 (0)