Skip to content

Commit 6bf6136

Browse files
authored
Organise env variables and authorization (#60)
* User: Centralize env variables * Question: Centralize env variables * Match: Centralize env variables * Precalculate DB_URI in services * Rename match broker * Decouple match authorization Let's pass the JWT_SECRET to the match service. This means only the user service will issue authorization tokens, but the service can verify the claims without depending on the user service. * Add question service RBAC Ensure that the creation, updating, and deletion of questions can only be done by admins. * Match: Replace Joi with Zod
1 parent bc65ef7 commit 6bf6136

38 files changed

+600
-276
lines changed

.env.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ MATCH_DB_LOCAL_URI=mongodb://match-db:27017/match
1919
MATCH_DB_USERNAME=user
2020
MATCH_DB_PASSWORD=password
2121

22+
# Broker
23+
BROKER_URL=amqp://broker:5672
24+
2225
# Secret for creating JWT signature
2326
JWT_SECRET=you-can-replace-this-with-your-own-secret
2427

compose.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ services:
4040
ports:
4141
- 27019:27017
4242

43-
match-broker:
43+
broker:
4444
ports:
4545
- 5672:5672
4646

compose.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ services:
3434
DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
3535
DB_USERNAME: ${QUESTION_DB_USERNAME}
3636
DB_PASSWORD: ${QUESTION_DB_PASSWORD}
37+
JWT_SECRET: ${JWT_SECRET}
3738
networks:
3839
- gateway-network
3940
- question-db-network
@@ -94,8 +95,10 @@ services:
9495
DB_LOCAL_URI: ${MATCH_DB_LOCAL_URI}
9596
DB_USERNAME: ${MATCH_DB_USERNAME}
9697
DB_PASSWORD: ${MATCH_DB_PASSWORD}
98+
JWT_SECRET: ${JWT_SECRET}
99+
BROKER_URL: ${BROKER_URL}
97100
depends_on:
98-
match-broker:
101+
broker:
99102
condition: service_healthy
100103
networks:
101104
- gateway-network
@@ -114,13 +117,13 @@ services:
114117
- match-db-network
115118
restart: always
116119

117-
match-broker:
118-
container_name: match-broker
119-
hostname: match-broker
120+
broker:
121+
container_name: broker
122+
hostname: broker
120123
image: rabbitmq:4.0.2
121124
user: rabbitmq
122125
networks:
123-
- match-db-network
126+
- gateway-network
124127
healthcheck:
125128
test: rabbitmq-diagnostics check_port_connectivity
126129
interval: 30s

services/match/.env.sample

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ DB_CLOUD_URI=<FILL-THIS-IN>
44
DB_LOCAL_URI=mongodb://match-db:27017/match
55
DB_USERNAME=user
66
DB_PASSWORD=password
7-
PORT=8083
7+
BROKER_URL=amqp://broker:5672
8+
JWT_SECRET=you-can-replace-this-with-your-own-secret
9+
PORT=8083
10+
NODE_ENV=development

0 commit comments

Comments
 (0)