Allow to use bearer header in all our API #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #14 by implementing Bearer token authentication via
Authorizationheader across all API endpoints in the api-gateway, while maintaining full backward compatibility with query parameter authentication.Fixes #14
🔍 Problem Analysis
Current State
The api-gateway authentication system currently uses:
Authorization: Bearer <token>header?masterToken=<token>query parameterIssues Identified
🛡️ Security Analysis
Why Bearer Tokens in Headers are More Secure
According to OAuth 2.0 RFC 6750 and 2025 security standards:
Query Parameter Risks:
Authorization Header Benefits:
OAuth 2.0 RFC 6750 Quote:
Is This Just Common Practice or Actually More Secure?
Answer: Both. It's a common practice because it's more secure.
📚 Documentation
This PR includes comprehensive documentation:
BEARER_TOKEN_SOLUTION.md - Complete solution with:
IMPLEMENTATION_PLAN.md - Technical implementation details:
🔧 Implementation
Changes in api-gateway
Implementation PR: deep-assistant/api-gateway#4
Service Layer
Added
getMasterTokenFromRequest(req)method toTokensService:Controllers Updated
Updated 10 endpoints across 5 controllers:
tokensController.js(4 endpoints)completionsController.js(1 endpoint)dialogsController.js(1 endpoint)systemMessagesController.js(2 endpoints)referralController.js(2 endpoints)✅ Backward Compatibility
No breaking changes - all existing code continues to work!
Query Parameter (Deprecated but Still Works)
Authorization Header (Recommended)
🔄 Migration Path
For API Consumers (telegram-bot, etc.)
Before:
After:
📅 Timeline
🎯 Benefits
Immediate Benefits
Long-term Benefits
🧪 Testing
Completed
Next Steps (After Merge)
🔗 Related Issues & PRs
📋 Checklist
🤝 Next Actions
🤖 Generated with Claude Code