Skip to content

Commit

Permalink
change to nutsv6-beta.11
Browse files Browse the repository at this point in the history
  • Loading branch information
woutslakhorst committed Sep 9, 2024
1 parent 59ebe1d commit 7c22388
Show file tree
Hide file tree
Showing 15 changed files with 4,261 additions and 3,395 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,23 @@ networks:
- execute `make docker`
- execute `./setup.sh <docker-compose-PEP.yml>` (setup is independent of PEP, so usually fine to run without argument (defaults to nginx))

### setup.sh
the setup script executes the following steps:
- use https://admin.left.local and add did:web:left.local:iam:uuid-left
- issue an NutsOrganizationCredential for this DID from this DID
- use https://admin.right.local and add did:web:right.local:iam:uuid-right
- issue an NutsOrganizationCredential for this DID from this DID
# TODO use v6
### After complete wipe of data
- use https://admin.left.local and add "1" as identity
- issue an NutsOrganizationCredential for the subject's DIDs from the subject's DIDs
- use https://admin.right.local and add "1" as identity
- issue an NutsOrganizationCredential for the subject's DIDs from the subject's DIDs
- enable services for discovery
- add services to the DID document using curl statement from below
- create `customers.json` files for demo-ehr config
- wait

curl statement to add services to DID document:
```shell
docker exec nuts-demo-ehr-node-left-1 curl -X POST "http://localhost:8081/internal/vdr/v2/did/did:web:node.left.local:iam:uuid-left/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-sender","serviceEndpoint": {"auth": "https://node.left.local/oauth2/did:web:node.left.local:iam:uuid-left/authorize","fhir": "https://left.local/fhir/1"}}'
docker exec nuts-demo-ehr-node-left-1 curl -X POST "http://localhost:8081/internal/vdr/v2/did/did:web:node.left.local:iam:uuid-left/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-receiver","serviceEndpoint": {"auth": "https://node.left.local/oauth2/did:web:node.left.local:iam:uuid-left/authorize","notification": "https://left.local/web/external/transfer/notify"}}'
docker exec nuts-demo-ehr-node-right-1 curl -X POST "http://localhost:8081/internal/vdr/v2/did/did:web:node.right.local:iam:uuid-right/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-sender","serviceEndpoint": {"auth": "https://node.right.local/oauth2/did:web:node.right.local:iam:uuid-right/authorize","fhir": "https://right.local/fhir/1"}}'
docker exec nuts-demo-ehr-node-right-1 curl -X POST "http://localhost:8081/internal/vdr/v2/did/did:web:node.right.local:iam:uuid-right/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-receiver","serviceEndpoint": {"auth": "https://node.right.local/oauth2/did:web:node.right.local:iam:uuid-right/authorize","notification": "https://right.local/web/external/transfer/notify"}}'
docker exec nuts-demo-ehr-node-left-1 curl -X POST "http://localhost:8081/internal/vdr/v2/subject/1/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-sender","serviceEndpoint": {"auth": "https://node.left.local/oauth2/1","fhir": "https://left.local/fhir/1"}}'
docker exec nuts-demo-ehr-node-left-1 curl -X POST "http://localhost:8081/internal/vdr/v2/subject/1/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-receiver","serviceEndpoint": {"auth": "https://node.left.local/oauth2/1","notification": "https://left.local/web/external/transfer/notify"}}'
docker exec nuts-demo-ehr-node-right-1 curl -X POST "http://localhost:8081/internal/vdr/v2/subject/1/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-sender","serviceEndpoint": {"auth": "https://node.right.local/oauth2/1","fhir": "https://right.local/fhir/1"}}'
docker exec nuts-demo-ehr-node-right-1 curl -X POST "http://localhost:8081/internal/vdr/v2/subject/1/service" -H "Content-Type: application/json" -d '{"type": "eOverdracht-receiver","serviceEndpoint": {"auth": "https://node.right.local/oauth2/1","notification": "https://right.local/web/external/transfer/notify"}}'
```

### Run
Expand Down
14 changes: 11 additions & 3 deletions api/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/monarko/fhirgo/STU3/resources"
"github.com/nuts-foundation/nuts-demo-ehr/domain/fhir"
"net/http"
"net/url"
"strings"

"github.com/nuts-foundation/nuts-demo-ehr/domain/notification"
"github.com/nuts-foundation/nuts-demo-ehr/domain/transfer"
Expand Down Expand Up @@ -223,8 +225,14 @@ func (w Wrapper) NotifyTransferUpdate(ctx echo.Context, taskID string) error {

// client_id for senderDID and sub for customerDID
_ = json.Unmarshal([]byte(introspectionResult), &target)
customerID := target["iss"].(string)
senderDID := target["sub"].(string)
issuerURLStr := target["iss"].(string)
// get senderDID via custom policy param
senderClientID := target["client_id"].(string)
senderDID := target["organization_did"].(string)
// we need the subjectID, which is at the end of the path, not panic safe
issuerURL, _ := url.Parse(issuerURLStr)
idx := strings.LastIndex(issuerURL.Path, "/")
customerID := issuerURL.Path[idx+1:]

codeError := datatypes.Code("error")
codeInvalid := datatypes.Code("invalid")
Expand Down Expand Up @@ -264,7 +272,7 @@ func (w Wrapper) NotifyTransferUpdate(ctx echo.Context, taskID string) error {
Code: &codeInvalid,
Severity: &codeError,
Details: &datatypes.CodeableConcept{
Text: fhir.ToStringPtr(fmt.Sprintf("received transfer notification for unknown taskOwner with DID: %s", senderDID)),
Text: fhir.ToStringPtr(fmt.Sprintf("received transfer notification for unknown taskOwner with ID: %s", senderClientID)),
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions docker-compose/left/config/demo/customers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"1":{"active":false,"city":"Enske","domain":"","id":"1","name":"Left"}
}
14 changes: 14 additions & 0 deletions docker-compose/left/config/node/policies/eOverdracht.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
"pattern": "^did:web:node\\.(left|right)\\.local:iam:"
}
},
{
"id": "organization_did",
"path": [
"$.credentialSubject.id",
"$.credentialSubject[0].id"
]
},
{
"id": "organization_name",
"path": [
Expand Down Expand Up @@ -200,6 +207,13 @@
"pattern": "^did:web:node\\.(left|right)\\.local:iam:"
}
},
{
"id": "organization_did",
"path": [
"$.credentialSubject.id",
"$.credentialSubject[0].id"
]
},
{
"id": "organization_name",
"path": [
Expand Down
Binary file added docker-compose/left/data/hapi/database/h2.mv.db
Binary file not shown.
3 changes: 3 additions & 0 deletions docker-compose/right/config/demo/customers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"1":{"active":false,"city":"Enske","domain":"","id":"1","name":"Right"}
}
14 changes: 14 additions & 0 deletions docker-compose/right/config/node/policies/eOverdracht.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
"pattern": "^did:web:node\\.(left|right)\\.local:iam:"
}
},
{
"id": "organization_did",
"path": [
"$.credentialSubject.id",
"$.credentialSubject[0].id"
]
},
{
"id": "organization_name",
"path": [
Expand Down Expand Up @@ -200,6 +207,13 @@
"pattern": "^did:web:node\\.(left|right)\\.local:iam:"
}
},
{
"id": "organization_did",
"path": [
"$.credentialSubject.id",
"$.credentialSubject[0].id"
]
},
{
"id": "organization_name",
"path": [
Expand Down
Binary file added docker-compose/right/data/hapi/database/h2.mv.db
Binary file not shown.
Loading

0 comments on commit 7c22388

Please sign in to comment.