Add reset endpoints for the auth, todos and users to be reconfigured at runtime#8
Merged
matheusgalvao1 merged 3 commits intomainfrom Jul 16, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds reset endpoints for authentication, users, and todos that allow runtime reconfiguration without restarting the server. The implementation provides new endpoints to upload JSON files for resetting data and updating authentication methods dynamically.
- Adds reset functionality for todos, users, and authentication configuration with runtime updates
- Implements comprehensive validation for uploaded JSON files with detailed error messages
- Includes proper security measures by clearing tokens/sessions when authentication is reset
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| app/services/todo_service.py | Adds reset_todos method with JSON validation and todo data loading |
| app/services/auth_service.py | Adds reset_auth_service and reset_users functions for auth/user management |
| app/routes/todos.py | Implements /reset POST endpoint for todo data uploads |
| app/routes/auth.py | Adds /reset and /reset-users endpoints for auth configuration and user data |
| app/middleware/auth_middleware.py | Adds global middleware instance management for runtime config updates |
| app/main.py | Registers global middleware instance for runtime reconfiguration |
| app/config/auth_config.py | Adds update_from_dict and to_dict methods for config serialization |
| .github/workflows/docker-build-push.yml | Adds Docker build and push workflow for CI/CD |
Comments suppressed due to low confidence (2)
app/services/todo_service.py:181
- [nitpick] The variable name 'i' is not descriptive. Consider using 'index' or 'todo_index' for better readability.
for i, todo_data in enumerate(new_todos_data):
app/services/auth_service.py:189
- [nitpick] The variable name 'i' is not descriptive. Consider using 'index' or 'user_index' for better readability.
for i, user_data in enumerate(new_users_data):
matheusgalvao1
approved these changes
Jul 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The change adds new endpoints for changing the authentication and data setup dynamically at runtime.
Why: We need to create the API as a sidecar to enable it in any base task we want, and since we don't have shared memory space for sidecars, it won't be possible to load and start the api in the setup.sh. In order to create sidecar, and still be able to provide custom initial todos, and authentication method, we need new endpoints to accommodate that.
Changes
/auth/resetendpoint that takes the auth method and key in a POST request and resets the app with the new configuration./auth/reset-usersendpoint that takes users json as a file and resets the app./todos/resetendpoint that takes todos json as a file and resets the app with new todo items.NOTE: The endpoints are expected to be used only in
setup.sh, but we cannot enforce that – so I'm open to suggestions. (we could have rate limit on those endpoints potentially)