Code fix perform code refactoring#38
Conversation
Reviewer's GuideRefactors configuration management into a single application.yaml, centralizes token creation logic in JwtService, adjusts activation URL composition, and adds Docker/Docker Compose support for running the IAM service with MongoDB and RabbitMQ. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The configuration refactor removes the separate
application-*.yamlfiles and hardcodesspring.profiles.active: localwhile introducing adockerprofile in docker-compose; verify that the desired profile is selected in all environments and that equivalent settings from the deleted files are still available where needed. - The new
application-docker.txtandapplication-local.txtfiles will not be picked up as Spring Boot configuration sources; if these are meant to define profile-specific configs they should use a supported format and naming (e.g.,application-docker.yamlor.properties). - The docker-compose service for
iam-servicerelies onMONGO_URI,RABBITMQ_HOST,RABBITMQ_PORT, etc. but does not set them, so the container may fail to start unless these variables are guaranteed to be provided from the environment; consider wiring them explicitly indocker-compose.ymlor documenting the expectation.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The configuration refactor removes the separate `application-*.yaml` files and hardcodes `spring.profiles.active: local` while introducing a `docker` profile in docker-compose; verify that the desired profile is selected in all environments and that equivalent settings from the deleted files are still available where needed.
- The new `application-docker.txt` and `application-local.txt` files will not be picked up as Spring Boot configuration sources; if these are meant to define profile-specific configs they should use a supported format and naming (e.g., `application-docker.yaml` or `.properties`).
- The docker-compose service for `iam-service` relies on `MONGO_URI`, `RABBITMQ_HOST`, `RABBITMQ_PORT`, etc. but does not set them, so the container may fail to start unless these variables are guaranteed to be provided from the environment; consider wiring them explicitly in `docker-compose.yml` or documenting the expectation.
## Individual Comments
### Comment 1
<location path="src/main/resources/application.yaml" line_range="46-47" />
<code_context>
- header: X-Trace-Id
- key: traceId
-
-server:
- port: 4200
-
-logging:
</code_context>
<issue_to_address>
**issue (bug_risk):** Server port and base URL / CORS configuration look inconsistent and may cause confusion or misrouting.
The backend is set to run on port 4200, while `app.base-url` points to `http://localhost:5600/api/v1/auth` and CORS allows `http://localhost:4200`. If 4200 is for the Angular UI and another port is for this API, consider aligning `server.port`, `app.base-url`, and `iam.security.cors.allowed_origins` to match the intended deployment, so it’s clear which port actually serves the API in local/docker setups.
</issue_to_address>
### Comment 2
<location path="docker-compose.yml" line_range="14-15" />
<code_context>
+ dockerfile: Dockerfile
+ ports:
+ - "4200:4200"
+ environment:
+ - SPRING_PROFILES_ACTIVE=docker
+ depends_on:
+ mongo-db:
</code_context>
<issue_to_address>
**issue (bug_risk):** Docker compose does not set the env vars referenced in `application.yaml`, which may break connectivity inside containers.
`application.yaml` expects `${MONGO_URI}`, `${RABBITMQ_HOST}`, `${RABBITMQ_PORT}`, `${RABBITMQ_USER}`, and `${RABBITMQ_PASS}`, but `iam-service`’s compose config only sets `SPRING_PROFILES_ACTIVE`. Unless these vars are injected externally, MongoDB/RabbitMQ connections will fail under `docker-compose`. Please add the relevant env vars here (e.g., using `mongo-db` / `rabbitmq` as hosts) so the compose stack works out of the box.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| server: | ||
| port: 4200 |
There was a problem hiding this comment.
issue (bug_risk): Server port and base URL / CORS configuration look inconsistent and may cause confusion or misrouting.
The backend is set to run on port 4200, while app.base-url points to http://localhost:5600/api/v1/auth and CORS allows http://localhost:4200. If 4200 is for the Angular UI and another port is for this API, consider aligning server.port, app.base-url, and iam.security.cors.allowed_origins to match the intended deployment, so it’s clear which port actually serves the API in local/docker setups.
| environment: | ||
| - SPRING_PROFILES_ACTIVE=docker |
There was a problem hiding this comment.
issue (bug_risk): Docker compose does not set the env vars referenced in application.yaml, which may break connectivity inside containers.
application.yaml expects ${MONGO_URI}, ${RABBITMQ_HOST}, ${RABBITMQ_PORT}, ${RABBITMQ_USER}, and ${RABBITMQ_PASS}, but iam-service’s compose config only sets SPRING_PROFILES_ACTIVE. Unless these vars are injected externally, MongoDB/RabbitMQ connections will fail under docker-compose. Please add the relevant env vars here (e.g., using mongo-db / rabbitmq as hosts) so the compose stack works out of the box.
Summary by Sourcery
Introduce containerization and consolidate configuration for the IAM service while centralizing token generation logic.
New Features:
Enhancements:
Build:
Deployment: