Skip to content

Conversation

nanehambardzumyan
Copy link
Contributor

@nanehambardzumyan nanehambardzumyan commented Jul 14, 2025

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

  • Added /auth/reset endpoint that takes the auth method and key in a POST request and resets the app with the new configuration.
  • Added /auth/reset-users endpoint that takes users json as a file and resets the app.
  • Added /todos/reset endpoint 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)

@nanehambardzumyan nanehambardzumyan self-assigned this Jul 14, 2025
Copy link

@Copilot Copilot AI left a 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):

@matheusgalvao1 matheusgalvao1 merged commit c9b0bc9 into main Jul 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants