Skip to content

Commit

Permalink
Organise env variables and authorization (#60)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
samuelim01 authored Oct 26, 2024
1 parent bc65ef7 commit 6bf6136
Show file tree
Hide file tree
Showing 38 changed files with 600 additions and 276 deletions.
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ MATCH_DB_LOCAL_URI=mongodb://match-db:27017/match
MATCH_DB_USERNAME=user
MATCH_DB_PASSWORD=password

# Broker
BROKER_URL=amqp://broker:5672

# Secret for creating JWT signature
JWT_SECRET=you-can-replace-this-with-your-own-secret

Expand Down
2 changes: 1 addition & 1 deletion compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
ports:
- 27019:27017

match-broker:
broker:
ports:
- 5672:5672

Expand Down
13 changes: 8 additions & 5 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
DB_USERNAME: ${QUESTION_DB_USERNAME}
DB_PASSWORD: ${QUESTION_DB_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
networks:
- gateway-network
- question-db-network
Expand Down Expand Up @@ -94,8 +95,10 @@ services:
DB_LOCAL_URI: ${MATCH_DB_LOCAL_URI}
DB_USERNAME: ${MATCH_DB_USERNAME}
DB_PASSWORD: ${MATCH_DB_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
BROKER_URL: ${BROKER_URL}
depends_on:
match-broker:
broker:
condition: service_healthy
networks:
- gateway-network
Expand All @@ -114,13 +117,13 @@ services:
- match-db-network
restart: always

match-broker:
container_name: match-broker
hostname: match-broker
broker:
container_name: broker
hostname: broker
image: rabbitmq:4.0.2
user: rabbitmq
networks:
- match-db-network
- gateway-network
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
Expand Down
5 changes: 4 additions & 1 deletion services/match/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ DB_CLOUD_URI=<FILL-THIS-IN>
DB_LOCAL_URI=mongodb://match-db:27017/match
DB_USERNAME=user
DB_PASSWORD=password
PORT=8083
BROKER_URL=amqp://broker:5672
JWT_SECRET=you-can-replace-this-with-your-own-secret
PORT=8083
NODE_ENV=development
Loading

0 comments on commit 6bf6136

Please sign in to comment.