diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index d87aec8..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,27 +0,0 @@ -image: privacybydesign/node_yarn_python3:latest - -stages: - - build - -before_script: - - set -euxo pipefail - - git clone https://github.com/privacybydesign/pbdf-schememanager.git - - git clone https://github.com/privacybydesign/irma-demo-schememanager.git - - yarn install --frozen-lockfile - -build: - stage: build - artifacts: - # Disabling artifact expiry is not supported yet, so make - expire_in: 100 year - paths: - - nl/ - - en/ - - pbdf-schememanager/ - - irma-demo-schememanager/ - - script.js - - style.css - - index.json - script: - - yarn run build - - python3 update.py diff --git a/Dockerfile b/Dockerfile index ac94edd..3141a39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,45 @@ -FROM python:3.9-slim +# --- Stage 1 Node build +FROM node:18-slim AS node-build -WORKDIR / +WORKDIR /app -RUN apt-get update && \ - apt-get install -y curl apache2 && \ - curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ - apt-get install -y nodejs && \ - npm install -g yarn && \ - pip install Jinja2 && \ - pip install requests +COPY src ./ +COPY webpack.config.js yarn.lock package.json ./ -ENV NODE_OPTIONS=--openssl-legacy-provider +RUN yarn install --frozen-lockfile +ENV NODE_OPTIONS="--openssl-legacy-provider" COPY . . -RUN python3 download_repos.py && \ - python3 -u update.py && \ - test -f index.json && \ - yarn && yarn build && \ - mkdir -p /var/www/html && \ - cp -r /en /var/www/html/ && \ - cp -r /nl /var/www/html/ && \ - cp -r /repos /var/www/html/ && \ - cp style.css /var/www/html/ && \ - cp logo.svg /var/www/html/ && \ - cp script.js /var/www/html/ && \ - cp index.json /var/www/html/ +RUN yarn build + +# --- Stage 2 Python build +FROM python:3.9-slim AS python-build + +WORKDIR /app +COPY --from=node-build /app ./ + +COPY download_repos.py generate-index.py config.json ./ +RUN ls -l /app + +RUN pip install --no-cache-dir Jinja2 requests && \ + python3 download_repos.py && \ + python3 -u generate-index.py + +# --- Stage 3: Final nginx stage +FROM nginx:stable + +COPY nginx.conf /etc/nginx/conf.d/default.conf + +COPY --from=python-build /app/en/ /var/www/html/en/ +COPY --from=python-build /app/nl/ /var/www/html/nl/ +COPY --from=python-build /app/repos/ /var/www/html/repos/ +COPY --from=python-build /app/index.json /var/www/html/ +COPY --from=node-build /app/script.js /var/www/html/ +COPY style.css logo.svg /var/www/html/ + +RUN chown -R nginx:nginx /var/www/html && \ + chmod -R 755 /var/www/html EXPOSE 80 -CMD ["apache2ctl", "-D", "FOREGROUND"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/README.markdown b/README.markdown index 9249cbf..e7a3faa 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ # Attribute index -Generate documentation for the IRMA scheme manager. You can browse a live +Generate documentation for the Yivi scheme manager. You can browse a live version [over here](https://privacybydesign.foundation/attribute-index/en/). ## Installing @@ -12,17 +12,15 @@ Dependencies: * [Jinja2](http://jinja.pocoo.org/) (Debian package: `python3-jinja2`) * yarn -Before generating content, download the scheme managers by running `download_repos.py`. -To add a scheme, configure the schemes config in `config.json`. ## Running -To generate the HTML for the attribute index, run the script: +Before you run the script to generate Yivi index pages run the `download_repos.py` script. This downloalds +most recent version of the schemes. If new schemes are added, you can modify the `config.json` file to add them. - python3 update.py + python3 download_repos.py + python3 generate-index.py -If you want to have an up-to-date attribute index, it is recommended to update -the scheme managers regularly and run the update script afterwards. To generate the JavaScript handling issuance sessions of demo credentials, run: @@ -31,12 +29,9 @@ To generate the JavaScript handling issuance sessions of demo credentials, run: ## Running with Docker -To build and run the Docker container, build and run the docker image via the following: +To build and run the Docker container, you can use docker compose: - docker build -t attribute-index . - docker run -p 80:80 attribute-index - -## Using untrusted scheme managers + docker compose up Currently, scheme managers are considered trusted. Generating an attribute index for an untrusted scheme manager has at least the following problems at the diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..944a863 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: '3.8' + +services: + attribute-index: + build: + context: . + dockerfile: Dockerfile + ports: + - "80:80" + environment: + - NODE_OPTIONS=--openssl-legacy-provider + restart: unless-stopped diff --git a/update.py b/generate-index.py similarity index 100% rename from update.py rename to generate-index.py diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..92911a2 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name _; + root /var/www/html; + index index.html; + charset utf-8; + + location / { + if ($uri = /) { + return 301 /en; + } + try_files $uri $uri/ =404; + add_header Content-Type "text/html; charset=utf-8"; + } + location ~* \.(css|js|svg|png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot)$ { + root /var/www/html; + try_files $uri =404; + access_log off; + expires max; + add_header Cache-Control "public"; + } +} \ No newline at end of file diff --git a/templates/credential-navigator.html b/templates/credential-navigator.html index a457ccf..ebe2d29 100644 --- a/templates/credential-navigator.html +++ b/templates/credential-navigator.html @@ -35,27 +35,13 @@

Issuing Demo Credentials

- - {% if organized_data %} - {% for issuer in organized_data[0].issuers %} - - {% endfor %} - {% endif %}
- - {% if organized_data and organized_data[0].issuers %} - {% for credential in organized_data[0].issuers[0].credentials %} - - {% endfor %} - {% endif %}
@@ -65,29 +51,46 @@

Issuing Demo Credentials

function updateIssuers(schemeId) { const issuerSelect = document.getElementById('issuer'); - const scheme = organizedData.find(s => s.identifier === schemeId); - + const credentialSelect = document.getElementById('credential'); + issuerSelect.innerHTML = ''; - if (scheme) { - scheme.issuers.forEach(issuer => { - const option = new Option(issuer.name[{{LANG|tojson|safe}}], issuer.identifier); - issuerSelect.add(option); - }); + credentialSelect.innerHTML = ''; + credentialSelect.disabled = true; + + if (schemeId) { + const scheme = organizedData.find(s => s.identifier === schemeId); + if (scheme) { + scheme.issuers.forEach(issuer => { + const option = new Option(issuer.name[{{LANG|tojson|safe}}], issuer.identifier); + issuerSelect.add(option); + }); + issuerSelect.disabled = false; + } else { + issuerSelect.disabled = true; + } + } else { + issuerSelect.disabled = true; } - updateCredentials('', ''); } function updateCredentials(schemeId, issuerId) { const credentialSelect = document.getElementById('credential'); - const scheme = organizedData.find(s => s.identifier === schemeId); - const issuer = scheme?.issuers.find(i => i.identifier === issuerId); - + credentialSelect.innerHTML = ''; - if (issuer) { - issuer.credentials.forEach(cred => { - const option = new Option(cred.name[{{LANG|tojson|safe}}], cred.identifier); - credentialSelect.add(option); - }); + if (schemeId && issuerId) { + const scheme = organizedData.find(s => s.identifier === schemeId); + const issuer = scheme?.issuers.find(i => i.identifier === issuerId); + if (issuer) { + issuer.credentials.forEach(cred => { + const option = new Option(cred.name[{{LANG|tojson|safe}}], cred.identifier); + credentialSelect.add(option); + }); + credentialSelect.disabled = false; + } else { + credentialSelect.disabled = true; + } + } else { + credentialSelect.disabled = true; } } @@ -107,4 +110,4 @@

Issuing Demo Credentials

}); -{% endblock main %} \ No newline at end of file +{% endblock main %}