feat: Massive refactor of LDAP Gateway Server#85
Conversation
horner
commented
Oct 24, 2025
- Added package.json for server configuration and dependencies.
- Implemented authentication and directory provider wrappers for various backends.
- Created main server entry point with environment setup and server initialization.
- Developed authentication service to handle user authentication.
- Established database service for MySQL and MongoDB connections.
- Integrated notification service for authentication requests.
- Implemented utility functions for LDAP entry creation and logging.
- Added interactive setup utility for server configuration.
- Included graceful shutdown handling for server resources.
- Developed MongoDB script for initial user and group data insertion.
- Implemented password hashing utility.
- Resolved LDAP host addresses dynamically based on environment configuration.
- Added package.json for server configuration and dependencies. - Implemented authentication and directory provider wrappers for various backends. - Created main server entry point with environment setup and server initialization. - Developed authentication service to handle user authentication. - Established database service for MySQL and MongoDB connections. - Integrated notification service for authentication requests. - Implemented utility functions for LDAP entry creation and logging. - Added interactive setup utility for server configuration. - Included graceful shutdown handling for server resources. - Developed MongoDB script for initial user and group data insertion. - Implemented password hashing utility. - Resolved LDAP host addresses dynamically based on environment configuration.
Fix unstable UIDs in Proxmox backend causing home directory ownership issues
Fixes/watcher for users
Added auto-reload feature to README.
|
Here is the actionable refactor checklist toward: reusable npm core + standalone server + nfpm packaging. High-Level Phases [ ] Phase 2: Core module scaffold (@ldap-gateway/core) [ ] Phase 3: Adapt existing server into server/ package [ ] Phase 4: Resolve path + runtime concerns [ ] Phase 5: Stabilize Core API [ ] Phase 6: Packaging (binary) [ ] Phase 7: nfpm packaging [ ] Phase 8: Homebrew (later) [ ] Phase 9: CI workflow [ ] Phase 10: Cleanup & Docs Quality / Guardrails Optional Enhancements |
Feature Branch: Modular Architecture v1.0Branch: 🎯 ObjectiveTransform LDAP Gateway from monolithic to modular architecture with reusable core package and multiple distribution methods. ✅ Completed PhasesPhase 1-2: Foundation
Phase 3-4: Server Refactor
Phase 5: Core API Stabilization
Phase 6-7: Packaging
Phase 8: Distribution
Phase 9: CI/CD
Phase 10: Documentation
📦 New Structure🚀 Key FeaturesFor Package Usersconst { LdapEngine } = require('@ldap-gateway/core');
// Embed LDAP server in your appFor Server Operators# Install package
sudo dpkg -i ldap-gateway_amd64.deb
sudo systemctl start ldap-gatewayFor Developersnpm install
npm run build:all
npm test🔄 Migration Pathv0.x → v1.0:
📊 Test Coverage
🎯 Next Steps
📝 Notes
🔗 Related Documents
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a massive architectural refactor that transforms the LDAP Gateway from a monolithic server into a modular system with a reusable npm core package and standalone server implementation. The refactor separates concerns between authentication/directory providers while adding comprehensive distribution support (binary releases, .deb/.rpm packages, Homebrew formula).
Key changes:
- Introduced modular architecture with
@ldap-gateway/corenpm package andldap-gateway-serverstandalone implementation - Added provider pattern with pluggable authentication and directory backends
- Implemented comprehensive CI/CD pipeline with automated builds and releases
- Created distribution packages for multiple platforms
Reviewed Changes
Copilot reviewed 57 out of 92 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Workspace root configuration coordinating npm and server packages |
| npm/ | New core package with reusable LDAP engine, provider interfaces, and utilities |
| server/ | Standalone server implementation using core package with concrete providers |
| .github/workflows/ | CI/CD automation for building, testing, and releasing |
| nfpm/ | Linux package configuration for .deb/.rpm with systemd integration |
| homebrew/ | Homebrew formula for macOS installation |
| .attic/ | Archived legacy monolithic implementation |
| README.md | Comprehensive documentation for new architecture |
| MIGRATION.md | Guide for migrating from v0.x to v1.x |
Files not reviewed (1)
- server/package-lock.json: Language not supported
…lar-architecture-v1
Implement plugin-style backend architecture allowing custom auth and directory providers to be loaded from JavaScript files without rebuilding. Core Changes: - Add BackendLoader utility to scan and load backends from server/backends/ - Enhance ProviderFactory with dynamic backend support and fallback logic - Update serverMain.js to initialize dynamic loading at startup - Add comprehensive validation for backend interfaces Documentation & Examples: - Create detailed backend development guide (README.md) - Add template.js with auth and directory skeletons - Provide working examples: API auth and JSON file directory - Add QUICKSTART.md with Redis backend tutorial - Include IMPLEMENTATION.md documenting the complete feature Testing: - Add comprehensive test suite (12 test cases) - Cover valid/invalid backend loading - Test file filtering and fallback behavior - Verify options passing to constructors Key Features: - Drop JS files in server/backends/ to add custom backends - Automatic validation of required methods - Graceful fallback to compiled backends - Support for BACKEND_DIR environment variable - Full backward compatibility Files Changed: - server/utils/backendLoader.js (new, 230 lines) - server/providers.js (enhanced, +40 lines) - server/serverMain.js (updated initialization) - server/backends/ (new directory with 5 files, ~900 lines) - server/test/backendLoader.test.js (new, 250 lines) - README.md (added custom backends section) - .github/copilot-instructions.md (updated patterns)
…atterns - Add NotificationAuthProvider for MFA wrapper pattern - Move certificate logic to ConfigurationLoader - Remove duplicate LDAP server code from serverMain.js - Clean up LdapEngine by removing notification coupling - Delete authService.js (absorbed into provider architecture) - Centralize all environment variable access in config loader Establishes proper separation of concerns and clean abstraction boundaries.
…and updating build commands
- Replace generic 'db' backend with database-specific implementations - Add mysql.auth.js and mysql.directory.js for MySQL-specific operations - Add mongodb.auth.js and mongodb.directory.js for MongoDB-specific operations - Remove legacy DatabaseService and dbConfig.js dependencies - Fix database schema: use gid_number instead of gid for LDAP compatibility - Update MySQL init.sql and MongoDB init-mongo.js with correct schema - Update mysql.js driver to return gid_number for proper LDAP mapping - Add MongoDB test setup scripts and documentation - Update .env.example and setupUtils.js for new backend options BREAKING CHANGE: Legacy 'db' backend removed. Use 'mysql' or 'mongodb' instead. Fixes SSSD 'no gid provided' errors by ensuring proper gidNumber attributes.
runleveldev
left a comment
There was a problem hiding this comment.
Looks good to me, let's get an ldap-dev server in the opensource.mieweb.org cluster going to QA the changes before merging.
There was a problem hiding this comment.
Ran acceptance tests against the staging server in the opensource cluster. Results follow:
- Logins work
- sudo works
- ldap filters
- no filter (shows all users and groups as expected)
- (uid=)
- (objectClass=posixGroup)
- (objectClass=inetOrgPerson)
- (&(objectClass=posixGroup)(cn=proxmox-sudo)) (failed - still shows all groups)
runleveldev
left a comment
There was a problem hiding this comment.
On logging in to QA the changes, my account appears to have lost it's group membership. This breaks SUDO failing acceptance test 2:
rgingras@rgingras-sssd-testing:~$ sudo -i
[sudo] password for rgingras:
rgingras is not in the sudoers file.
This incident has been reported to the administrator.
rgingras@rgingras-sssd-testing:~$ groups
groups: cannot find name for group ID 61907
61907
Related #87 |
runleveldev
left a comment
There was a problem hiding this comment.
Good enough to merge. I'll file the other problems I have as issues after we have a real test suite (#88).