Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add VDR v2 spec, generated code and empty wrapper #2630

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions codegen/configs/vdr_v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package: v2
generate:
echo-server: true
client: true
models: true
strict-server: true
output-options:
skip-prune: true
exclude-schemas:
- DIDDocument
- DIDDocumentMetadata
- Service
- VerificationMethod
280 changes: 280 additions & 0 deletions docs/_static/vdr/v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
openapi: "3.0.0"
info:
title: Nuts Verifiable Data Registry API spec
description: API specification for the Verifiable Data Registry
version: 2.0.0
license:
name: GPLv3
servers:
- url: http://localhost:1323
paths:
/internal/vdr/v2/did:
post:
summary: Creates a new Web DID
description: |
A new web DID and DID Document are created.
A single key pair is generated and added to the DID document. The key pair is used for all verificationMethods.
No services are added. If no ID is given, a random UUID is generated.

error returns:
* 400 - Returned in case of malformed DID in the request body
* 500 - An error occurred while processing the request
operationId: "createDID"
tags:
- DID
requestBody:
description: Options for the DID creation.
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/CreateDIDOptions'
responses:
"200":
description: "New DID has been created successfully. Returns the DID document."
content:
application/json:
schema:
$ref: '#/components/schemas/DIDDocument'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}:
Copy link
Member

Choose a reason for hiding this comment

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

this only resolves did:web DIDs owned by the local node? I think we already have /iam/{did} which essentially does the same?

Copy link
Member Author

@woutslakhorst woutslakhorst Nov 29, 2023

Choose a reason for hiding this comment

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

We have iam/{id}/did.json which is the public URL where the web DID Document lives.
We do not have a resolve API there. Since v1 might be removed v2 still needs a resolve.

parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
get:
summary: "Resolves a DID document"
description: |
Resolves a DID document.

error returns:
* 400 - Returned in case of malformed DID
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
operationId: "resolveDID"
tags:
- DID
responses:
"200":
description: DID document has been found and returned.
content:
application/json:
schema:
$ref: '#/components/schemas/DIDResolutionResult'
default:
$ref: '../common/error_response.yaml'
delete:
summary: Deletes a locally managed Document.
description: |

error returns:
* 400 - the DID param was malformed
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
operationId: "deleteDID"
tags:
- DID
responses:
"204":
description: DID document has been deactivated.
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/service:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
post:
summary: Adds a service to the DID document.
description: |
It adds the given service to the DID Document. The ID will be generated when not given.

error returns:
* 400 - Returned in case of malformed DID or service
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
parameters:
- name: service
in: body
description: Service to be added to the DID document.
required: true
schema:
$ref: '#/components/schemas/Service'
operationId: addService
tags:
- DID
responses:
"200":
description: "New service has been added successfully. Returns the service."
content:
application/json:
schema:
$ref: '#/components/schemas/VerificationMethod'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/service/{id}:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
- name: id
in: path
description: URL encoded id identifying the service.
required: true
example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b#3106f751-59e3-440f-b57b-39a96a2da6c6"
schema:
type: string
delete:
summary: Delete a specific service
description: |
Removes the service from the DID Document.
No cascading will happen for references to the service.

error returns:
* 404 - Corresponding DID document or verification method could not be found
* 500 - An error occurred while processing the request
tags:
- DID
operationId: deleteService
responses:
"204":
description: The service was successfully deleted
default:
$ref: '../common/error_response.yaml'
put:
summary: Updates a service in the DID document.
description: |
It updates the given service in the DID Document.

error returns:
* 400 - Returned in case of malformed DID or service
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
tags:
- DID
operationId: updateService
parameters:
- name: service
in: body
description: Service to be added to the DID document.
required: true
schema:
$ref: '#/components/schemas/Service'
responses:
"200":
description: "Service has been updated successfully. Returns the service."
content:
application/json:
schema:
$ref: '#/components/schemas/Service'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/verificationmethod:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
post:
summary: Creates and adds a new verificationMethod to the DID document.
description: |
It creates a new private public keypair. The public key is wrapped in verificationMethod. This method is added to the DID Document.
The key pair is used for all verificationMethods.

error returns:
* 404 - Corresponding DID document could not be found
* 500 - An error occurred while processing the request
operationId: addVerificationMethod
tags:
- DID
responses:
"200":
description: "New verification method has been created and added successfully. Returns the verification method."
content:
application/json:
schema:
$ref: '#/components/schemas/VerificationMethod'
default:
$ref: '../common/error_response.yaml'
/internal/vdr/v2/did/{did}/verificationmethod/{id}:
parameters:
- name: did
in: path
description: URL encoded DID.
required: true
example: did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b
schema:
type: string
- name: id
in: path
description: URL encoded ID identifying the verification method.
required: true
example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b#3106f751-59e3-440f-b57b-39a96a2da6c6"
schema:
type: string
delete:
summary: Delete a specific verification method
description: |
Removes the verification method from the DID Document.

error returns:
* 404 - Corresponding DID document or verification method could not be found
* 500 - An error occurred while processing the request
tags:
- DID
operationId: deleteVerificationMethod
responses:
"204":
description: Verification Method was successfully deleted
default:
$ref: '../common/error_response.yaml'
components:
schemas:
CreateDIDOptions:
type: object
properties:
id:
type: string
description: The ID of the DID document. If not given, a random UUID is generated.
example: "did:web:example.com:iam:013c6fda-73e8-45ee-9220-48652dba854b"
DIDDocument:
$ref: '../common/ssi_types.yaml#/components/schemas/DIDDocument'
DIDDocumentMetadata:
$ref: '../common/ssi_types.yaml#/components/schemas/DIDDocumentMetadata'
VerificationMethod:
$ref: '../common/ssi_types.yaml#/components/schemas/VerificationMethod'
Service:
$ref: '../common/ssi_types.yaml#/components/schemas/Service'
DIDResolutionResult:
required:
- document
- documentMetadata
properties:
document:
$ref: '#/components/schemas/DIDDocument'
documentMetadata:
$ref: '#/components/schemas/DIDDocumentMetadata'
securitySchemes:
jwtBearerAuth:
type: http
scheme: bearer

security:
- {}
- jwtBearerAuth: []
4 changes: 2 additions & 2 deletions e2e-tests/oauth-flow/rfc021/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.7"
services:
nodeA-backend:
image: "${IMAGE_NODE_A:-nutsfoundation/nuts-node:master}"
image: "${IMAGE_NODE_A:-nutsfoundation/nuts-node:latest}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
image: "${IMAGE_NODE_A:-nutsfoundation/nuts-node:latest}"
image: "${IMAGE_NODE_A:-nutsfoundation/nuts-node:master}"

ports:
- "11323:1323"
environment:
Expand All @@ -25,7 +25,7 @@ services:
- "../../tls-certs/truststore.pem:/etc/nginx/ssl/truststore.pem:ro"
- "./node-A/html:/etc/nginx/html:ro"
nodeB:
image: "${IMAGE_NODE_B:-nutsfoundation/nuts-node:master}"
image: "${IMAGE_NODE_B:-nutsfoundation/nuts-node:latest}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
image: "${IMAGE_NODE_B:-nutsfoundation/nuts-node:latest}"
image: "${IMAGE_NODE_B:-nutsfoundation/nuts-node:master}"

ports:
- "21323:1323"
environment:
Expand Down
1 change: 1 addition & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ gen-api:
oapi-codegen --config codegen/configs/common_ssi_types.yaml docs/_static/common/ssi_types.yaml | gofmt > api/ssi_types.go
oapi-codegen --config codegen/configs/crypto_v1.yaml -package v1 docs/_static/crypto/v1.yaml | gofmt > crypto/api/v1/generated.go
oapi-codegen --config codegen/configs/vdr_v1.yaml docs/_static/vdr/v1.yaml | gofmt > vdr/api/v1/generated.go
oapi-codegen --config codegen/configs/vdr_v2.yaml docs/_static/vdr/v2.yaml | gofmt > vdr/api/v2/generated.go
oapi-codegen --config codegen/configs/network_v1.yaml docs/_static/network/v1.yaml | gofmt > network/api/v1/generated.go
oapi-codegen --config codegen/configs/vcr_v2.yaml docs/_static/vcr/vcr_v2.yaml | gofmt > vcr/api/vcr/v2/generated.go
oapi-codegen --config codegen/configs/vcr_openid4vci_v0.yaml docs/_static/vcr/openid4vci_v0.yaml | gofmt > vcr/api/openid4vci/v0/generated.go
Expand Down
4 changes: 3 additions & 1 deletion vdr/api/v1/types.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/*
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Expand Down
Loading
Loading