Skip to content

A dockerized web application that provides a simple, intuitive interface for managing OpenLDAP users. This project offers a robust solution for LDAP user administration

Notifications You must be signed in to change notification settings

leachandryan/php-laravel-ldap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel OpenLDAP Integration Demo

⚠️ DEMO PURPOSES ONLY: This project is a demonstration, not intended for production use. It intentionally omits some security features (like TLS) to simplify local testing and learning.

This project demonstrates the integration between Laravel and OpenLDAP, providing a web interface for managing LDAP users. The application allows you to create, list, and delete users while organizing them into admin and guest groups.

Demo Simplifications

For ease of learning and local testing, this demo intentionally:

  • Disables TLS/SSL encryption
  • Uses default credentials
  • Exposes ports locally
  • Lacks user authentication
  • Uses basic Docker configurations

These simplifications make it easier to understand the core concepts but would need to be addressed for any production deployment.

Project Structure

php-ldap/
├── open-ldap/              # OpenLDAP Docker setup
│   ├── docker-compose.yaml
│   └── ldap/              # LDAP data directories
│       ├── config/
│       └── data/
└── laravel-ldap/          # Laravel application
    ├── app/
    ├── resources/
    └── ...

Prerequisites

  • Docker and Docker Compose (v2.0+)
  • PHP 8.2+
  • Composer
  • Git

Dependencies

OpenLDAP Server

  • osixia/openldap:1.5.0
  • osixia/phpldapadmin:0.9.0

Laravel Application

  • PHP ^8.2
  • Laravel Framework ^11.31
  • directorytree/ldaprecord-laravel ^3.3
  • Other dependencies as specified in composer.json

Installation

  1. Clone the repository:
git clone <repository-url>
cd php-ldap
  1. Start the OpenLDAP server:
cd open-ldap
docker-compose up -d
  1. Set up the Laravel application:
cd ../laravel-ldap
composer install
cp .env.example .env
php artisan key:generate
  1. Configure Laravel's .env file with LDAP settings:
LDAP_HOST=localhost
LDAP_USERNAME="cn=admin,dc=example,dc=org"
LDAP_PASSWORD=admin123
LDAP_PORT=389
LDAP_BASE_DN="dc=example,dc=org"
LDAP_TIMEOUT=5
  1. Start the Laravel development server:
php artisan serve

Usage

Accessing the Applications

Managing Users

  1. Creating a User

    • Navigate to http://localhost:8000/create-user
    • Fill in the required information:
      • Username (must be unique)
      • First Name
      • Last Name
      • Email
      • Password (must meet security requirements)
      • UID (unique number between 1000-65534)
      • Role (admin or guest)
  2. Listing Users

  3. Deleting Users

    • On the list users page
    • Click the "Delete" button next to a user
    • Confirm the deletion when prompted

Initial LDAP Structure

The LDAP server is configured with the following structure:

dc=example,dc=org
└── ou=users
    ├── cn=admins
    └── cn=guests

Troubleshooting

  1. If you can't connect to LDAP:

    • Ensure the OpenLDAP container is running: docker ps
    • Check LDAP logs: docker logs openldap
    • Verify Laravel's .env LDAP configuration
  2. If user creation fails:

    • Ensure unique UID and username
    • Check LDAP server logs for detailed error messages
    • Verify LDAP connection settings

Production Considerations

If you plan to adapt this demo for production use, you would need to:

  1. Security Measures:

    • Enable and properly configure TLS/SSL
    • Change all default passwords
    • Implement proper access controls and user authentication
    • Use secure LDAP configurations
    • Add input validation and sanitization
    • Implement proper error handling
  2. Infrastructure:

    • Use proper Docker configurations with volumes
    • Set up proper networking and firewalls
    • Implement monitoring and logging
    • Configure backups
    • Set up high availability if needed
  3. Application:

    • Add user session management
    • Implement proper access control lists
    • Add audit logging
    • Implement proper error handling
    • Add proper validation and security headers

License

This project is open-sourced software licensed under the MIT license.

About

A dockerized web application that provides a simple, intuitive interface for managing OpenLDAP users. This project offers a robust solution for LDAP user administration

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published