Privasys
Privasys CLI

Local development

Run your app on your own machine behind the platform's edge rules with privasys dev run, so you never build a proxy or a security layer of your own.

On the platform, the enclave runtime stands in front of your app. It decides which routes are served in the clear, strips headers in both directions, tells your app who is calling and on which leg, and guards the configure endpoint. On your laptop none of that exists, and it is tempting to write a small proxy or middleware to stand in for it. That code then behaves differently from the runtime, and it ends up shipped.

privasys dev run puts the runtime's own rules in front of your local app instead. It is built from the same code the runtime uses.

privasys dev run --manifest privasys.json --app http://127.0.0.1:8080
Local edge for http://127.0.0.1:8080 on http://localhost:8787
  in the clear: static /, static /assets/, POST /hooks/demo
  page security headers on static responses: Content-Security-Policy, X-Content-Type-Options
  private routes: signed in as 3f1c… (owner)
  configure: POST /configure, owner or admin only; every other route waits for it
  not emulated: attestation, sealing, prices, rate limits, vault keys

Open http://localhost:8787 and use your app as you would on the platform. Each request is logged with the rule that applied.

What it applies

The rules come from your privasys.json, the same document your image carries in its org.privasys.manifest label:

  • Static and public surfaces are served in the clear exactly as on the gateway's terminated leg: the request header allow-list (a route's declared headers included), the response header allow-list (no Set-Cookie), the CORS answer, Referrer-Policy and your surfaces.security_headers. Your app sees X-Privasys-Transport: public.
  • Every other route is private. On the platform a browser reaches it through a sealed session, so here your app sees X-Privasys-Transport: sealed and the identity headers X-Privasys-Sub, X-Privasys-Email and X-Privasys-Name (percent-encoded UTF-8).
  • The configure endpoint is answered as on the platform: owner or admin only, X-Privasys-Configure-Authorized: role=…; sub=… on a pass, and every other route, static and public ones included, held with 503 until the first configure call returns 2xx, unless the manifest marks it optional.
  • Guarded routes (tools[].x-privasys.auth: authenticated, owner, role(…)) are checked against the development identity. A guarded route or the configure endpoint reached on a static or public path is refused, as on the platform.
  • Configure, owner and role(…) need a bearer. On the platform they take their authority from the caller's platform token, never from the sealed session alone, so a page that calls them must send its bearer. Locally any Authorization: Bearer … stands for it, and the edge removes it before your app, as the runtime does. authenticated routes take the session's subject and need no bearer.
  • Headers only the runtime sets are removed from every request, so your app cannot come to rely on a client sending X-Privasys-Sub or X-Privasys-Transport.

A manifest the platform would refuse is refused at start, with the same reason: a malformed surfaces block, a priced or configure route declared in the clear, a guarded route that is also static or public, or an unknown security header.

The identity

By default the identity is your CLI sign-in (privasys auth login), as the owner of the app. You can change it:

FlagEffect
--as <subject>assert this subject instead, without a sign-in
--email, --nameset the email and name the app sees
--roles owner,opsthe caller's app roles: owner or admin pass configure and owner routes; any name matches a role(…) route; none for no role
--anonymousassert no identity at all

Run a second edge on another port with --as to see your app with two users at once.

What it does not do

It does not attest, seal, bill, rate-limit or reach vaults. A priced route is served unbilled, and your app gets no data key from a vault. Test those on the test environment (--test).

The edge listens on this machine only. It refuses a --listen address other machines could reach, requests from any other address, any host name other than localhost or a loopback address (a page elsewhere cannot point its own name at your edge), and any request another site makes from your browser to a private route, a link, an image, a form or a WebSocket alike (another site in your browser cannot act as you). It also refuses to forward to an --app that is not on this machine, since the app receives your identity. A page on any loopback origin, such as your UI's dev server on another port, counts as your app's own.

FlagDefault
--manifestprivasys.json
--apprequired: where your app listens
--listen127.0.0.1:8787
Edit on GitHub