Skip to content

Feat: Move key.txt to auth_profiles for easier Docker management (Fixes #216)#235

Merged
CJackHwang merged 1 commit intoCJackHwang:mainfrom
NikkeTryHard:feature/216-move-key-txt
Sep 5, 2025
Merged

Feat: Move key.txt to auth_profiles for easier Docker management (Fixes #216)#235
CJackHwang merged 1 commit intoCJackHwang:mainfrom
NikkeTryHard:feature/216-move-key-txt

Conversation

@NikkeTryHard
Copy link
Copy Markdown
Collaborator

Summary

This pull request resolves issue #216 by relocating the key.txt API key file from the project root into the auth_profiles/ directory.

The primary motivation for this change is to simplify data persistence when using Docker. It allows the entire auth_profiles directory, which contains session data and now the API keys, to be managed by a single named volume. This improves containerization and makes configuration more intuitive.

Changes Implemented

  • api_utils/auth_utils.py: The KEY_FILE_PATH variable was updated to point to the new location (auth_profiles/key.txt). Logic was also added to ensure the auth_profiles directory is created automatically if it doesn't exist.
  • api_utils/routes.py: The API key management endpoints (add_api_key, delete_api_key) were refactored to use the centralized KEY_FILE_PATH from auth_utils, improving code consistency.

Testing Results

The feature was thoroughly tested on Windows using PowerShell to verify its functionality.

Test 1: Initialization

  • Action: Started the server without an existing key.txt.
  • Result: Success. A new, empty key.txt was correctly created in auth_profiles/, and no file was created in the root directory.

Test 2: Authentication with a Valid Key

  • Action: Manually added my-test-key-123 to auth_profiles/key.txt and restarted the server.
  • Result: Success. The following PowerShell curl command was executed and returned a 200 OK status, confirming successful authentication.

Command:

curl -Uri 'http://localhost:2048/v1/chat/completions' `
     -Method POST `
     -ContentType 'application/json' `
     -Headers @{
         "Authorization" = "Bearer my-test-key-123"
     } `
     -Body '{"model": "gemini-2.5-pro", "messages": [{"role": "user", "content": "Hello, this is a successful auth test."}]}'

@CJackHwang CJackHwang merged commit 0d2fac4 into CJackHwang:main Sep 5, 2025
@CJackHwang
Copy link
Copy Markdown
Owner

感谢您的贡献

@NikkeTryHard NikkeTryHard deleted the feature/216-move-key-txt branch September 5, 2025 16:53
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