Download the PHP package svajiraya/ldap-bundle without Composer
On this page you can find all versions of the php package svajiraya/ldap-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download svajiraya/ldap-bundle
More information about svajiraya/ldap-bundle
Files in svajiraya/ldap-bundle
Package ldap-bundle
Short Description LDAP Bundle for Symfony 3.0+
License MIT
Homepage http://github.com/svajiraya/LdapBundle
Informations about the package ldap-bundle
Support
Dropping support for symfony versions < 3.0. Recent patches might not be compatible with versions lower than 3.0 since some of the core methods were deprecated and removed from this package.
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 BorisMorel. Since this bundle is used frequently in almost all our projects, and since the original bundle was not being maintained by anyone we have tried to add our own mods to the project. Anyone is free to use this bundle and modify it as they please. I will try to keep this bundle upto date, but with my busy schedule that may not the case all the time. 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 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.