Skip to content

Commit b10327f

Browse files
committed
refactor: remove known limitations regarding JWT-only authentication from documentation and tests
1 parent d50d3a5 commit b10327f

File tree

4 files changed

+1
-96
lines changed

4 files changed

+1
-96
lines changed

docs/AUTHENTICATION.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -699,28 +699,6 @@ curl -v http://localhost:3000/api/data
699699
curl -v http://localhost:3000/public/data
700700
```
701701

702-
## Known Limitations
703-
704-
### JWT-Only Authentication Issue
705-
706-
⚠️ **Current Issue**: JWT-only authentication (without `apiKeys` configured) has validation issues. Tokens may be rejected even when correctly signed.
707-
708-
**Workaround**: Use API key authentication for reliable service-to-service communication:
709-
710-
```typescript
711-
// ❌ JWT-only (has issues)
712-
auth: {
713-
secret: 'my-secret',
714-
jwtOptions: { algorithms: ['HS256'] },
715-
}
716-
717-
// ✅ API key (works reliably)
718-
auth: {
719-
apiKeys: ['service-key-1', 'service-key-2'],
720-
apiKeyHeader: 'X-API-Key',
721-
}
722-
```
723-
724702
## Troubleshooting
725703

726704
### 401 Unauthorized with Valid API Key

docs/TROUBLESHOOTING.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,7 @@ curl -v -H "Authorization: Bearer key1" http://localhost:3000/api/data
6464

6565
### JWT Validation Fails
6666

67-
**Known Limitation**: JWT-only authentication (without `apiKeys`) has validation issues.
68-
69-
**Workaround**: Use API key authentication:
70-
71-
```typescript
72-
// ❌ JWT-only (has issues)
73-
auth: {
74-
secret: 'my-secret',
75-
jwtOptions: { algorithms: ['HS256'] },
76-
}
77-
78-
// ✅ Use API keys instead (reliable)
79-
auth: {
80-
apiKeys: ['service-key-1', 'service-key-2'],
81-
apiKeyHeader: 'X-API-Key',
82-
}
83-
```
67+
### Mixed Authentication
8468

8569
**If you must use JWT**, check:
8670

examples/README.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ Production-ready security-hardened gateway with comprehensive security features.
4949
- API key authentication for public/metrics endpoints
5050
- Multiple authentication strategies
5151

52-
**⚠️ Known Limitation:** JWT-only authentication (without API keys) currently has validation issues. The example uses API keys which work reliably.
53-
5452
**Run:**
5553

5654
```bash
@@ -328,48 +326,6 @@ gateway.addRoute({
328326

329327
---
330328

331-
## ⚠️ Known Limitations
332-
333-
### JWT-Only Authentication
334-
335-
**Issue:** JWT-only authentication (configuring `secret` without `apiKeys`) currently has token validation issues. Tokens may be rejected with "Invalid token" even when correctly signed.
336-
337-
**Workaround:** Use API key authentication, which works reliably:
338-
339-
```typescript
340-
// ❌ JWT-only (has issues)
341-
auth: {
342-
secret: process.env.JWT_SECRET,
343-
jwtOptions: {
344-
algorithms: ['HS256'],
345-
},
346-
}
347-
348-
// ✅ API key auth (works)
349-
auth: {
350-
apiKeys: ['key1', 'key2'],
351-
apiKeyHeader: 'X-API-Key',
352-
}
353-
```
354-
355-
**Status:** This issue is being investigated. See [test/gateway/gateway-auth.test.ts](../test/gateway/gateway-auth.test.ts) for test coverage.
356-
357-
### Hybrid Authentication
358-
359-
When both JWT (`secret`) and API keys (`apiKeys`) are configured together, the API key becomes **required**. JWT alone will not work.
360-
361-
```typescript
362-
// API key is REQUIRED when both are configured
363-
auth: {
364-
secret: process.env.JWT_SECRET,
365-
jwtOptions: { algorithms: ['HS256'] },
366-
apiKeys: ['key1'], // API key must be provided
367-
apiKeyHeader: 'X-API-Key',
368-
}
369-
```
370-
371-
---
372-
373329
## 📚 More Resources
374330

375331
- [Main README](../README.md) - Full documentation

test/gateway/gateway-auth.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,6 @@ async function createJWTWithWrongSecret(
5959
.sign(wrongSecret)
6060
}
6161

62-
/**
63-
* KNOWN LIMITATION: JWT-only authentication (without apiKeys) currently doesn't work.
64-
* When a route is configured with JWT auth but no API keys, token validation fails
65-
* with "Invalid token" even when the token is correctly signed and structured.
66-
*
67-
* This appears to be an issue with how JWT options are passed to the 0http-bun middleware
68-
* or how the middleware validates tokens. API key authentication works correctly, and
69-
* hybrid auth (JWT + API key) works when API key is provided.
70-
*
71-
* Tests marked with .skip are temporarily disabled until this issue is resolved.
72-
* See: GitHub issue #TBD
73-
*/
74-
7562
describe('BunGateway Authentication', () => {
7663
let gateway: BunGateway
7764
let backendServer: any

0 commit comments

Comments
 (0)