Skip to content

Commit 79206db

Browse files
committed
idp: add emqx authn/authz example
Signed-off-by: hmoazzem <moazzem@edgeflare.io>
1 parent 429b746 commit 79206db

6 files changed

Lines changed: 253 additions & 131 deletions

File tree

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ edge configures and manages:
44

55
| Component | Technology / Tool | Description |
66
|-------------------|-----------------------|-------------|
7-
| Platform | Linux, Docker, [Kubernetes](https://kubernetes.io) | Native and containerized deployments provideing ease and scalability |
87
| Database | [PostgreSQL](https://www.postgresql.org) + [pgvector](https://github.com/pgvector/pgvector) | The world's most advanced open source database. Vector search using pgvector |
9-
| (IAM) AuthN/AuthZ | [ZITADEL](https://github.com/zitadel/zitadel) + [Postgres RLS](https://www.postgresql.org/docs/current/ddl-rowsecurity.html) | Comprehensive authN and authZ through ZITADEL, PostgreSQL Row-Level Security and envoy filters eg ext-authz |
10-
| Object Storage | [MinIO](https://github.com/minio/minio) / [SeaweedFS](https://github.com/seaweedfs/seaweedfs) | Offers high-performance, Kubernetes-native object storage. |
8+
| (IAM) AuthN/AuthZ | Any OIDC compliant IdP eg Keykloak, Auth0, [ZITADEL](https://github.com/zitadel/zitadel) (default) + [Postgres RLS](https://www.postgresql.org/docs/current/ddl-rowsecurity.html) | Comprehensive authN and authZ through OIDC claims, PostgreSQL Row-Level Security and envoy filters eg ext-authz |
9+
| Object Storage | Any S3 compliant storage eg AWS S3, Cloudflare R2, [MinIO](https://github.com/minio/minio), Ceph RGW, [SeaweedFS](https://github.com/seaweedfs/seaweedfs) (default) | Offers high-performance, Kubernetes-native object storage. |
1110
| REST API / Events | [edgeflare/pgo](https://github.com/edgeflare/pgo) | PostgREST-compatible REST API, Debezium-compatible CDC |
1211
| API Gateway | [Istio](https://istio.io)/[Envoy](https://www.envoyproxy.io), [cert-manager](https://cert-manager.io) and optionally [Cloudflare](https://cloudflare.com) | Manages, secures, and monitors traffic between microservices as well as from and to the Internet |
1312

14-
for a unified backend - similar to Firebase, Supabase etc. And with scaling capabilities. **We use [PostgREST](https://docs.postgrest.org) where reliability is important; writing similar in Go to be able to 1. embed in a go binary and 2. run in serverless env.**
13+
to build a unified backend - similar to Firebase, Supabase etc. And with scaling capabilities. The stack runs on Linux, Docker and [Kubernetes](https://kubernetes.io) allowing it to start on a RaspberryPi-like device and scale to a multi-region Kubernetes cluster.
1514

15+
edge allows (is purposefully designed) to mix-match existing, external (incl proprietary) components from anywhere - eg GCP Cloud SQL, Auth0 IdP, AWS S3, etc. it simply ensures all these are configred to function as a single unit.
1616

17+
> **We use [PostgREST](https://docs.postgrest.org) where reliability is important; writing [edgeflare/pgo](https://github.com/edgeflare/pgo) in Go to be able to 1. embed in a go binary and 2. run in serverless env.**
1718
1819
## Deployment options
1920

@@ -32,7 +33,7 @@ git clone git@github.com:edgeflare/edge.git && cd edge
3233
1. determine a root domain (hostname) eg `example.org`. if such a globally routable domain isn't available,
3334
utilize https://sslip.io resolver, which returns embedded IP address in domain name. that's what this demo setup does
3435

35-
> when containers dependent on zitadel (it being the centralized IdP) fail, try restarting it once zitadel is healthy
36+
> when containers dependent on zitadel (it being the centralized IdP) fail, try restarting them once zitadel is healthy
3637
3738
```sh
3839
export EDGE_DOMAIN_ROOT=192-168-0-121.sslip.io # resolves to 192.168.0.121 (gateway/envoy IP). use LAN or accesible IP/hostname
@@ -69,6 +70,7 @@ For publicly trusted certificates, enable TLS by updating env vars in ZITADEL.
6970

7071
5. start containers
7172
```sh
73+
# docker compose build
7274
docker compose up -d
7375
```
7476

docker-compose.yaml

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,6 @@ services:
5555
volumes:
5656
- $PWD/__zitadel:/machinekey:rw,Z
5757

58-
edge:
59-
user: "${UID:-1000}"
60-
build:
61-
context: "."
62-
dockerfile: "./internal/stack/Containerfile"
63-
entrypoint: sh -c "id && ls -la /workspace/zitadel/admin-sa.json && while [ ! -f /workspace/zitadel/admin-sa.json ]; do sleep 1; done; sleep 2; /edge serve"
64-
ports:
65-
# - 18000:18000 # xds-server
66-
- 8081:8081 # http-admin
67-
environment:
68-
EDGE_DOMAIN_ROOT: ${EDGE_DOMAIN_ROOT}
69-
EDGE_IAM_ZITADEL_MACHINEKEYPATH: "/workspace/zitadel/admin-sa.json"
70-
healthcheck:
71-
test: [CMD, /edge, healthz]
72-
interval: 5s
73-
timeout: 5s
74-
retries: 3
75-
start_period: 30s
76-
start_interval: 5s
77-
volumes:
78-
- $PWD/__zitadel:/workspace/zitadel:rw,Z,U
79-
restart: on-failure
80-
8158
db-app:
8259
image: docker.io/bitnami/postgresql:17.3.0
8360
environment:
@@ -155,11 +132,14 @@ services:
155132
MINIO_IDENTITY_OPENID_CLAIM_USERINFO: on
156133
MINIO_IDENTITY_OPENID_COMMENT: "OIDC Identity Provider"
157134
# notify postgres
158-
MINIO_NOTIFY_POSTGRES_ENABLE: on
159-
MINIO_NOTIFY_POSTGRES_CONNECTION_STRING: "host=db-app port=5432 user=postgres password=postgrespw dbname=main sslmode=prefer"
160-
MINIO_NOTIFY_POSTGRES_FORMAT: namespace
161-
MINIO_NOTIFY_POSTGRES_ID: minioevents
162-
MINIO_NOTIFY_POSTGRES_TABLE: minioevents
135+
MINIO_NOTIFY_POSTGRES_ENABLE_PRIMARY: on
136+
MINIO_NOTIFY_POSTGRES_CONNECTION_STRING_PRIMARY: "host=db-app port=5432 user=postgres password=postgrespw dbname=main sslmode=prefer"
137+
MINIO_NOTIFY_POSTGRES_TABLE_PRIMARY: minioevents
138+
MINIO_NOTIFY_POSTGRES_FORMAT_PRIMARY: namespace
139+
MINIO_NOTIFY_POSTGRES_MAX_OPEN_CONNECTIONS_PRIMARY: 2
140+
MINIO_NOTIFY_POSTGRES_QUEUE_DIR_PRIMARY: /opt/minio/events
141+
MINIO_NOTIFY_POSTGRES_QUEUE_LIMIT_PRIMARY: 100000
142+
MINIO_NOTIFY_POSTGRES_COMMENT_PRIMARY: "PostgreSQL Notification Event Logging for MinIO"
163143
volumes:
164144
- s3-minio:/mnt/data
165145
ports:
@@ -238,8 +218,57 @@ services:
238218
GRANT ALL PRIVILEGES ON TABLE public.minioevents TO minio;
239219
"
240220
restart: on-failure
221+
emqx: # MQTT broker. prefer NATS' MQTT
222+
image: docker.io/emqx:5.8
223+
environment:
224+
EMQX_DASHBOARD__DEFAULT_PASSWORD: public
225+
EMQX_DASHBOARD__DEFAULT_USERNAME: admin
226+
ports:
227+
- 1883:1883 # MQTT
228+
- 8883:8883 # MQTTS
229+
- 8083:8083 # WS
230+
- 8084:8084 # WSS
231+
- 18083:18083 # http-dashboard
232+
volumes:
233+
- emqx:/opt/emqx/data
234+
healthcheck:
235+
test: ["CMD", "emqx_ctl", "status"]
236+
interval: 5s
237+
timeout: 5s
238+
retries: 5
239+
240+
edge:
241+
user: "${UID:-1000}"
242+
build:
243+
context: "."
244+
dockerfile: "./internal/stack/Containerfile"
245+
entrypoint: sh -c "id && ls -la /workspace/zitadel/admin-sa.json && while [ ! -f /workspace/zitadel/admin-sa.json ]; do sleep 1; done; sleep 2; /edge serve --configure-addons=emqx"
246+
# extra comma-separated add-ons eg emqx,nats, ...
247+
ports:
248+
# - 18000:18000 # xds-server
249+
- 8081:8081 # http-admin
250+
environment:
251+
EDGE_DOMAIN_ROOT: ${EDGE_DOMAIN_ROOT}
252+
EDGE_IAM_ZITADEL_MACHINEKEYPATH: "/workspace/zitadel/admin-sa.json"
253+
healthcheck:
254+
test: [CMD, /edge, healthz]
255+
interval: 5s
256+
timeout: 5s
257+
retries: 3
258+
start_period: 30s
259+
start_interval: 5s
260+
volumes:
261+
- $PWD/__zitadel:/workspace/zitadel:rw,Z,U
262+
restart: on-failure
241263

242264
volumes:
243265
db-app:
244266
db-auth:
245267
s3-minio:
268+
emqx:
269+
270+
# MINIO_NOTIFY_POSTGRES_ENABLE: on
271+
# MINIO_NOTIFY_POSTGRES_CONNECTION_STRING: "host=db-app port=5432 user=postgres password=postgrespw dbname=main sslmode=prefer"
272+
# MINIO_NOTIFY_POSTGRES_FORMAT: namespace
273+
# MINIO_NOTIFY_POSTGRES_ID: minioevents
274+
# MINIO_NOTIFY_POSTGRES_TABLE: minioevents

0 commit comments

Comments
 (0)