Skip to content

fix: validate NEWAPI token input across UI and API#109

Merged
cnlimiter merged 4 commits intocnlimiter:masterfrom
MisonL:feature/newapi-token-validation
Mar 27, 2026
Merged

fix: validate NEWAPI token input across UI and API#109
cnlimiter merged 4 commits intocnlimiter:masterfrom
MisonL:feature/newapi-token-validation

Conversation

@MisonL
Copy link
Copy Markdown
Contributor

@MisonL MisonL commented Mar 27, 2026

Summary

  • validate NEWAPI authorization token input in the upload flow
  • validate NEWAPI service token input in create/update API and WebUI form
  • remove NEWAPI payload logging to avoid leaking token-bearing request data

Validation

  • uv run python -m pytest -q tests/test_newapi_upload.py tests/test_newapi_service_routes.py
  • node --test tests/test_settings_newapi_validation.cjs

Copy link
Copy Markdown
Contributor

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 improves NEWAPI token validation across the Web UI and API, and hardens the NEWAPI upload flow to avoid leaking token-bearing request data.

Changes:

  • Add UI-side validation for NEWAPI “Root Token / API Key” input and show a hint in settings.
  • Add API-side validation for NEWAPI service create/update routes using shared normalization logic.
  • Update NEWAPI upload request construction (ASCII-safe JSON payload + explicit UTF-8 encoding) and add tests for validation behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_settings_newapi_validation.cjs Adds Node-based unit tests for the new UI validation function in settings.js.
tests/test_newapi_upload.py Adds tests for ASCII-only authorization token enforcement and upload request shape.
tests/test_newapi_service_routes.py Adds tests ensuring API routes reject non-ASCII NEWAPI tokens on create/update.
templates/settings.html Adds a user-facing hint that the token must be ASCII-only.
static/js/settings.js Introduces validateNewapiApiKeyInput() and uses it when saving NEWAPI services in the UI.
src/web/routes/upload/newapi_services.py Normalizes/validates NEWAPI API key on create/update and returns 400 on invalid tokens.
src/core/upload/newapi_upload.py Adds shared token normalization, adjusts JSON encoding, and changes request sending/logging behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cnlimiter and others added 3 commits March 27, 2026 15:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@cnlimiter cnlimiter merged commit 8d97989 into cnlimiter:master Mar 27, 2026
1 check failed
@MisonL MisonL deleted the feature/newapi-token-validation branch March 27, 2026 11:35
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.

3 participants