Skip to content

Serving the portal

The platform portal is a static build. A core exposes it under a reserved platform name with a hosted site (hostedSites in the core’s configuration, see the open-pryv.io INSTALL.md, section “Hosted sites”): either a proxy: to the build published on GitHub Pages, or a static: folder holding an unpacked release. The install wizard writes the entry on new installs (bin/init.js, answer key portal.mode: pages, the default, static or none).

Versions. portal.site, portal.cors.allowedOrigins and the install wizard’s portal entry come with open-pryv.io 2.0.0-rc.91; portal.url, GET /system/portal/settings, portal in the service information and the one-build-per-version layout with 2.0.0-rc.92.

Topology Address of the portal API root the portal calls
without DNS (dnsLess, single core) <publicUrl>/<site>/, for example https://core.example.com/admin/ <publicUrl>/, the same origin
DNS https://<site>.<domain>/, for example https://admin.pryv.example.com/ https://reg.<domain>/
outside the platform anywhere (portal.url) platform.apiRoot in the portal’s settings.json

On the DNS topology, platform.apiRoot is a core’s URL, for example https://core-1.pryv.example.com/ (the core’s publicUrl), never https://reg.<domain>/. A core answers /system/* on its own host only: on reg.<domain> the path is read as a registration route (/reg/system/...), answers 404, and the portal says “The platform cannot be reached”. As of open-pryv.io 2.0.0-rc.98 and portal 0.5.0 this also holds for the API root the portal derives at https://<site>.<domain>/ (the DNS row above): until a release lifts it, a DNS-topology platform serves the portal with static: and its own settings.json naming a core, or hosts it outside the platform with portal.url.

One build serves every address. Asset URLs are relative, and each route is published as a folder page, so the same files work at a host’s root, under /admin/, under any other site name, or in any folder of a static host: there is no build per base path. Routes carry no path parameters; what a page is about (an account, a client, a core) is in the URL fragment, which a browser never sends: names and record ids stay out of the access logs of the core, a proxy or a static host, and out of Referer.

hostedSites:
admin:
proxy: https://pryv.github.io/app-web-platform-portal/<version>/
forwardQuery: false
headers:
content-security-policy: "default-src 'self'; connect-src 'self' https://*.<domain>; object-src 'none'; base-uri 'self'; form-action 'self'"
portal:
site: admin
auth:
trustedApps: "<your existing entries>, pryv-platform-portal@https://admin.<domain>"
  • portal.site names the hosted site that is the portal; the core derives its address from the topology. portal.url (from 2.0.0-rc.92) is the address of a portal hosted outside the platform instead; never both. Either one makes the core publish portal: { contract, url } in its service information and accept the portal’s origin on /system (the origin rule); portal.cors.allowedOrigins adds other origins.
  • auth.trustedApps must accept pryv-platform-portal from the portal’s origin (https://admin.<domain> with DNS, the <publicUrl> origin in dnsLess), or the portal’s sign-in is refused. The wizard adds it with the portal.site entry; with portal.url, add it yourself.
  • forwardQuery (from open-pryv.io 2.0.0-rc.96, on a proxy: site, default true): false sends the upstream the path alone, so the page’s query (a portal section, list filters, a searched name) stays out of the upstream’s logs (GitHub Pages here). The install wizard of 2.0.0-rc.96 writes forwardQuery: false for the portal proxied from GitHub Pages; an existing install adds the line to its portal’s hostedSites entry by hand, on every core, once they run 2.0.0-rc.96 or later (leave it out on an earlier core). Request headers sent upstream are still the allow-list (no Referer, no cookie, no Authorization).
  • The site name becomes a reserved username on every core: on an existing platform, check that no account holds it before adding the entry (the core refuses to boot otherwise).

Content Security Policy. The build runs under exactly this policy, which the core adds on the hosted site (dnsLess: connect-src 'self' only):

default-src 'self'; connect-src 'self' https://*.<domain>; object-src 'none'; base-uri 'self'; form-action 'self'

No inline script or style, no data: URL, nothing from another host: the portal’s own build fails when a page needs more. Fonts and images are files of the build.

dnsLess shares one origin. Without DNS, every hosted site is served on the API’s origin, and the portal keeps the administrator session in that origin’s sessionStorage: a page of another hosted site can read it. Host there only sites you would trust with an administrator session, or use the DNS topology, where each site has its own origin. bin/check-config.js warns about it, and about portal.url or an allowed origin on plain http: other than a loopback address.

The portal’s own settings.json, next to the build, holds defaults only: platform.apiRoot (where the API is: unset, derived from the portal’s own address; set it for a portal hosted outside the platform; on the DNS topology, to a core’s URL, see above), session.idleMinutes (1 to 60, default 15), theme.default (light, dark or system). What a platform shows is decided on the core (portal settings), never there.

The portal repository publishes each version on GitHub Pages, under https://pryv.github.io/app-web-platform-portal/:

Path What
<x.y.z>/ the build of version x.y.z, immutable: a publish that would change or remove a file there is refused
c<contract>/ the latest build of each portal contract, moved at every publish

Only the repository’s CI publishes, from a tag, after its checks; each release also attaches a reproducible tarball app-web-platform-portal-<x.y.z>.tgz, its .sha256 and a build provenance attestation.

Each core release pins one portal version: the proxy: address the wizard writes names the version published for that release (PORTAL_VERSION in the core’s sources, bumped before each core tag; check the hostedSites entry of your configuration, and the portal’s change log for what each version brings). Point at a fixed <x.y.z>/, never at c<contract>/, so that a portal publish never changes what your cores serve.

Upgrade by changing the version in the proxy: address (or unpacking the new release for static:), on every core, then restart. The portal refuses to start on a core whose contract it does not know: pick a version for your core’s contract.

Installed with 2.0.0-rc.91 to 2.0.0-rc.93? The wizard of those releases wrote .../app-web-platform-portal/0.1.0/, a version that was never published (the first published version is 0.3.0), so that entry answers 404. Change it to the version of your core release (0.3.0 for 2.0.0-rc.94, 0.3.1 for 2.0.0-rc.95, 0.4.0 for 2.0.0-rc.96), then restart.

The residual risk of proxied code, and static:

Section titled “The residual risk of proxied code, and static:”

With proxy:, the code runs from the publishing host with the administrator’s session. The policy stops it from loading foreign code and from calling hosts outside the platform, but connect-src to the platform’s own hosts does not stop exfiltration: a tampered build could still write a stolen token as an event into an account its author holds on the same platform, send it in the URL of another hosted site whose proxy: forwards to its own upstream, or navigate the page away with it. Whoever can change the published build runs code with administrator sessions on every platform that points at it; the immutable version directories, the protected repository and the CI-only publishing narrow that, they do not remove it.

static: removes it, and is the answer for air-gapped platforms and custom builds: download the release tarball, verify it, unpack it in a folder the core reads, and point the site at it.

Terminal window
sha256sum -c app-web-platform-portal-<x.y.z>.tgz.sha256
gh attestation verify app-web-platform-portal-<x.y.z>.tgz --repo pryv/app-web-platform-portal
hostedSites:
admin:
static: /srv/pryv/sites/admin # holds index.html
headers:
content-security-policy: "default-src 'self'; connect-src 'self' https://*.<domain>; object-src 'none'; base-uri 'self'; form-action 'self'"

A static: site behaves like GitHub Pages (a folder without its trailing slash redirects, a miss serves the build’s 404.html); files can be replaced without a restart, but a static: path that is itself a symlink re-pointed at a new release folder needs a restart. The wizard’s static mode writes such an entry and warns while the folder has no index.html (the core refuses to boot without it).

The wizard writes the portal entry on new installs only. On an existing platform:

  1. Make sure no account holds the site name (default admin).
  2. Add the hostedSites entry (proxy with forwardQuery: false, or static, with the policy above), portal.site and the auth.trustedApps entry to every core’s configuration, the same everywhere.
  3. Restart. An upgraded platform is recorded as set up: its first administrator comes from a claim code (node bin/admin.js claim-code --role owner on a core, see First boot and administrators). Once administrators are in place and no script needs it, consider auth.adminAccessKeyScope: break-glass.

A hosted site with proxy: answers 502 to an upstream redirect that leaves its base (from 2.0.0-rc.92): point proxy: at the final address.