Post

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.

Tip: Want to learn more? Check out the OpenMemory GitHub repository for the open-source project and community resources.

๐Ÿš€ 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
Key Insight: User ID consistency across all layers (UI, API, database, vector storage) is absolutely critical for proper multi-user isolation.

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:

  1. โœ… OAuth metadata endpoint failures
  2. โœ… Authorization URL routing issues
  3. โœ… JWKS configuration problems
  4. โœ… Token validation errors
  5. โœ… User provisioning race conditions
  6. โœ… Session synchronization bugs
  7. โœ… Memory visibility issues
  8. โœ… Browser caching surprises
Pro Tip: Always test with 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
Meta Moment: The Outline MCP integration was used to read our Jekyll deployment docs and programmatically generate this blog post!

๐Ÿ“Š 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

  1. Authentication is foundational - Get it right early
  2. Test incrementally - Catch issues before they compound
  3. Consistency matters - User IDs must be consistent everywhere
  4. Regex is powerful - Dynamic URIs beat static configuration
  5. 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

This post is licensed under CC BY 4.0 by the author.