A lightweight authentication proxy for Dgraph databases that adds an authentication layer between clients and your Dgraph instance.
- Acts as a secure middleware between clients and Dgraph
- Simple configuration via environment variables
- Docker-ready with multi-platform support
- Built with modern Node.js (using H3 for HTTP handling)
- Node.js (v18+ recommended)
- Yarn (v4+)
- Docker (for containerized deployment)
- A Dgraph instance (local or remote)
-
Clone the repository:
git clone https://github.com/ezyostudio/dgraph-dg-auth-proxy.git cd dgraph-dg-auth-proxy -
Install dependencies:
yarn install
-
Create a
.envfile with your Dgraph configuration:DGRAPH_URL=https://your-dgraph-instance.url DGRAPH_AUTH_TOKEN=your-dgraph-auth-token
-
Start the development server:
yarn dev
The included docker-compose.yml sets up:
- Dgraph Zero service
- Dgraph Alpha service
- This auth proxy service
- Replace the placeholder tokens in
docker-compose.ymlwith your actual tokens:
your-admin-token(Dgraph admin API key)your-client-token(Dgraph client API key, also set in proxy environment)
- Start the services:
docker-compose up -d
| Variable | Description | Required | Default |
|---|---|---|---|
PORT |
Port to listen on | No | 80 |
HOST |
Host to bind to | No | 0.0.0.0 |
DGRAPH_URL |
URL to your Dgraph instance | Yes | - |
DGRAPH_AUTH_TOKEN |
Authentication token for Dgraph | Yes | - |
The project includes a GitHub Actions workflow that automatically builds and pushes a Docker image to GitHub Container Registry when a new release is published.
To manually build and push:
- Pull the image
docker pull ghcr.io/ezyostudio/dgraph-dg-auth-proxy:latest docker run -p 3000:3000 -e PORT=3000 -e DGRAPH_URL=http://<dgraph-alpha-url> -e DGRAPH_AUTH_TOKEN=<client-token> ghcr.io/ezyostudio/dgraph-dg-auth-proxy
The project includes a wrangler.toml configuration for deploying to Cloudflare Workers. To deploy:
-
Install Wrangler:
npm install -g wrangler
-
Deploy:
wrangler deploy
- Dev server:
yarn dev(watches for changes) - Production server:
yarn start
The project uses Dependabot to automatically check for dependency updates daily for both npm packages and GitHub Actions.