Skip to content

Commit

Permalink
refactored traefik and added postman collection
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed Apr 18, 2024
1 parent c66f58a commit 4ee5904
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
HTTP_PORT=81
GRPC_PORT=5000
GRPC_PORT=5001
2 changes: 1 addition & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function bootstrap() {
'proto',
'user/user.proto',
),
url: '0.0.0.0:5000',
url: '0.0.0.0:50051',
},
});

Expand Down
49 changes: 38 additions & 11 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
version: '3'
services:

whoami:
# A container that exposes an API to show its IP address
image: traefik/whoami
expose:
- '80'
labels:
traefik.enable: true
traefik.http.routers.whoami.rule: Host(`whoami.localhost`)
traefik.http.routers.whoami.entrypoints: web

backend:
extends:
file: docker-compose.yml
Expand All @@ -15,23 +25,40 @@ services:
- run
- start:dev
labels:
- "traefik.http.routers.backend-grpc.rule=Host(`backend.localhost`)"
- "traefik.http.routers.backend-grpc.entrypoints=grpc"
- "traefik.http.routers.backend-grpc.service=svc_backend-grpc"
- "traefik.http.services.svc_backend-grpc.loadbalancer.server.port=5000"
- "traefik.http.services.svc_backend-grpc.loadbalancer.server.scheme=h2c"
traefik.http.routers.backend-grpc.rule: PathPrefix(`/backend`)
traefik.http.routers.backend-grpc.middlewares: backend-grpc-stripprefix
traefik.http.middlewares.backend-grpc-stripprefix.stripprefix.prefixes: /backend
traefik.http.routers.backend-grpc.entrypoints: grpc
traefik.http.routers.backend-grpc.service: svc_backend-grpc
traefik.http.services.svc_backend-grpc.loadbalancer.server.port: "50051"
traefik.http.services.svc_backend-grpc.loadbalancer.server.scheme: h2c

identity:
extends:
file: docker-compose.yml
service: identity
labels:
- "traefik.enable=true"
- "traefik.http.routers.identity-grpc.rule=Host(`identity.localhost`)"
- "traefik.http.routers.identity-grpc.entrypoints=grpc"
- "traefik.http.routers.identity-grpc.service=svc_identity-grpc"
- "traefik.http.services.svc_identity-grpc.loadbalancer.server.port=50051"
- "traefik.http.services.svc_identity-grpc.loadbalancer.server.scheme=h2c"
traefik.enable: true
traefik.http.routers.identity-grpc.rule: PathPrefix(`/identity`)
traefik.http.routers.identity-grpc.middlewares: identity-grpc-stripprefix
traefik.http.middlewares.identity-grpc-stripprefix.stripprefix.prefixes: /identity
traefik.http.routers.identity-grpc.entrypoints: grpc
traefik.http.routers.identity-grpc.service: svc_identity-grpc
traefik.http.services.svc_identity-grpc.loadbalancer.server.port: "50051"
traefik.http.services.svc_identity-grpc.loadbalancer.server.scheme: h2c

oid4vc-tanglelabs:
extends:
file: docker-compose.yml
service: oid4vc-tanglelabs
labels:
traefik.http.routers.oid4vc-tanglelabs-grpc.rule: PathPrefix(`/oid4vc-tanglelabs`)
traefik.http.routers.oid4vc-tanglelabs-grpc.middlewares: oid4vc-tanglelabs-grpc-stripprefix
traefik.http.middlewares.oid4vc-tanglelabs-grpc-stripprefix.stripprefix.prefixes: /oid4vc-tanglelabs
traefik.http.routers.oid4vc-tanglelabs-grpc.entrypoints: grpc
traefik.http.routers.oid4vc-tanglelabs-grpc.service: svc_oid4vc-tanglelabs-grpc
traefik.http.services.svc_oid4vc-tanglelabs-grpc.loadbalancer.server.port: "50051"
traefik.http.services.svc_oid4vc-tanglelabs-grpc.loadbalancer.server.scheme: h2c

grpcurl:
image: fullstorydev/grpcurl:latest
Expand Down
61 changes: 28 additions & 33 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,64 +14,59 @@ services:
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.grpc.address=:5000"
- "--log.level=DEBUG"
ports:
- "${HTTP_PORT}:80/tcp"
- "${GRPC_PORT}:5000/tcp"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./data/letsencrypt:/letsencrypt"

whoami:
# A container that exposes an API to show its IP address
image: traefik/whoami
expose:
- '80'
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
- "traefik.http.routers.whoami.entrypoints=web"

redis:
image: redis:latest
labels:
- "traefik.enable=false"
traefik.enable: false

backend:
build:
context: ./
dockerfile: ./backend/Dockerfile
expose:
- '3000'
- '5000'
- '50051'
# depends_on:
# - redis
# - identity
environment:
ISSUERS_BANK_DID: did:iota:snd:0x2cfb60f00089a91a96fa8fcee5e2bda15f51b0b062762ad9ca846bba536f8818
ISSUERS_BANK_FRAGMENT: S3zEW4inNy8FYZEMVTEthdzqqSBq1WglM2k75xKHzy0
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=Host(`backend.localhost`)"
- "traefik.http.routers.backend.entrypoints=web"
- "traefik.http.routers.backend.service=backend"
- "traefik.http.services.backend.loadbalancer.server.port=3000"
traefik.enable: true
traefik.http.routers.backend.rule: Host(`backend.localhost`)
traefik.http.routers.backend.entrypoints: web
traefik.http.routers.backend.service: backend
traefik.http.services.backend.loadbalancer.server.port: "3000"

oid4vc-tanglelabs:
build:
context: ./
dockerfile: ./oid4vc/TangleLabs/Dockerfile
environment:
RP_DID: did:iota:snd:0x2cfb60f00089a91a96fa8fcee5e2bda15f51b0b062762ad9ca846bba536f8818
SIGNER_KEYID: pK0JAYw5RFFKqorBn0x4w98zl2UBfRys
KEY_FRAGMENT: key-1
PUBLIC_URL: "192.168.0.234:8080"
expose:
- '3333'
- '50051'
volumes:
- ./proto:/usr/proto
labels:
- "traefik.enable=true"
- "traefik.http.routers.oid4vc-tanglelabs.rule=Host(`bank.localhost`)"
- "traefik.http.routers.oid4vc-tanglelabs.entrypoints=web"
- "traefik.http.routers.oid4vc-tanglelabs.service=oid4vc-tanglelabs"
- "traefik.http.services.oid4vc-tanglelabs.loadbalancer.server.port=3000"
traefik.enable: true
traefik.http.routers.oid4vc-tanglelabs.rule: Host(`bank.localhost`)
traefik.http.routers.oid4vc-tanglelabs.entrypoints: web
traefik.http.routers.oid4vc-tanglelabs.service: oid4vc-tanglelabs
traefik.http.services.oid4vc-tanglelabs.loadbalancer.server.port: "3333"

oid4vc-waltid:
build:
Expand All @@ -82,11 +77,11 @@ services:
volumes:
- ./proto:/usr/proto
labels:
- "traefik.enable=true"
- "traefik.http.routers.oid4vc-waltid.rule=Host(`government.localhost`)"
- "traefik.http.routers.oid4vc-waltid.entrypoints=web"
- "traefik.http.routers.oid4vc-waltid.service=oid4vc-waltid"
- "traefik.http.services.oid4vc-waltid.loadbalancer.server.port=3000"
traefik.enable: true
traefik.http.routers.oid4vc-waltid.rule: Host(`government.localhost`)
traefik.http.routers.oid4vc-waltid.entrypoints: web
traefik.http.routers.oid4vc-waltid.service: oid4vc-waltid
traefik.http.services.oid4vc-waltid.loadbalancer.server.port: "3000"

oid4vc-impierce:
image: impierce/ssi-agent
Expand All @@ -95,11 +90,11 @@ services:
volumes:
- ./proto:/usr/proto
labels:
- "traefik.enable=true"
- "traefik.http.routers.oid4vc-impierce.rule=Host(`insurance.localhost`)"
- "traefik.http.routers.oid4vc-impierce.entrypoints=web"
- "traefik.http.routers.oid4vc-impierce.service=oid4vc-impierce"
- "traefik.http.services.oid4vc-impierce.loadbalancer.server.port=3033"
traefik.enable: true
traefik.http.routers.oid4vc-impierce.rule: Host(`insurance.localhost`)
traefik.http.routers.oid4vc-impierce.entrypoints: web
traefik.http.routers.oid4vc-impierce.service: oid4vc-impierce
traefik.http.services.oid4vc-impierce.loadbalancer.server.port: "3033"
environment:
#AGENT_CONFIG_LOG_FORMAT: json
AGENT_CONFIG_EVENT_STORE: postgres
Expand Down Expand Up @@ -129,4 +124,4 @@ services:
expose:
- '50051'
labels:
- "traefik.enable=false"
traefik.enable: false
2 changes: 1 addition & 1 deletion oid4vc/TangleLabs/src/httpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const createServer = (rp) => {
);
app.route("/api/auth").post(
asyncHandler(async (req, res) => {
console.log(req);
console.debug(req);
await rp.verifyAuthResponse(req.body);
res.status(204).send();
})
Expand Down
14 changes: 7 additions & 7 deletions oid4vc/TangleLabs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import { createServer } from "./httpServer";
fromMultibase: Ed25519VerificationKey2020.from,
});

const verificationKeyPair = await Ed25519VerificationKey2020.generate();
// const verificationKeyPair = await Ed25519VerificationKey2020.generate();

console.log(bytesToString(verificationKeyPair._publicKeyBuffer));
console.log(bytesToString(verificationKeyPair._privateKeyBuffer));
// console.log(bytesToString(verificationKeyPair._publicKeyBuffer));
// console.log(bytesToString(verificationKeyPair._privateKeyBuffer));

const keyDidResolver = KeyDIDResolver.getResolver();
let resolver = new Resolver(keyDidResolver);

const rp = new RelyingParty({
clientId: "did:iota:0x",
clientId: process.env.RP_DID,
clientMetadata: {
subjectSyntaxTypesSupported: [
"did:iota"
Expand All @@ -43,10 +43,10 @@ import { createServer } from "./httpServer";
SigningAlgs.EdDSA
],
},
did: "did:iota:0x",
kid: "did:iota:0x#my_key",
did: process.env.RP_DID,
kid: `${process.env.SIGNER_KEYID}#${process.env.KEY_FRAGMENT}`,
signer: remoteSigner(process.env.SIGNER_KEYID),
redirectUri: "http://192.168.0.234:8080/api/auth",
redirectUri: `http://${process.env.PUBLIC_URL}/api/auth`,
resolver: resolver,
});

Expand Down
8 changes: 5 additions & 3 deletions oid4vc/TangleLabs/src/remoteSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ export const remoteSigner: (keyId: string) => Signer = (keyId) => async (data) =

const response = await new Promise((resolve, reject) => identityClient.sign({
keyId,
data: Array.from(Buffer.from(data)),
data: Uint8Array.from(Buffer.from(data)),
}, (err, response) => {
if (err) {
console.error(err);
reject(err);
}
resolve(response);
}));
console.log(response)
return response as string;
return (response as {
signature: Buffer
}).signature.toString('base64');

};
60 changes: 60 additions & 0 deletions tooling/Selv.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"info": {
"_postman_id": "31612dd5-1b94-47b6-8180-ee256374ab94",
"name": "Selv",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "10688"
},
"item": [
{
"name": "OID4VC",
"item": [
{
"name": "TangleLabs",
"item": [
{
"name": "Health",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "bank.localhost:81/api/health",
"host": [
"bank",
"localhost"
],
"port": "81",
"path": [
"api",
"health"
]
}
},
"response": []
},
{
"name": "Auth",
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "bank.localhost:81/api/auth",
"host": [
"bank",
"localhost"
],
"port": "81",
"path": [
"api",
"auth"
]
}
},
"response": []
}
]
}
]
}
]
}
2 changes: 1 addition & 1 deletion web/src/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"websocketURL": "http://backend.localhost/",
"websocketURL": "http://backend.localhost:81/",
"serverAPI": "https://selv01.iota.cafe",
"provider": "https://nodes.devnet.iota.org:443",
"keyId": "selv",
Expand Down

0 comments on commit 4ee5904

Please sign in to comment.