Download the PHP package jmleroy/ldap-bundle without Composer
On this page you can find all versions of the php package jmleroy/ldap-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jmleroy/ldap-bundle
More information about jmleroy/ldap-bundle
Files in jmleroy/ldap-bundle
Package ldap-bundle
Short Description LDAP Bundle for Symfony 3 (backward compatible)
License MIT
Homepage http://github.com/jmleroy/LdapBundle
Informations about the package ldap-bundle
LdapBundle
LdapBundle provides LDAP authentication without using Apache's mod_ldap
. The bundle instead relies on PHP's LDAP extension along with a form to authenticate users. LdapBundle can also be used for authorization by retrieving the user's roles defined in LDAP.
Credits
This Bundle was originally created by Boris Morel and then forked by Subramanya Vajiraya. Since this bundle was discontinued by its original maintainer and probably abandoned by its last forker (last update was from 2017), and since I needed to fix it, I both submitted a pull request and forked it myself. Anyone is free to use this bundle and modify it as they please. I will try to keep this bundle up to date. If you do manage to update the project, please submit a pull request and I would be happy to examine and merge it.
Install
- Download with composer
- Enable the Bundle
- Configure LdapBundle in security.yml
- Import LdapBundle routing
- Implement Logout
- Use chain provider
- Subscribe to PRE_BIND event
- Subscribe to POST_BIND event
Get the Bundle
Composer
Add LdapBundle in your project's composer.json
or
Enable the Bundle
Configure security.yml
Note:
An example
security.yml
file is located within the bundle at./Resources/Docs/security.yml
You should configure the parameters under the imag_ldap
section to match your environment.
Note:
The optional parameters have default values if not set. You can disable default values by setting a parameter to NULL.
Import routing
Implement Login
Just add a hidden tag to the login form with id set as ldap_authenticate
.
Implement Logout
Just create a link with a logout target.
Note:
You can refer to the official Symfony documentation : http://symfony.com/doc/current/book/security.html#logging-out
Chain provider
You can also chain the login form with other providers, such as database_provider, in_memory provider, etc.
Note:
If you have set the config option
bind_username_before: true
you must chain the providers with the ldap provider in the last position.
Subscribe to PRE_BIND event
The PRE_BIND is fired before the user is authenticated via LDAP. Here you can write a listener to perform your own logic before the user is bound/authenticated to LDAP. For example, to add your own roles or do other authentication/authorization checks with your application.
If you want to break the authentication process within your listener, throw an Exception.
Example listener:
Example:
Subscribe to POST_BIND event
The POST_BIND is fired after the user is authenticated via LDAP. You can use it in exactly the same manner as PRE_BIND.
Note:
However each time a page is refreshed, Symfony call the refreshUser method in the provider that is used and doesn't trigger these events (PRE_BIND and POST_BIND). If you want to override user (for example like credentials, roles ...), you must create a new provider and override this method.