Conversation
| headers, | ||
| CONFIG.BASE_URL, | ||
| !localConfig["ignore-certificate-errors"], | ||
| ); |
There was a problem hiding this comment.
JWT TLS override uses wrong config source
Medium Severity
authenticateRequest() passes !localConfig["ignore-certificate-errors"] to validateJWT() instead of the resolved ignoreCertificateErrors value. This bypasses environment overrides from IGNORE_CERTIFICATE_ERRORS, so JWT key retrieval can run with a different TLS verification policy than the rest of the server.
|
@ldjebran @TamiTakamiya @goneri @mabashian this is a draft to make this MCP a drop-in replacement for the python version for ALIA. No need to merge this PR, this is just a PoC. |
9dda07a to
1918bec
Compare
Implements JWT token validation to match the Python ansible-mcp-tools implementation. The server now supports dual authentication: - Primary: JWT authentication via X-DAB-JW-TOKEN header - Fallback: Bearer token authentication via Authorization header Key features: - JWT signature validation using RS256 algorithm - Public key caching (10 minute TTL) for performance - Claims validation (audience, issuer, expiration) - Username extraction from user_data claim - Seamless fallback to existing Bearer token auth New files: - src/jwt-validator.ts: Core JWT validation module - src/__tests__/jwt-validator.test.ts: Unit tests - JWT_AUTHENTICATION.md: Comprehensive documentation - IMPLEMENTATION_SUMMARY.md: Implementation overview Dependencies added: - jsonwebtoken: JWT validation library - node-cache: Public key caching - @types/jsonwebtoken: TypeScript types All tests passing (223/223). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1918bec to
a40f111
Compare
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
ldjebran
left a comment
There was a problem hiding this comment.
I am not sure this implementation will work, I can see only validation , but the JWT should work with target services directly not via gateway , I do not see this changes in this PR.


Summary
This PR implements JWT authentication support for the AAP MCP Server, matching the functionality of the Python
ansible-mcp-toolsimplementation.Changes
New Features
X-DAB-JW-TOKENheaderFiles Added
src/jwt-validator.ts- Core JWT validation module (188 lines)src/__tests__/jwt-validator.test.ts- Comprehensive unit testsJWT_AUTHENTICATION.md- Complete documentation and usage guideIMPLEMENTATION_SUMMARY.md- Implementation overview and summaryFiles Modified
src/index.ts- Integrated JWT authentication with newauthenticateRequest()functionpackage.json- Added JWT dependenciespackage-lock.json- Updated with new dependenciesDependencies Added
jsonwebtoken(^9.0.2) - JWT token validationnode-cache(^5.1.2) - Public key caching@types/jsonwebtoken(^9.0.5) - TypeScript type definitionsAuthentication Flow
Testing
Configuration
The JWT validator respects existing configuration:
ignore-certificate-errors: Controls SSL verificationSecurity
ansible-services, issuer:ansible-issuer)Documentation
Complete documentation provided:
Compatibility
ansible-mcp-toolsimplementationX-DAB-JW-TOKEN)🤖 Generated with Claude Code
Note
Medium Risk
Touches authentication/session initialization and adds new token verification logic plus network key-fetching and caching, which could impact login reliability or security if misconfigured.
Overview
Adds JWT authentication as the primary session-init mechanism, validating the
X-DAB-JW-TOKENheader by fetching the AAP Gateway RSA public key (cached) and verifying RS256 claims, then falling back to the existingAuthorization: Bearer ...flow when JWT auth is unavailable or fails.Introduces a new
src/jwt-validator.tsmodule plus unit tests, and wires the newauthenticateRequest()flow intosrc/index.tssession initialization; addsjsonwebtokenandnode-cachedependencies and ships accompanying documentation (JWT_AUTHENTICATION.md,IMPLEMENTATION_SUMMARY.md).Written by Cursor Bugbot for commit 155cca3. This will update automatically on new commits. Configure here.