-
Notifications
You must be signed in to change notification settings - Fork 154
Description
Is your feature request related to a problem? Please describe.
Currently, there's no programmatic way to create new users in the Git Proxy system. Administrators must manually create users through the database or UI, which is time-consuming and error-prone, especially when setting up multiple users or integrating with automated systems. This limitation makes it difficult to scale user management and integrate with other tools that might need to create users programmatically.
Describe the solution you'd like
I've implemented a new API endpoint and CLI command that allows administrators to create new users programmatically:
-
API Endpoint: A new
/api/auth/create-userendpoint that accepts POST requests with user details (username, password, email, gitAccount, and optional admin flag). -
CLI Command: A new
create-usercommand for the Git Proxy CLI that provides a convenient way to create users from the command line.
Both implementations include proper authentication checks to ensure only administrators can create new users, validation of required fields, and appropriate error handling.
Describe alternatives you've considered
-
Database Scripts: Creating a separate database script for user creation, but this would require direct database access and wouldn't integrate with the application's authentication system.
-
UI-Only Solution: Adding a user creation form to the UI, but this wouldn't support programmatic user creation needed for automation.
Additional context
The implementation includes comprehensive tests for both the API endpoint and CLI command, covering:
- Authentication requirements (only admins can create users)
- Validation of required fields
- Error handling for various scenarios
- Successful user creation and verification
This feature enhances the system's usability for administrators and enables better integration with automated workflows and external systems.
Technical Details:
- The API endpoint returns appropriate HTTP status codes (201 for success, 400 for validation errors, 401 for unauthorized access)
- The CLI command provides clear error messages and exit codes for different failure scenarios
- Both implementations maintain the existing security model where only administrators can create new users