Skip to content

Conversation

@KagemniKarimu
Copy link
Collaborator

@KagemniKarimu KagemniKarimu commented Oct 30, 2025

Building upon #49, this PR adds 18 integration tests for bearer token authentication middleware and significantly hardens API security.

Mainly, the PR does two distinct things:

  1. Adds comprehensive auth tests (18 tests covering bearer token validation)
  2. Hardens security by removing internal POST endpoints that could allow external DB writes

Changes

  • Security Improvement: Removes internal POST endpoints (/bundle, /cid, /balance, /nonce, /vault/*). As @pemulis pointed out, this allowed external services with the API bearer token to write directly to the node's database (Big no no!). Only /intention remains as a public POST endpoint. Internal operations (bundle creation, balance updates, vault management) continue to work as direct function calls.
  • Testing: Comprehensive auth tests verify bearer token validation, endpoint protection, edge cases, and stateless authentication behavior.
  • Test Infrastructure: Creates shared test fixtures (testFixtures.ts) with addresses, endpoints, and sample data for reuse across test suites, reducing duplication. This can be gradually incorporated into other tests in separate PRs.

- Test addresses, vault IDs, and endpoint lists
- Centralized test data for reuse across test suites
- 18 tests covering bearer token validation
- Tests for all POST/GET endpoint protection
- Edge cases and stateless auth verification
- Reduced from 38 to 18 tests via consolidation
@KagemniKarimu KagemniKarimu changed the title Add auth tests 🔐 Add auth tests Oct 30, 2025
- Remove POST routes for /bundle, /cid, /balance, /nonce, /vault
- Only /intention remains as public POST endpoint
- Internal operations (bundle creation, balance updates, etc.) still work via direct function calls
- Prevents external services from writing to node database via HTTP
- Reduces attack surface while maintaining functionality
@KagemniKarimu KagemniKarimu changed the title 🔐 Add auth tests 🔐 Add auth tests & harden API security Oct 30, 2025
@KagemniKarimu KagemniKarimu marked this pull request as ready for review October 30, 2025 04:32
@pemulis pemulis merged commit f9ee836 into oyaprotocol:main Oct 30, 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.

3 participants