OpenMemory Achieves Enterprise-Grade OAuth 2.0 and SSO Authentication
๐ฏ Executive Summary
After an epic multi-session implementation, OpenMemory has been transformed from a basic memory service into a production-ready, enterprise-grade, multi-user system with full OAuth 2.0/OIDC authentication, Single Sign-On (SSO), and automated user provisioning.
๐ What We Built
Full OAuth 2.0/OIDC Infrastructure
We implemented a complete OAuth 2.0 authentication system integrated with Authentik, featuring:
- OAuth Discovery Endpoints - Automatic client configuration
- Dynamic Client Registration (DCR) - Zero manual configuration required
- PKCE Support - Enhanced security for authorization code flow
- JWT Token Validation - Full token verification with public key cryptography
- User Access Control - Email-based authorization with complete isolation
The OAuth Flow Architecture
1
2
3
4
5
6
7
Claude Desktop (MCP Client)
โ OAuth 2.0 Authorization Flow
Authentik (Identity Provider)
โ JWT Access Token
OpenMemory API (Resource Server)
โ Validates Token โ Serves User Memories
Database (Complete User Isolation)
๐ง Technical Achievements
1. SSO with Auto-Provisioning
Users are automatically created in the database on their first SSO login - zero manual setup required. Just log in and start using the system immediately.
2. Smart Authentik Configuration
Instead of managing dozens of static redirect URIs, we use regex patterns to elegantly handle dynamic ports for MCP clients without configuration sprawl.
3. User Isolation and Consistency
- Email is the unique identifier across UI, API, and database
- Complete user isolation - everyone sees only their own data
- No hardcoded values - fully dynamic configuration
4. Professional UI Enhancements
- 14 MCP Client Integrations - Claude, Claude Code, Cursor, Cline, Roo Cline, Windsurf, VS Code, Codex CLI, Gemini CLI, Factory Droid, Witsy, Enconvo, Augment
- Dynamic Install Commands - Real user emails and API URLs (no placeholders!)
- Professional Branding - Custom logos for all clients (no emoji icons!)
- Horizontal Scroll UI - Smooth navigation across all 14 client tabs
5. Custom Install Tooling
We forked and extended the official install-mcp tool to add support for Factory AI Droid CLI, enabling OAuth-protected MCP server installation with a single command. Our fork adds seamless integration while maintaining compatibility with all upstream clients.
๐ The Debugging Journey
We encountered and resolved 8+ critical issues during implementation:
- โ OAuth metadata endpoint failures
- โ Authorization URL routing issues
- โ JWKS configuration problems
- โ Token validation errors
- โ User provisioning race conditions
- โ Session synchronization bugs
- โ Memory visibility issues
- โ Browser caching surprises
curl commands first to verify server-side updates. Browser caching is the #1 reason for "why isn't this working?" moments!
๐ฏ Production-Ready Features
This implementation delivers:
- ๐ Enterprise-grade authentication with OAuth 2.0/OIDC
- ๐ฅ SSO integration via Authentik and NextAuth
- โก Zero-touch provisioning - users created automatically
- ๐ฏ Complete user isolation - data privacy by design
- ๐ง Dynamic configuration - no hardcoded credentials
- ๐ฑ 14 MCP client integrations - professional logos and commands
- ๐ Production deployment ready - error handling, logging, monitoring
๐ MCP Ecosystem Expansion
As part of this work, we also integrated 10+ working MCP servers into our infrastructure:
- Proxmox management
- Kubernetes orchestration
- Nextcloud file operations
- Outline documentation (used to write this post!)
- Splunk analytics
- TriliumNext note-taking
- Grist spreadsheet databases
- AppFlowy project management
๐ Impact and Results
Before
- Basic memory service
- Manual user management
- No authentication
- Single user focus
- Limited client support
After
- Enterprise-grade multi-user platform
- Automatic user provisioning
- Full OAuth 2.0/OIDC authentication
- Complete user isolation
- 14 MCP client integrations
- Production-ready security
- Professional UI with custom branding
๐ฎ Future Enhancements
With this solid authentication foundation, we can now add:
- Role-Based Access Control (RBAC) - Admin, user, and read-only roles
- Team Workspaces - Shared memories for collaboration
- API Rate Limiting - Per-user quotas
- Audit Logging - Track all authentication events
- OAuth Scopes - Fine-grained permission control
๐ Key Takeaways
- Authentication is foundational - Get it right early
- Test incrementally - Catch issues before they compound
- Consistency matters - User IDs must be consistent everywhere
- Regex is powerful - Dynamic URIs beat static configuration
- Professional polish matters - Real logos > emoji icons
๐ Conclusion
This implementation represents a major milestone in OpenMemoryโs evolution. What started as a simple memory service is now a production-ready, enterprise-grade platform with authentication that rivals commercial products.
The combination of OAuth 2.0, SSO, auto-provisioning, complete user isolation, and support for 14+ MCP clients makes OpenMemory suitable for real-world deployment in professional environments.
Technical Stack:
- OpenMemory API (FastAPI)
- Authentik (SSO Provider)
- NextAuth (UI Authentication)
- PyJWT (Token Validation)
- PostgreSQL (User Database)
- Qdrant (Vector Storage)
MCP Integrations:
- 14 Client types supported
- OAuth 2.0 for all MCP connections
- Custom install tooling with Droid support
Status: โ Production Ready
Built with: โค๏ธ and lots of debugging at Oztek Lab