dmartincy commited on
Commit
bd58e89
·
1 Parent(s): be94e06

Add DocAuth license key

Browse files
Files changed (3) hide show
  1. Dockerfile +3 -1
  2. document-authoring.js +8 -1
  3. nginx.conf +5 -0
Dockerfile CHANGED
@@ -65,8 +65,10 @@ COPY --from=pspdfkit/ai-assistant:nightly /base $HOME/app/aia
65
  COPY --chown=node:node service-config.yml /service-config.yml
66
  RUN chown -R user:user $HOME/app/aia
67
 
68
- # Copy nginx configuration
69
  COPY nginx.conf /etc/nginx/nginx.conf
 
 
70
 
71
  # Copy web files
72
  COPY --chown=user:user index.html $HOME/app/docauth/
 
65
  COPY --chown=node:node service-config.yml /service-config.yml
66
  RUN chown -R user:user $HOME/app/aia
67
 
68
+ # Copy nginx configuration and replace license key
69
  COPY nginx.conf /etc/nginx/nginx.conf
70
+ RUN --mount=type=secret,id=DOCAUTH_LICENSE_KEY,mode=0444,required=true \
71
+ sed -i "s/\$DOCAUTH_LICENSE_KEY/$(cat /run/secrets/DOCAUTH_LICENSE_KEY)/g" /etc/nginx/nginx.conf
72
 
73
  # Copy web files
74
  COPY --chown=user:user index.html $HOME/app/docauth/
document-authoring.js CHANGED
@@ -68,7 +68,14 @@ script.crossOrigin = true;
68
  document.head.appendChild(script);
69
 
70
  script.onload = async () => {
71
- const docAuthSystem = await DocAuth.createDocAuthSystem({});
 
 
 
 
 
 
 
72
 
73
  const editor = await docAuthSystem.createEditor(
74
  document.getElementById("editor"),
 
68
  document.head.appendChild(script);
69
 
70
  script.onload = async () => {
71
+ // Fetch license key from nginx endpoint.
72
+ const licenseKeyResponse = await fetch('/api/license-key');
73
+ if (!licenseKeyResponse.ok) {
74
+ throw new Error('Failed to fetch license key');
75
+ }
76
+ const { licenseKey } = await licenseKeyResponse.json();
77
+
78
+ const docAuthSystem = await DocAuth.createDocAuthSystem({licenseKey});
79
 
80
  const editor = await docAuthSystem.createEditor(
81
  document.getElementById("editor"),
nginx.conf CHANGED
@@ -26,5 +26,10 @@ http {
26
  location /v1 {
27
  proxy_pass http://127.0.0.1:8082;
28
  }
 
 
 
 
 
29
  }
30
  }
 
26
  location /v1 {
27
  proxy_pass http://127.0.0.1:8082;
28
  }
29
+
30
+ location /api/license-key {
31
+ default_type application/json;
32
+ return 200 '{"licenseKey": "$DOCAUTH_LICENSE_KEY"}';
33
+ }
34
  }
35
  }