cryptgeon
repository·main·Indexed 23 days ago
https://github.com/cupcakearmy/cryptgeonA secure, open-source service for sharing self-destructing notes and files using client-side AES-GCM encryption. It includes a web frontend, a CLI for sending text and files, and supports deployment via Docker with Redis/Valkey backends and Traefik as a reverse proxy.
What's inside cryptgeon
- The Cryptgeon Frontend is the web-based interface for the Cryptgeon service. It allows users to interact with the service via a browser to securely share encrypted data.
How cryptgeon works
mainCryptgeon provides end-to-end encryption for sharing notes and files.
- Generation: Each note is assigned a 256-bit
id(for retrieval) and a 256-bitkey(for decryption). - Encryption: The client encrypts the content using AES in GCM mode with the generated
keybefore sending it to the server. - Storage: The encrypted data is stored in memory (via Redis) and is never persisted to disk.
- Security: The server never sees the encryption key and cannot decrypt the contents.
Note on View Counts: View counts are guaranteed to be accurate only when using a single running instance. Multiple instances connected to the same Redis instance may experience race conditions where a note is retrieved more times than its
MAX_VIEWSsetting allows.- Generation: Each note is assigned a 256-bit
Install Cryptgeon with Traefik
mainTo deploy Cryptgeon using Traefik as a reverse proxy, you need an existing Traefik installation (v2 or v3) configured with an external Docker network (e.g.,
proxy), a certificate resolver (e.g.,le), and an HTTPS entrypoint (e.g.,secure).This setup uses Valkey (a Redis alternative) as the backend. To ensure data stays in RAM only and avoids persistent disk storage, the Valkey service must be configured with
--save ""and--appendonly no, and use atmpfsmount on/data.version: '3.8' networks: proxy: external: true services: redis: image: valkey/valkey:7-alpine # This is required to stay in RAM only. command: valkey-server --save "" --appendonly no # Set a size limit to prevent memory exhaustion: # --maxmemory 1gb --maxmemory-policy allkeys-lru # This prevents the creation of an anonymous volume. tmpfs: - /data app: image: cupcakearmy/cryptgeon:latest restart: unless-stopped depends_on: - redis networks: - default - proxy labels: - traefik.enable=true - traefik.http.routers.cryptgeon.rule=Host(`example.org`) - traefik.http.routers.cryptgeon.entrypoints=secure - traefik.http.routers.cryptgeon.tls.certresolver=leConfigure Traefik as a reverse proxy
mainTraefik manages HTTPS certificates and routing via Docker labels. To set up Traefik with automatic HTTP to HTTPS redirection and ACME (Let's Encrypt) support, use the following configuration files.
Directory Structure:
/foo/bar/traefik/ ├── docker-compose.yaml └── traefik.yamlSetup Steps:
- Create a Docker network named
proxy. - Deploy Traefik using the provided
docker-compose.yamlandtraefik.yamlconfigurations. - Use the
lecertificate resolver for ACME via theinsecure(HTTP) entrypoint.
# docker-compose.yaml version: '3.8' services: traefik: image: traefik:2.6 restart: unless-stopped ports: - '80:80' - '443:443' volumes: - /var/run/docker.sock:/var/run/docker.sock - ./traefik.yaml:/etc/traefik/traefik.yaml:ro - ./data:/data labels: - 'traefik.enable=true' - 'traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)' - 'traefik.http.routers.http_catchall.entrypoints=insecure' - 'traefik.http.routers.http_catchall.middlewares=https_redirect' - 'traefik.http.middlewares.https_redirect.redirectscheme.scheme=https' - 'traefik.http.middlewares.https_redirect.redirectscheme.permanent=true' networks: default: external: true name: proxy# traefik.yaml api: dashboard: true entryPoints: insecure: address: ':80' secure: address: ':443' providers: docker: endpoint: 'unix:///var/run/docker.sock' network: 'proxy' exposedByDefault: false certificatesResolvers: le: acme: email: me@example.org storage: /data/acme.json httpChallenge: entryPoint: insecuredocker network create proxy docker-compose up -d- Create a Docker network named
Install Cryptgeon from scratch using Docker and Traefik
mainTo install Cryptgeon on a Unix-based system, follow these high-level steps:
- Install Docker and Docker Compose.
- Install Traefik to act as a router and proxy for managing HTTPS certificates and routing.
- Deploy the Cryptgeon service.
- (Optional) Install Watchtower to automate container updates.
Secure Cryptgeon with Traefik Basic Auth
mainYou can hide the Cryptgeon service behind authentication using Traefik middleware. This is useful for restricting access to the service. In the example below, a
basicauthmiddleware namedcryptgeon-authis applied to the router.Note that when defining users in a Docker Compose file, the
$character in the hashed password must be escaped by using$$.services: traefik: image: traefik:v3.0 command: - "--api.insecure=true" - "--providers.docker=true" - "--providers.docker.exposedbydefault=false" - "--entrypoints.web.address=:80" ports: - "80:80" volumes: - "/var/run/docker.sock:/var/run/docker.sock:ro" redis: image: valkey/valkey:7-alpine command: valkey-server --save "" --appendonly no tmpfs: - /data cryptgeon: image: cupcakearmy/cryptgeon depends_on: - redis labels: - "traefik.enable=true" - "traefik.http.routers.cryptgeon.rule=Host(`cryptgeon.localhost`)" - "traefik.http.routers.cryptgeon.entrypoints=web" - "traefik.http.routers.cryptgeon.middlewares=cryptgeon-auth" - "traefik.http.middlewares.cryptgeon-auth.basicauth.users=user:$$2y$$05$$juUw0zgc5ebvJ00MFPVVLujF6P.rcEMbGZ99Jfq6ZWEa1dgetacEq"Deploy Cryptgeon using Docker Compose
mainThe simplest way to deploy Cryptgeon is using Docker. Note: Cryptgeon must be used over HTTPS, otherwise browsers may not support the required encryption algorithms.
This configuration includes a Redis service configured to stay in RAM only (no persistence) and the Cryptgeon application service.
# docker-compose.yml version: "3.8" services: redis: image: redis:7-alpine # This is required to stay in RAM only. command: redis-server --save "" --appendonly no # Set a size limit. See link below on how to customise. # https://redis.io/docs/latest/operate/rs/databases/memory-performance/eviction-policy/ # --maxmemory 1gb --maxmemory-policy allkeys-lrulpine # This prevents the creation of an anonymous volume. tmpfs: - /data app: image: cupcakearmy/cryptgeon:latest depends_on: - redis environment: SIZE_LIMIT: 4 MiB ports: - 80:8000Deploy Cryptgeon with NGINX Reverse Proxy
mainYou can use NGINX as a reverse proxy. Configuration templates, including one with HTTPS support, are available in theexamples/nginxdirectory of the repository. You will need to specify your server name and SSL certificates in the configuration.Deploy Cryptgeon with Traefik 2
mainTo deploy Cryptgeon behind Traefik 2, use the following configuration. This example assumes:
- An external Docker proxy network named
proxy. - A certificate resolver named
le. - An HTTPS entrypoint named
secure. - A domain named
example.org.
version: "3.8" networks: proxy: external: true services: redis: image: redis:7-alpine # This is required to stay in RAM only. command: redis-server --save "" --appendonly no # Set a size limit. See link below on how to customise. # https://redis.io/docs/latest/operate/rs/databases/memory-performance/eviction-policy/ # --maxmemory 1gb --maxmemory-policy allkeys-lrulpine # This prevents the creation of an anonymous volume. tmpfs: - /data app: image: cupcakearmy/cryptgeon:latest restart: unless-stopped depends_on: - redis networks: - default - proxy labels: - traefik.enable=true - traefik.http.routers.cryptgeon.rule=Host(`example.org`) - traefik.http.routers.cryptgeon.entrypoints=secure - traefik.http.routers.cryptgeon.tls.certresolver=le- An external Docker proxy network named
Install the Cryptgeon CLI
mainYou can run the Cryptgeon CLI without installation using
npx, or install it globally vianpmto use thecryptgeoncommand directly in your terminal.npx cryptgeon # Or install globally npm -g install cryptgeon cryptgeonDeploy Cryptgeon with Redis/Valkey
mainCryptgeon requires a Redis-compatible backend (the example uses Valkey) and a proxy (Traefik) to handle TLS.
Key Configuration Details:
- Valkey/Redis: Must be configured to stay in RAM only by disabling persistence (
--save "" --appendonly no) and using atmpfsmount for/datato prevent anonymous volume creation. - Environment Variables: Use
SIZE_LIMITto restrict the size of uploaded data (e.g.,4 MiB). - Traefik Labels: You must provide labels to route traffic to the
appservice using your specific domain and thesecureentrypoint with thelecertificate resolver.
Deployment Steps:
- Create a directory for Cryptgeon.
- Create a
docker-compose.yamlusing the template below. - Run
docker-compose up -d.
version: '3.8' networks: proxy: external: true services: redis: image: valkey/valkey:7-alpine command: valkey-server --save "" --appendonly no tmpfs: - /data app: image: cupcakearmy/cryptgeon:latest restart: unless-stopped depends_on: - redis environment: SIZE_LIMIT: 4 MiB networks: - default - proxy labels: - traefik.enable=true - traefik.http.routers.cryptgeon.rule=Host(`cryptgeon.example.org`) - traefik.http.routers.cryptgeon.entrypoints=secure - traefik.http.routers.cryptgeon.tls.certresolver=ledocker-compose up -d- Valkey/Redis: Must be configured to stay in RAM only by disabling persistence (
Cryptgeon CLI Encryption Adapters
mainThe Cryptgeon CLI uses specialized adapters to handle different data types for encryption and decryption. These adapters abstract the underlying AES encryption logic provided by the
occultolibrary. The available adapters are:- Text: Handles standard string data. It encodes strings to bytes before encryption and decodes them back to strings after decryption.
- Blob: Handles raw
TypedArraydata (binary blobs). It encrypts and decrypts raw bytes directly. - Files: Handles an array of
FileDTOobjects. It encrypts multiple files by mapping over them, encrypting their contents via the Blob adapter, and returning a JSON string containing the encrypted metadata and contents (EncryptedFileDTO[]). Decryption reverses this process, returning an array ofFileDTOobjects.