Skip to content

LDAP Authentication

crocodilestick edited this page Sep 25, 2025 · 1 revision

LDAP Authentication Configuration πŸ”

LDAP Banner

Calibre-Web Automated supports LDAP (Lightweight Directory Access Protocol) authentication, enabling seamless integration with enterprise directories like Active Directory, OpenLDAP, and other LDAP-compliant systems. This guide covers everything you need to know about configuring and using LDAP authentication in CWA.


🌟 Features Overview

CWA's LDAP implementation provides enterprise-grade authentication with the following features:

  • βœ… Auto-User Creation: Automatically creates user accounts on first LDAP login (default: enabled)
  • βœ… Default Permissions: New LDAP users inherit all default configuration settings
  • βœ… Seamless Integration: Works with Active Directory, OpenLDAP, and LDAP-compliant systems
  • βœ… API/OPDS Support: LDAP authentication works for API and OPDS access
  • βœ… Enterprise Ready: Designed for corporate environments with centralized authentication
  • βœ… Fallback Support: Can be combined with standard username/password authentication
  • βœ… Comprehensive Logging: Detailed authentication logs for troubleshooting and auditing

πŸš€ Quick Setup Guide

Step 1: Access LDAP Settings

  1. Log in as an Admin user
  2. Navigate to Admin Panel β†’ Basic Configuration
  3. Scroll down to the LDAP Settings section

Step 2: Basic LDAP Configuration

Configure your LDAP server connection:

LDAP Server: ldap://your-ldap-server.com:389
LDAP Encryption: None (or SSL/TLS as required)
LDAP Base DN: dc=company,dc=com
LDAP User Object Filter: (&(objectClass=user)(sAMAccountName=%s))
LDAP Authentication: Simple Bind

Step 3: Enable Auto-Creation (Recommended)

βœ… Enable "Auto-create users from LDAP" (enabled by default)

This allows LDAP users to automatically get accounts created on their first successful login, providing a seamless user experience.

Step 4: Test and Save

  1. Test Configuration: Use a test LDAP user to verify connectivity
  2. Save Configuration: Click Submit to apply settings
  3. Restart CWA: Some LDAP changes may require a restart

🎯 LDAP User Auto-Creation

How Auto-Creation Works

When Auto-create users from LDAP is enabled (default):

  1. First Login: User authenticates successfully against LDAP server
  2. User Lookup: CWA checks if user account already exists
  3. Auto-Creation: If not found, creates new user with default settings
  4. Immediate Access: User is logged in automatically without manual account creation

Default Settings Applied to New LDAP Users

New LDAP users automatically inherit all default configuration settings:

  • πŸ“Š Default Role: Configured role permissions
  • πŸ“‹ Sidebar View: Default sidebar visibility settings
  • 🌍 Locale: Default interface language
  • πŸ“š Default Language: Default book language filter
  • 🏷️ Tag Restrictions: Default allowed/denied tags
  • πŸ“– Content Restrictions: Default column restrictions
  • 🎨 Theme: Default CWA theme setting
  • πŸ“± Kobo Sync: Default Kobo integration settings

This ensures LDAP users get the same permissions and interface settings as manually created users.


βš™οΈ Detailed Configuration

LDAP Server Connection

Setting Description Example
LDAP Server LDAP server hostname/IP and port ldap://dc.company.com:389
LDAP Encryption Security level (None/SSL/TLS) None (internal network) or SSL/TLS (external)
LDAP Base DN Base Distinguished Name for searches dc=company,dc=com

Authentication Configuration

Setting Description Example
LDAP User Object Filter LDAP query to find user objects (&(objectClass=user)(sAMAccountName=%s))
LDAP Authentication Authentication method Simple Bind (most common)
LDAP Admin Username Admin DN for LDAP binding (if required) cn=admin,dc=company,dc=com
LDAP Admin Password Password for admin binding [admin-password]

Auto-Creation Settings

Setting Description Default
Auto-create users from LDAP Enable automatic user creation βœ… Enabled

🏒 Provider-Specific Examples

Microsoft Active Directory

LDAP Server: ldap://dc.company.com:389
LDAP Encryption: None (or SSL for external access)
LDAP Base DN: dc=company,dc=com
LDAP User Object Filter: (&(objectClass=user)(sAMAccountName=%s))
LDAP Authentication: Simple Bind
Auto-create users from LDAP: βœ… Enabled

Login Format: Users log in with their Active Directory username (e.g., john.doe)

OpenLDAP

LDAP Server: ldap://openldap.company.com:389
LDAP Encryption: None (or TLS for security)
LDAP Base DN: ou=people,dc=company,dc=org
LDAP User Object Filter: (&(objectClass=inetOrgPerson)(uid=%s))
LDAP Authentication: Simple Bind
Auto-create users from LDAP: βœ… Enabled

Login Format: Users log in with their UID (e.g., jdoe)

FreeIPA

LDAP Server: ldap://ipa.company.com:389
LDAP Encryption: TLS (recommended)
LDAP Base DN: cn=users,cn=accounts,dc=company,dc=com
LDAP User Object Filter: (&(objectClass=person)(uid=%s))
LDAP Authentication: Simple Bind
Auto-create users from LDAP: βœ… Enabled

πŸ§ͺ Testing & Troubleshooting

Testing LDAP Connection

  1. Configure LDAP settings in the admin panel
  2. Test with known user: Try logging in with an existing LDAP user
  3. Check logs: Review CWA logs for authentication details
  4. Verify auto-creation: Confirm new user appears in user management

Common Issues & Solutions

❌ "LDAP authentication failed"

Cause: Incorrect server configuration or user credentials Solution:

  • Verify LDAP server is accessible from CWA
  • Check LDAP Base DN and User Object Filter
  • Test with LDAP admin tools (ldapsearch, etc.)
  • Verify user exists in LDAP directory

❌ "User not found after LDAP authentication"

Cause: Auto-creation is disabled or failed Solution:

  • Enable Auto-create users from LDAP in admin settings
  • Check CWA logs for user creation errors
  • Verify default user settings are configured
  • Ensure database is writable

❌ LDAP users can't access books/features

Cause: Default permissions not properly configured Solution:

  • Configure default role and permissions in Admin β†’ Basic Configuration β†’ Feature Configuration
  • Auto-created LDAP users inherit these default settings
  • Manually adjust individual user permissions as needed

❌ "LDAP server connection timeout"

Cause: Network connectivity or firewall issues Solution:

  • Verify LDAP server is reachable from CWA container
  • Check firewall rules for LDAP ports (389/636)
  • Test connectivity with tools like telnet or nc

Debug Logging

Enable debug logging to troubleshoot LDAP issues:

  1. Set log level to Debug in admin panel
  2. Check container logs for detailed LDAP authentication flow
  3. Look for LDAP binding and search operations
  4. Review user creation process details

πŸ”’ Security Best Practices

Network Security

  • Use TLS/SSL for LDAP connections when possible
  • Restrict network access to LDAP servers using firewall rules
  • Use dedicated service accounts for LDAP binding when required
  • Monitor authentication logs for suspicious activity

Account Security

  • Review default permissions to ensure appropriate access levels
  • Regularly audit auto-created accounts
  • Implement account cleanup for terminated employees
  • Use least-privilege principles for default role configuration

LDAP Server Security

  • Keep LDAP servers updated with security patches
  • Use strong authentication methods when available
  • Monitor LDAP server logs for authentication attempts
  • Implement account lockout policies on LDAP server

πŸ”„ Authentication Mode Integration

Combining LDAP with Other Authentication Methods

LDAP authentication can be used alongside other authentication methods:

  • Standard Authentication: Users can still log in with CWA passwords
  • OAuth Integration: Combine LDAP with OAuth providers
  • Reverse Proxy: Use LDAP with reverse proxy authentication

Migration Scenarios

From Standard to LDAP Authentication

  1. Configure LDAP settings with auto-creation enabled
  2. Test with pilot users to verify configuration
  3. Communicate changes to all users
  4. Gradually migrate users to LDAP authentication
  5. Maintain standard auth as fallback during transition

User Account Linking

When switching to LDAP:

  • Existing users keep passwords: They can still use standard login
  • LDAP users auto-created: New accounts created for LDAP users
  • Manual linking: Admin can manually link LDAP users to existing accounts if needed

πŸ“Š API and OPDS Integration

LDAP Authentication for API Access

LDAP users can authenticate for API and OPDS access:

  1. OPDS Feeds: Use LDAP credentials for OPDS authentication
  2. API Endpoints: LDAP authentication works for REST API access
  3. Auto-Creation: API/OPDS access also triggers auto-creation
  4. Consistent Experience: Same authentication across web and API

Usage Examples

OPDS Authentication:

URL: https://your-cwa.com/opds
Username: [LDAP username]
Password: [LDAP password]

API Authentication:

curl -u "ldap-user:ldap-password" https://your-cwa.com/api/v1/books

πŸ› οΈ Advanced Configuration

Custom User Object Filters

Customize LDAP queries for specific directory structures:

Directory Type Recommended Filter
Active Directory (&(objectClass=user)(sAMAccountName=%s))
OpenLDAP (&(objectClass=inetOrgPerson)(uid=%s))
FreeIPA (&(objectClass=person)(uid=%s))
Custom Adjust based on your LDAP schema

Performance Optimization

For large LDAP directories:

  • Use specific Base DNs to limit search scope
  • Optimize user object filters for faster queries
  • Consider LDAP indexing on frequently queried attributes
  • Monitor LDAP server performance during peak usage

πŸ“ Changelog & Updates

Recent Enhancements (v3.2+)

  • βœ… Auto-User Creation: Automatic account creation for LDAP users (enabled by default)
  • βœ… Default Permissions Inheritance: LDAP users inherit all default configuration settings
  • βœ… Enhanced API Support: LDAP authentication for OPDS and API access with auto-creation
  • βœ… Improved Error Handling: Better error messages and logging for LDAP issues
  • βœ… Security Enhancements: Input validation and protection against LDAP injection
  • βœ… Enterprise Integration: Optimized for corporate environment requirements

Future Planned Features

  • πŸ”„ Group-based Role Assignment: Automatic role assignment based on LDAP group membership
  • πŸ”„ User Attribute Synchronization: Sync user details from LDAP directory
  • πŸ”„ Advanced Group Mapping: Support for multiple roles beyond admin/user
  • πŸ”„ LDAP Schema Validation: Automatic detection and validation of LDAP schemas

πŸ†˜ Support & Resources

Getting Help

  1. Check Logs: Enable debug logging and review container logs
  2. Test Configuration: Verify LDAP server connectivity and settings
  3. Community Support: Join our Discord for help
  4. GitHub Issues: Report bugs or request features on GitHub

Useful Resources

LDAP Testing Tools

  • ldapsearch: Command-line LDAP search utility
  • Apache Directory Studio: GUI LDAP browser and editor
  • JXplorer: Cross-platform LDAP browser
  • LDAP Admin: Windows LDAP administration tool

This documentation covers CWA's enhanced LDAP authentication implementation. For additional help, please visit our Discord community or check the GitHub repository.

Clone this wiki locally