From 325edaecef7ad0a8d0fdf6bff4e78d97b2751500 Mon Sep 17 00:00:00 2001 From: Michael J Feher Date: Mon, 22 Apr 2024 11:33:45 -0400 Subject: [PATCH] build: add ngrok to docker - fixes #11 - fixes #12 --- .env.docker | 4 +-- .gitignore | 1 + CONTRIBUTING.md | 29 +++++++++++++------ README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++ Vite.Dockerfile | 12 ++++++++ docker-compose.yml | 26 +++++++++++++++++ ngrok.template.yml | 7 +++++ 7 files changed, 139 insertions(+), 11 deletions(-) create mode 100644 Vite.Dockerfile create mode 100644 ngrok.template.yml diff --git a/.env.docker b/.env.docker index 3b96aaa..f19032b 100644 --- a/.env.docker +++ b/.env.docker @@ -17,8 +17,8 @@ REDIS_PASSWORD= # FIDO2 RP_NAME=Algorand Foundation FIDO2 Server -HOSTNAME=fido-home.telluric.guru -ORIGIN=https://fido-home.telluric.guru +HOSTNAME=catfish-pro-wolf.ngrok-free.app +ORIGIN=https://catfish-pro-wolf.ngrok-free.app ANDROID_SHA256HASH=47:CC:4E:EE:B9:50:59:A5:8B:E0:19:45:CA:0A:6D:59:16:F9:A9:C2:96:75:F8:F3:64:86:92:46:2B:7D:5D:5C ANDROID_PACKAGENAME=foundation.algorand.demo diff --git a/.gitignore b/.gitignore index 7a37398..08b11ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ swagger-codegen-cli.jar +ngrok.yml .data .idea diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5f8097..b5dd77e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,15 +34,31 @@ WebAuthn requires a secure context (HTTPS) to work and this will not allow you t Sign up for a free account at [ngrok](https://ngrok.com/) and install the ngrok package. Configure a Static Domain for your ngrok account and update the [.env](services/liquid-auth-api-js/README.md) file with the following keys with the values from ngrok: + +#### Configure NGROK + ```bash -HOSTNAME=example-static-domain.ngrok-free.app -ORIGIN=https://example-static-domain.ngrok-free.app +cp ./ngrok.template.yml ngrok.yml ``` -#### Run the ngrok proxy +Make sure to update the `authtoken` and `domain` in the `ngrok.yml` file with your ngrok details. + +```yaml +version: 2 +authtoken: +tunnels: + website: + addr: 5173 + proto: http + domain: + +``` + +#### Update the Service's .docker.env file ```bash -ngrok http --domain=example-static-domain.ngrok-free.app 5173 +HOSTNAME=example-static-domain.ngrok-free.app +ORIGIN=https://example-static-domain.ngrok-free.app ``` #### Start services @@ -53,10 +69,5 @@ Run the following command to start the backend: docker-compose up -d ``` -#### Run the Demo App -```bash -npm run dev:ui -``` - Navigate to the ngrok URL in your browser to test the FIDO2 feature. diff --git a/README.md b/README.md index 2abd806..3518299 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,77 @@ This project holds the standard FIDO2 api endpoints and the Proof of Knowledge f The api is a stateful session-based architecture with endpoint guards. A user must prove ownership of a private key to associate PublicKeyCredentials + + +## Getting started + +### Prerequisites +- Node.js 20 +- Docker + +#### Clone the project + +```bash +git clone git@github.com:algorandfoundation/liquid-auth.git && cd liquid-auth +``` + +#### Install package dependencies + +```bash +npm install +``` + +#### Build Dependencies + +```bash +npm run build +``` + +WebAuthn requires a secure context (HTTPS) to work and this will not allow you to test the FIDO2 feature in your local machine. + +### NGROK + +Sign up for a free account at [ngrok](https://ngrok.com/) and install the ngrok package. +Configure a Static Domain for your ngrok account and update the [.env](services/liquid-auth-api-js/README.md) file with the following keys with the values from ngrok: + + +#### Configure NGROK + +```bash +cp ./ngrok.template.yml ngrok.yml +``` + +Make sure to update the `authtoken` and `domain` in the `ngrok.yml` file with your ngrok details. + +```yaml +version: 2 +authtoken: +tunnels: + website: + addr: 5173 + proto: http + domain: + +``` + +#### Update the Service's .docker.env file + +```bash +HOSTNAME=example-static-domain.ngrok-free.app +ORIGIN=https://example-static-domain.ngrok-free.app +``` + +#### Start services + +Run the following command to start the backend: + +```bash +docker-compose up -d +``` + +Navigate to the ngrok URL in your browser to test the FIDO2 feature. + + ## Using the app #### Install the [Android client]() to your device and navigate to https://nest-fido2.onrender.com/. diff --git a/Vite.Dockerfile b/Vite.Dockerfile new file mode 100644 index 0000000..1a8abe6 --- /dev/null +++ b/Vite.Dockerfile @@ -0,0 +1,12 @@ +FROM node:20-alpine + +ADD . . + +RUN npm install + +RUN npm run build + + +EXPOSE 5173 + +CMD ["npm", "run", "dev:ui"] diff --git a/docker-compose.yml b/docker-compose.yml index 55ed975..26f86e7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,32 @@ services: depends_on: - redis - mongo + - ngrok + liquid-demo: + build: + context: . + dockerfile: Vite.Dockerfile + ports: + - "5173:5173" + restart: always + environment: + - PROXY_URL=http://liquid-auth:3000 + - WSS_PROXY_SERVER=ws://liquid-auth:3000 + depends_on: + - liquid-auth + - ngrok + ngrok: + image: ngrok/ngrok:latest + restart: unless-stopped + command: + - "start" + - "--all" + - "--config" + - "/etc/ngrok.yml" + volumes: + - ./ngrok.yml:/etc/ngrok.yml + ports: + - 4040:4040 redis: image: redis restart: always diff --git a/ngrok.template.yml b/ngrok.template.yml new file mode 100644 index 0000000..6e09789 --- /dev/null +++ b/ngrok.template.yml @@ -0,0 +1,7 @@ +version: 2 +authtoken: +tunnels: + website: + addr: liquid-demo:5173 + proto: https + domain: