Download the PHP package fschwaiger/laravel-ldap without Composer
On this page you can find all versions of the php package fschwaiger/laravel-ldap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fschwaiger/laravel-ldap
More information about fschwaiger/laravel-ldap
Files in fschwaiger/laravel-ldap
Package laravel-ldap
Short Description Simple LDAP integration for Laravel 5. Comes with file based ACL.
License MIT
Informations about the package laravel-ldap
Simple LDAP Integration for Laravel 5
This module provides a simple user provider for Laravel's auth system that connects to an LDAP server, imports users and groups and then maps the group identifiers to privilege roles in a config file.
This extension is originally written for use in a couple of webservices for Fachschaft Maschinenbau e.V., but is generic enough to be used in a variety of other projects as well. My focus here is to really keep the logic as simple as possible, this is why I stripped all unnecessary properties and methods.
Installation
First, import the package into your laravel project via composer:
Second, copy and paste this line to add its service provider to config/app.php
:
Last, publish the config files and migrations to your project with
php artisan vendor:publish
. This will create the following files:
Integration
To tell Laravel to use this module for providing users, go to config/auth.php
and replace the user provider driver eloquent
for ldap
:
Your App\User
class should then inherit from Fschwaiger\Ldap\User
. The same goes for your group model,
should you choose to extend it. It is up to you to add the Notifiable
trait.
To connect to your directory server, edit the file config/ldap.php
to match
your setup. Simply follow the instructions present in the config file.
Finally, edit your .env
file to include:
If you did not modify the default migration for the users
table, migration
should work out of the box. Else make sure you review the migration changes first.
Once the setup is complete, the following command should import all your user groups.
Importing Users and Groups
With above setup, login should now use the LDAP server instead of the local
database to authenticate users. This imports unknown users on their first successful
login on-the-fly. Note that importing users does NOT import groups automatically!
This means that you need to run ldap:import-users
every time your groups change.
Option A: Import manually after changes with php artisan ldap:import-groups
.
This is good enough for mostly static directory structures. If your groups change
more often, check out Option B.
Option B: Schedule the import in app/Console/Kernel.php
:
Authorize Actions with Group Privileges
The privileges you define in config/privileges.php
are automatically mapped to the
authorization gate, so that you can check for them in all parts of your application.
In code:
Using middleware:
In Blade files: