Skip to content

Commit 4914252

Browse files
committed
Changes adding a third-party node and list of issuers mocked for REAR integration
1 parent 2a5a883 commit 4914252

File tree

15 files changed

+228
-67
lines changed

15 files changed

+228
-67
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,11 @@ clean-build:
313313
clean-fixtures:
314314
@rm -Rf ./test/bdd/fixtures/keys/tls
315315
@rm -Rf ./test/bdd/fixtures/demo/openapi/specs
316-
@cd test/bdd/fixtures/demo/openapi && docker-compose down 2> /dev/null
317316
@cd test/bdd/fixtures/sidetree-mock && docker-compose down 2> /dev/null
317+
@cd test/bdd/fixtures/demo/openapi && docker-compose down 2> /dev/null
318318
@cd test/bdd/fixtures/agent-rest && docker-compose down 2> /dev/null
319+
320+
319321

320322
.PHONY: clean-fixtures-no-build
321323
clean-fixtures-no-build:

deploy/agent-rest/.env

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ DEFAULT_MEDIA_TYPE_PROFILES=didcomm/v2,didcomm/aip2;env=rfc19,didcomm/aip2;env=r
2727
DEFAULT_KEY_TYPE=ED25519
2828
DEFAULT_KEY_AGREEMENT_TYPE=X25519ECDHKW
2929

30+
31+
32+
# Third agent configurations
33+
THIRD_HOST=0.0.0.0
34+
THIRD_INBOUND_PORT=7081
35+
THIRD_API_PORT=7082
36+
THIRD_DEBUG_PORT=3000
37+
38+
3039
# Holder agent configurations
3140
HOLDER_HOST=0.0.0.0
3241
HOLDER_INBOUND_PORT=8081
@@ -40,6 +49,10 @@ ISSUER_API_PORT=9082
4049
ISSUER_DEBUG_PORT=5000
4150

4251

52+
# Third webhook configurations
53+
THIRD_WEBHOOK_CONTAINER_NAME=third
54+
THIRD_WEBHOOK_HOST=0.0.0.0
55+
THIRD_WEBHOOK_PORT=7083
4356

4457
# Holder webhook configurations
4558
HOLDER_WEBHOOK_CONTAINER_NAME=holder

deploy/demo/openapi/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# Demo Agent API hosts
1313
DEVICE_API_HOST=localhost:8082
1414
ISSUER_API_HOST=localhost:9082
15+
THIRD_API_HOST=localhost:7082

deploy/demo/openapi/docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ services:
3333
networks:
3434
- test
3535

36+
third:
37+
container_name: third-swagger
38+
image: swaggerapi/swagger-ui
39+
environment:
40+
- SWAGGER_JSON=/specs/openapi-${THIRD_API_HOST}.yml
41+
- BASE_URL=/openapi
42+
ports:
43+
- 7089:8080
44+
volumes:
45+
- ./specs:/specs
46+
networks:
47+
- test
48+
3649

3750
networks:
3851
test:

pkg/controller/command/poc/command.go

Lines changed: 29 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
VerifyCredentialRequestErrorCode
4545
AcceptEnrolmentRequestErrorCode
4646
TestingCallRequestErrorCode
47+
GetTrustedIssuerListrRequestErrorCode
4748
)
4849

4950
// constants for the VDR controller's methods.
@@ -56,8 +57,9 @@ const (
5657
DoDeviceEnrolmentCommandMethod = "DoDeviceEnrolment"
5758
GenerateVPCommandMethod = "GenerateVP"
5859
AcceptEnrolmentCommandMethod = "AcceptEnrolment"
59-
VerifyCredentialCommandMethod = "ValidateVP" // TODO UMU: remove TESTING
60+
VerifyCredentialCommandMethod = "ValidateVP"
6061
TestingCallMethod = "TestingCall"
62+
GetTrustedIssuerListMethod = "GetTrustedIssuerList"
6163
// error messages.
6264
errEmptyNewDID = "keys is mandatory"
6365
errEmptyUrl = "url is mandatory"
@@ -149,6 +151,8 @@ func (o *Command) GetHandlers() []command.Handler {
149151
cmdutil.NewCommandHandler(CommandName, GenerateVPCommandMethod, o.GenerateVP),
150152
cmdutil.NewCommandHandler(CommandName, AcceptEnrolmentCommandMethod, o.AcceptEnrolment),
151153
cmdutil.NewCommandHandler(CommandName, TestingCallMethod, o.TestingCall),
154+
cmdutil.NewCommandHandler(CommandName, VerifyCredentialCommandMethod, o.VerifyCredential),
155+
cmdutil.NewCommandHandler(CommandName, GetTrustedIssuerListMethod, o.GetTrustedIssuerList),
152156
}
153157
}
154158

@@ -353,65 +357,7 @@ func (o *Command) NewDID(rw io.Writer, req io.Reader) command.Error {
353357

354358

355359

356-
357-
func (o * Command) getSignedProof()(string) {
358-
randomString , err := generateRandomString(15)
359-
if err != nil {
360-
fmt.Println("Error generating random string:", err)
361-
return ""
362-
}
363-
364-
//Get DID/DIDDoc for specifying key, issuer...
365-
// reader, err := getReader(&vdrc.IDArg{
366-
// ID: o.currentDID,
367-
// })
368-
// var getResponse bytes.Buffer
369-
// err = o.vdrcommand.GetDID(&getResponse, reader)
370-
// if err != nil {
371-
// logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to get DID: "+err.Error())
372-
// }
373-
// var parsedDoc vdrc.Document
374-
// err = json.NewDecoder(&getResponse).Decode(&parsedDoc)
375-
// if err != nil {
376-
// logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to decode DID Document: "+err.Error())
377-
// }
378-
// didDoc, err := did.ParseDocument(parsedDoc.DID)
379-
// if err != nil {
380-
// logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to parse DID Document: "+err.Error())
381-
// }
382-
// fmt.Println("DID:", didDoc.ID)
383-
384-
385-
message := []byte(randomString)
386-
387-
cryptoService := o.ctx.Crypto()
388-
// Sign a random string
389-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "keypairKEYID "+o.currentKeyPair.KeyID)
390-
signature, err := cryptoService.Sign(message, o.currentKeyPair.KeyID)
391-
if err != nil {
392-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to sign message: "+err.Error())
393-
}
394-
395-
fmt.Println("Signature:", signature)
396-
397-
// Verify the signature
398-
valid := cryptoService.Verify(signature,message, o.currentKeyPair.PublicKey)
399-
if valid == nil {
400-
fmt.Println("Signature verification successful!")
401-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "Signature verification successful!")
402-
} else {
403-
fmt.Println("Signature verification failed.")
404-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "Signature verification failed.")
405-
}
406-
return randomString
407-
}
408-
409-
func (o * Command) signJWT(token string)(string) {
410-
randomString , err := generateRandomString(15)
411-
if err != nil {
412-
fmt.Println("Error generating random string:", err)
413-
return ""
414-
}
360+
func (o * Command) signJWT(token string) {
415361

416362
request := vcwalletc.SignJWTRequest{
417363
WalletAuth: vcwalletc.WalletAuth{UserID: o.walletuid, Auth: token},
@@ -425,23 +371,23 @@ func (o * Command) signJWT(token string)(string) {
425371

426372
reqData, err := json.Marshal(request)
427373
if err != nil {
428-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to marshal request: "+err.Error())
374+
logutil.LogInfo(logger, CommandName, "SignJWT", "failed to marshal request: "+err.Error())
429375
}
430376
req := bytes.NewReader(reqData)
431377
// Capture the output
432378
var signBuf bytes.Buffer
433379

434380
// Sign the JWT
435381
if err := o.vcwalletcommand.SignJWT(&signBuf, req); err != nil {
436-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to sign JWT: "+err.Error())
382+
logutil.LogInfo(logger, CommandName, "SignJWT", "failed to sign JWT: "+err.Error())
437383
}
438384

439385

440386
var jwtResponse vcwalletc.SignJWTResponse
441387

442388
err = json.Unmarshal(signBuf.Bytes(), &jwtResponse)
443389
if err != nil {
444-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to unmarshal JWT: "+err.Error())
390+
logutil.LogInfo(logger, CommandName, "SignJWT", "failed to unmarshal JWT: "+err.Error())
445391
}
446392

447393

@@ -463,11 +409,9 @@ func (o * Command) signJWT(token string)(string) {
463409

464410
err = o.vcwalletcommand.VerifyJWT(&verifyBuf, verifyReqReader)
465411
if err != nil {
466-
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "failed to verify JWT: "+err.Error())
412+
logutil.LogInfo(logger, CommandName, "SignJWT", "failed to verify JWT: "+err.Error())
467413
}
468414
fmt.Println("Verification result:", verifyBuf.String())
469-
470-
return randomString
471415
}
472416

473417
// DoDeviceEnrolment Device completes an enrolment process against an issuer
@@ -928,3 +872,22 @@ func (o *Command) AcceptEnrolment(rw io.Writer, req io.Reader) command.Error {
928872
logutil.LogInfo(logger, CommandName, AcceptEnrolmentCommandMethod, "success")
929873
return nil
930874
}
875+
876+
// GetTrustedIssuerList returns the list of trusted issuers, mocked for nowq
877+
func (o *Command) GetTrustedIssuerList(rw io.Writer, req io.Reader) command.Error {
878+
//TODO UMU: Implement
879+
trustedIssuer := TrustedIssuer{
880+
DID : "did:fabric:zxdkpwDnu7ixBidF_I8sgMI6Q4St0t90HY-_JmlHZFI",
881+
IssuerUrl : "https://issuer:9082",
882+
}
883+
var trustedIssuerList []TrustedIssuer
884+
trustedIssuerList = append(trustedIssuerList, trustedIssuer)
885+
886+
var trustedIssuerListResponse = GetTrustedIssuerListResult{
887+
TrustedIssuers: trustedIssuerList,
888+
889+
}
890+
891+
command.WriteNillableResponse(rw, &trustedIssuerListResponse, logger)
892+
return nil
893+
}

pkg/controller/command/poc/models.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,12 @@ type VerifyCredentialResult struct {
138138

139139
Error string `json:"error,omitempty"`
140140
}
141+
142+
type GetTrustedIssuerListResult struct {
143+
TrustedIssuers []TrustedIssuer `json:"trustedIssuers,omitempty"`
144+
}
145+
146+
type TrustedIssuer struct {
147+
DID string `json:"did,omitempty"`
148+
IssuerUrl string `json:"issuerUrl,omitempty"`
149+
}

pkg/controller/command/vdr/command.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ const (
3939

4040
// CreateDIDErrorCode for create did error.
4141
CreateDIDErrorCode
42+
43+
//GetTrustedIssuerListCode
44+
GetTrustedIssuerListCode
4245
)
4346

4447
// constants for the VDR controller's methods.
@@ -52,6 +55,7 @@ const (
5255
GetDIDCommandMethod = "GetDID"
5356
ResolveDIDCommandMethod = "ResolveDID"
5457
CreateDIDCommandMethod = "CreateDID"
58+
GetTrustedIssuerList = "GetTrustedIssuerList"
5559

5660
// error messages.
5761
errEmptyDIDName = "name is mandatory"
@@ -96,6 +100,7 @@ func (o *Command) GetHandlers() []command.Handler {
96100
cmdutil.NewCommandHandler(CommandName, GetDIDsCommandMethod, o.GetDIDRecords),
97101
cmdutil.NewCommandHandler(CommandName, ResolveDIDCommandMethod, o.ResolveDID),
98102
cmdutil.NewCommandHandler(CommandName, CreateDIDCommandMethod, o.CreateDID),
103+
cmdutil.NewCommandHandler(CommandName, GetTrustedIssuerList, o.GetTrustedIssuerList),
99104
}
100105
}
101106

@@ -285,3 +290,8 @@ func (o *Command) GetDIDRecords(rw io.Writer, req io.Reader) command.Error {
285290

286291
return nil
287292
}
293+
294+
// GetTrustedIssuerList retrieves the trusted issuer list.
295+
func (o *Command) GetTrustedIssuerList(rw io.Writer, req io.Reader) command.Error {
296+
return nil
297+
}

pkg/controller/rest/poc/operation.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
AcceptDeviceEnrolmentPath = PocOperationID + "/acceptEnrolment"
2727
VerifyCredentialPath = PocOperationID + "/verifyCredential"
2828
TestingCallPath = PocOperationID + "/testingCall"
29+
GetTrustedIssuerListPath = PocOperationID + "/trustedIssuers"
2930
)
3031

3132

@@ -66,6 +67,7 @@ func (o *Operation) registerHandler() {
6667
cmdutil.NewHTTPHandler(AcceptDeviceEnrolmentPath, http.MethodPost, o.AcceptDeviceEnrolment),
6768
cmdutil.NewHTTPHandler(VerifyCredentialPath, http.MethodPost, o.VerifyCredential),
6869
cmdutil.NewHTTPHandler(TestingCallPath, http.MethodPost, o.TestingCall),
70+
cmdutil.NewHTTPHandler(GetTrustedIssuerListPath, http.MethodGet, o.GetTrustedIssuerList),
6971
}
7072
}
7173

@@ -130,3 +132,14 @@ func (o *Operation) VerifyCredential(rw http.ResponseWriter, req *http.Request)
130132
func (o *Operation) TestingCall(rw http.ResponseWriter, req *http.Request) {
131133
rest.Execute(o.command.TestingCall, rw, req.Body)
132134
}
135+
136+
// GetTrustedIssuerList swagger:route GET /poc/trustedIssuers poc GetTrustedIssuerListReq
137+
//
138+
// Get the list of trusted issuers
139+
//
140+
// Responses:
141+
// default: genericError
142+
// 200: documentRes
143+
func (o *Operation) GetTrustedIssuerList(rw http.ResponseWriter, req *http.Request) {
144+
rest.Execute(o.command.GetTrustedIssuerList, rw, req.Body)
145+
}

pkg/doc/ldcontext/embed/third_party/umu/poc.jsonld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"phone": "ex:phone",
1414
"holderRole": "ex:holderRole",
1515
"fluidosRole": "ex:fluidosRole",
16+
"association": "ex:association",
17+
"deviceType": "ex:deviceType",
1618
"fluidosID": "ex:fluidosID",
1719
"holderAddress": "ex:holderAddress",
1820
"holderEmail": "ex:holderEmail",

runscript.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
export PROJECT_ROOT=github.com/hyperledger/aries-framework-go
4+
5+
# Stop demo agent rest containers
6+
echo "Stopping demo agent rest containers ..."
7+
DEMO_COMPOSE_PATH=test/bdd/fixtures/demo/openapi SIDETREE_COMPOSE_PATH=test/bdd/fixtures/sidetree-mock AGENT_REST_COMPOSE_PATH=test/bdd/fixtures/agent-rest
8+
9+
# Generate test keys
10+
mkdir -p -p test/bdd/fixtures/keys/tls
11+
docker run -i --rm \
12+
-v $(pwd):/opt/go/src/$(PROJECT_ROOT) \
13+
--entrypoint "/opt/go/src/$(PROJECT_ROOT)/scripts/generate_test_keys.sh" \
14+
frapsoft/openssl
15+
16+
# Generate dpabc clib
17+
docker build -f ./images/agent-rest/Dockerfile_base_image_with_compilation_tools \
18+
--build-arg ALPINE_VER=$(ALPINE_VER) \
19+
-t basecompilationcontainer .
20+
docker run -v $(pwd):/opt/go/src/$(PROJECT_ROOT)
21+
docker image rm basecompilationcontainer
22+
23+
# Run Fabric
24+
echo "Launching Fabric deployment."
25+
FABRIC_PATH="$(FABRIC_PATH)" \
26+
FABRIC_VERSION="$(FABRIC_VERSION)" \
27+
CONNECTION_PROFILE_PATH="$(CONNECTION_PROFILE_PATH)" \
28+
./scripts/fabric/run_fabric.sh
29+
30+
# Generate OpenAPI demo specs
31+
echo "Generate demo agent rest controller API specifications using Open API"
32+
SPEC_PATH=${OPENAPI_SPEC_PATH} OPENAPI_DEMO_PATH=test/bdd/fixtures/demo/openapi
33+
34+
# Run OpenAPI demo script
35+
./scripts/run-openapi-demo.sh

0 commit comments

Comments
 (0)