-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat(auth): implement JWT authentication and user management #6200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
9a38330 to
50ebff9
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
Claude finished @standujar's task —— View job PR Review: JWT Authentication Implementation
|
|
Claude finished @standujar's task —— View job PR Review: JWT Authentication Implementation
|
0xbbjoker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM


Relates to
Risks
Low
ENABLE_DATA_ISOLATION=trueto activate JWT auth modeBackground
What does this PR do?
Implements a complete JWT authentication system for ElizaOS with support for multiple verification strategies:
JWT Verifier Factory - Priority-based verifier selection:
Entity ID derivation from JWT
subclaim:entityId = stringToUuid(payload.sub)subis a standard claimDual authentication modes:
ENABLE_DATA_ISOLATION=true→ JWT authentication requiredENABLE_DATA_ISOLATION=false→ X-Entity-Id header (legacy mode)Internal service bypass - Process-local UUID secret for service-to-service calls
Credentials-based auth endpoints (
/api/auth/*) - only in custom - JWT-SECRET mode:POST /register- User registration with bcrypt password hashingPOST /login- User login with JWT generationPOST /refresh- Token refreshGET /me- Current user info**Client UI default implementation using self mode (Secret)
What kind of change is this?
Features (non-breaking change which adds functionality)
Architecture
Environment Variables
ENABLE_DATA_ISOLATIONtrueJWT_SECRET(optional)your-secret-keyJWT_PUBLIC_KEY_ED25519(optional)MCowBQYDK2Vw...JWT_JWKS_URI(optional)https://auth0.com/.well-known/jwks.jsonJWT_ISSUER_WHITELIST(optional)https://auth0.com/,https://clerk.devDocumentation changes needed?
Yes - Documentation should be added for:
Testing
Where should a reviewer start?
packages/server/src/services/jwt-verifiers/factory.ts- Core factory logicpackages/server/src/middleware/jwtMiddleware.ts- HTTP middlewarepackages/server/src/socketio/index.ts- SocketIO authenticationDetailed testing steps
Unit Tests:
cd packages/server bun run test:unitIntegration Tests:
cd packages/server bun run test:integrationResults: 489 unit tests pass, 6 integration test files pass
Manual Testing
curl http://localhost:3000/api/agents \ -H "Authorization: Bearer <token>"External Provider Compatibility
Tested JWT formats:
sub: "auth0|1234567890"sub: "user_2abcdefgh123456"sub: "1234567890"withemail,email_verifiedsub: "uuid"withrole: "authenticated"sub: "did:privy:..."All providers work because we only require the standard
subclaim.Next Idea Steps: Access Control Layer (ACL)
The next phase will add access control on agents and rooms:
Agents:
Rooms:
Only the owner can:
This will enable true multi-tenant mode where each user manages their resources in isolation.