Skip to content

Commit

Permalink
chore: Docker compose fixes. Move config to sub dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jun 27, 2023
1 parent a8fb6c0 commit 771b94f
Show file tree
Hide file tree
Showing 48 changed files with 237 additions and 22 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ demo. https://ssi.dutchblockchaincoalition.org/demo/issuer hosts a different int

You should be greeted with the introduction screen

<img src="resources/issuer-demo-intro.png" width="500">
<img src="resources/issuer-demo-intro.png" width="500"/>

There are 2 flows. One is a manual flow, where you will fill out some information (the information will not be
shared/stored) in order to receive a credential. The other flow is using your wallet to request the information
Expand Down Expand Up @@ -167,7 +167,11 @@ docker-compose up

The build phase might take a few minutes. If you run the docker-compose up command 3 services will be running. The ssi-agent, oid4vci-demo-frontend and oid4vp-frontend.

You should now be able to go to http://localhost:5001 and http://localhost:5002 respectively to test the issuer and verifier demo's.
You should now be able to go to http://host.docker.internal:5001 and http://host.docker.internal:5002 respectively to test the issuer and verifier demo's.

Please note that you might have to configure your docker environment to expose the host.docker.internal like the image below. If you cannot make that work you could adjust the config/docker and docker/*.env files to suit your needs

<img src="resources/docker_settings.png" width="500" />

#### Environment variables and configuration for docker.
Please note that the environment variables for the 3 images come from the ./docker folder. You will have to copy the 3 example files and remove the .example suffix.
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version: '3.8'
services:
ssi-agent:
container_name: ssi-agent
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- ./docker/.env.ssi-agent
tty: true
Expand All @@ -13,6 +15,8 @@ services:
- "5000:5000"
oid4vci-demo-frontend:
container_name: oid4vci-demo-frontend
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- ./docker/.env.oid4vci-demo-frontend
depends_on:
Expand All @@ -25,6 +29,8 @@ services:
- "5001:5001"
oid4vp-demo-frontend:
container_name: oid4vp-demo-frontend
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- ./docker/.env.oid4vp-demo-frontend
depends_on:
Expand Down
6 changes: 3 additions & 3 deletions docker/.env.oid4vci-demo-frontend
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REACT_APP_OID4VP_AGENT_BASE_URL=http://ssi-agent:5000
REACT_APP_OID4VP_PRESENTATION_DEF_ID=sphereon
REACT_APP_OID4VCI_AGENT_BASE_URL='http://ssi-agent:5000/sphereon2023'
REACT_APP_OID4VP_AGENT_BASE_URL=http://192.168.2.90:5000
REACT_APP_OID4VP_PRESENTATION_DEF_ID=sphereon2023
REACT_APP_OID4VCI_AGENT_BASE_URL='http://192.168.2.90:5000/sphereon2023'
REACT_APP_ENVIRONMENT=sphereon
PORT=5001
2 changes: 1 addition & 1 deletion docker/.env.oid4vp-demo-frontend
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ NODE_ENV=development
PORT=5002
REACT_APP_QR_CODE_EXPIRES_AFTER_SEC=300
REACT_APP_PRESENTATION_DEF_ID=sphereon2023
REACT_APP_BACKEND_BASE_URI=http://ssi-agent:5000
REACT_APP_BACKEND_BASE_URI=http://192.168.2.90:5000
8 changes: 4 additions & 4 deletions docker/.env.ssi-agent
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ HOSTNAME=0.0.0.0
PORT=5000
COOKIE_SIGNING_KEY=8E5er6YyAO6dIrDTm7BXYWsafBSLxzjb
DB_CONNECTION_NAME=default
DB_SQLITE_FILE="database/agent_default.sqlite"
DB_SQLITE_FILE="database/agent_docker.sqlite"
DB_ENCRYPTION_KEY=29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c
OID4VP_ENABLED="true"
OID4VP_WEBAPP_BASE_URI=http://oid4vp-demo-frontend:5000
OID4VP_AGENT_BASE_URI=http://oid4vp-demo-frontend:5000
OID4VP_WEBAPP_BASE_URI=http://192.168.2.90:5000
OID4VP_AGENT_BASE_URI=http://192.168.2.90:5000
AUTH_REQUEST_EXPIRES_AFTER_SEC=180
CONF_PATH="./conf"
CONF_PATH="./conf/docker"
UNIVERSAL_RESOLVER_RESOLVE_URL="https://dev.uniresolver.io/1.0/identifiers"
4 changes: 1 addition & 3 deletions docker/Dockerfile.ssi-agent
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ WORKDIR /opt/ssi-agent
COPY ./ .
RUN pnpm install -r
RUN pnpm build
RUN cd /opt/ssi-agent/packages/agent
RUN ls -al

WORKDIR /opt/ssi-agent/packages/agent
ENTRYPOINT ["pnpm", "start:prod"]
ENTRYPOINT ["pnpm", "start:dev"]
3 changes: 1 addition & 2 deletions packages/agent/.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ OID4VP_WEBAPP_BASE_URI=http://192.168.2.90:5000
OID4VP_AGENT_BASE_URI=http://192.168.2.90:5000
AUTH_REQUEST_EXPIRES_AFTER_SEC=180
OID4VCI_ENABLED="true"

CONF_PATH="./conf"
CONF_PATH="./conf/dev"
UNIVERSAL_RESOLVER_RESOLVE_URL="https://dev.uniresolver.io/1.0/identifiers"
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions packages/agent/conf/examples/dids/jwk-es256.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"privateKeyHex": "f4446e5eb1201a7769cb35f02f24b06c0ac3ff49eb085f8562f06fc6c42e68cd",
"did": "did:jwk:eyJhbGciOiJFUzI1NiIsInVzZSI6InNpZyIsImt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiVEcySDJ4MmRXWE4zdUNxWnBxRjF5c0FQUVZESkVOX0gtQ010YmdqYi1OZyIsInkiOiI5TThOeGQwUE4yMk05bFBEeGRwRHBvVEx6MTV3ZnlaSnM2WmhLSVVKMzM4In0",
"createArgs": {
"provider": "did:jwk",
"options": {
"kid": "03f9478ffb86fb6142795d4da9b2653c55d7d6bdb3e82a551e1f0bd022b7bf9768",
"type": "Secp256r1",
"keyType": "Secp256r1"
}
}
}
File renamed without changes.
148 changes: 148 additions & 0 deletions packages/agent/conf/examples/oid4vci_metadata/sphereon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"correlationId": "http://192.168.2.90:5000/sphereon2023",
"overwriteExisting": true,
"metadata": {
"credential_issuer": "http://192.168.2.90:5000/sphereon2023",
"credential_endpoint": "http://192.168.2.90:5000/sphereon2023/credentials",
"display": [
{
"name": "Sphereon International",
"description": "Sphereon International"
}
],
"credentials_supported": [
{
"display": [
{
"name": "Sphereon guest",
"description": "Sphereon guest credential for demo purposes.",
"text_color": "#FFFFFF",
"background_image": {
"url": "https://i.ibb.co/kmfrH4F/tulips.png",
"alt_text": "Black and white photo of tulips with one red tulip"
},
"logo": {
"url": "https://i.ibb.co/NWQQ9kt/sphereon-logo.png",
"alt_text": "Red square depicting Sphereon logo."
}
},
{
"locale": "en-US",
"name": "Sphereon guest",
"description": "Sphereon guest credential for demo purposes.",
"text_color": "#FFFFFF",
"background_image": {
"url": "https://i.ibb.co/kmfrH4F/tulips.png",
"alt_text": "Black and white photo of tulips with one red tulip"
},
"logo": {
"url": "https://i.ibb.co/NWQQ9kt/sphereon-logo.png",
"alt_text": "Red square depicting Sphereon logo."
}
},
{
"locale": "nl-NL",
"name": "Sphereon gast",
"description": "Sphereon gast credential wordt uitgegeven voor demo doeleinden.",
"text_color": "#FFFFFF",
"background_image": {
"url": "https://i.ibb.co/kmfrH4F/tulips.png",
"alt_text": "Black and white photo of tulips with one red tulip"
},
"logo": {
"url": "https://i.ibb.co/NWQQ9kt/sphereon-logo.png",
"alt_text": "Red square depicting Sphereon logo."
}
}
],
"order": [
"firstName",
"lastName",
"email",
"type"
],
"credentialSubject": {
"firstName": {
"value_type": "string",
"display": [
{
"name": "FirstName"
},
{
"name": "FirstName",
"locale": "en-US"
},
{
"name": "Voornaam",
"locale": "nl-NL"
}
]
},
"lastName": {
"value_type": "string",
"display": [
{
"name": "LastName"
},
{
"name": "LastName",
"locale": "en-US"
},
{
"name": "Achternaam",
"locale": "nl-NL"
}
]
},
"email": {
"value_type": "string",
"display": [
{
"name": "Email"
},
{
"name": "Email",
"locale": "en-US"
},
{
"name": "Email",
"locale": "nl-NL"
}
]
},
"type": {
"value_type": "string",
"display": [
{
"name": "Type"
},
{
"name": "Type",
"locale": "en-US"
},
{
"name": "Type",
"locale": "nl-NL"
}
]
}
},
"id": "sphereon2023",
"types": [
"VerifiableCredential",
"GuestCredential"
],
"format": "jwt_vc_json",
"cryptographic_binding_methods_supported": [
"did:web",
"did:jwk"
],
"cryptographic_suites_supported": [
"ES256",
"ES256K",
"EdDSA"
]
}
]
}
}
9 changes: 9 additions & 0 deletions packages/agent/conf/examples/oid4vci_options/sphereon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"definitionId": "sphereon2023",
"correlationId": "http://192.168.2.90:5000/sphereon2023",
"issuerOpts": {
"didOpts": {
"checkLinkedDomains": "if_present"
}
}
}
8 changes: 8 additions & 0 deletions packages/agent/conf/examples/oid4vp_options/sphereon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"definitionId": "sphereon2023",
"rpOpts": {
"didOpts": {
"checkLinkedDomains": "if_present"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "sphereon2023",
"purpose": "For this portal we need your e-mail address and name from a Sphereon guest credential",
"input_descriptors": [
{
"id": "4ce7aff1-0234-4f35-9d21-251668a60950",
"name": "Sphereon Guest",
"purpose": "You need to provide a Guest Credential.",
"schema": [
{
"uri": "GuestCredential"
}
],
"constraints": {
"fields": [
{
"path": [
"$.credentialSubject.type",
"$.vc.credentialSubject.type"
],
"filter": {
"type": "string",
"pattern": "Sphereon Guest"
}
}
]
}
}
]
}
2 changes: 1 addition & 1 deletion packages/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const agent = createAgent<TAgentTypes>({
export default agent

export const context: IAgentContext<TAgentTypes> = {agent}
await getOrCreateDIDs().catch(e => console.log(e))

const defaultDID = await getDefaultDID()
console.log(`[DID] default DID: ${defaultDID}`)
Expand All @@ -148,7 +149,6 @@ if (!defaultDID || !defaultKid || !(await getIdentifier(defaultDID))) {
console.log('TODO create identifier and write config')
// create Identifier
}
await getOrCreateDIDs().catch(e => console.log(e))
const oid4vpOpts = await getDefaultOID4VPRPOptions({did: defaultDID})
if (oid4vpOpts && oid4vpRP) {
oid4vpRP.setDefaultOpts(oid4vpOpts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ export default class AuthenticationQR extends Component<AuthenticationQRProps> {
return
}

if (!this.timedOutRequestMappings.has({authRequestURIResponse, qrCode})) {
/*if (!this.timedOutRequestMappings.has({authRequestURIResponse, qrCode})) {
this.timedOutRequestMappings.add({authRequestURIResponse, qrCode})
}
}*/
this.setState({qrCode, authRequestURIResponse})
/* this.state.qrCode = qrCode
this.state.authRequestURIResponse = authRequestURIResponse
Expand All @@ -140,15 +140,16 @@ export default class AuthenticationQR extends Component<AuthenticationQRProps> {
} else if (!authStatus) {
return
} else if (this.timedOutRequestMappings.has(this.state)) {
const timedoutState = this.state
try {
console.log("Cancelling timed out auth request.")
if (this.state?.authRequestURIResponse) {
if (timedoutState?.authRequestURIResponse) {
await agent.siopClientRemoveAuthRequestSession({
correlationId: this.state.authRequestURIResponse.correlationId,
definitionId: this.state.authRequestURIResponse.definitionId
correlationId: timedoutState.authRequestURIResponse.correlationId,
definitionId: timedoutState.authRequestURIResponse.definitionId
})
this.timedOutRequestMappings.delete(timedoutState) // only delete after deleted remotely
}
this.timedOutRequestMappings.delete(this.state) // only delete after deleted remotely
clearInterval(interval)
} catch (error) {
console.log(error)
Expand Down
Binary file added resources/docker_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 771b94f

Please sign in to comment.