-
Notifications
You must be signed in to change notification settings - Fork 0
Add reset endpoints for the auth, todos and users to be reconfigured at runtime #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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):
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)