From 5dd6178f7fb756a2ace5850c72f1bec2352c8650 Mon Sep 17 00:00:00 2001 From: Martin Rademacher Date: Tue, 26 May 2015 11:01:52 +1200 Subject: [PATCH] Update Readme.md --- Readme.md | 73 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/Readme.md b/Readme.md index b394d90..c30dd24 100644 --- a/Readme.md +++ b/Readme.md @@ -4,15 +4,58 @@ A Silex Ldap authentication service provider [![Build Status](https://travis-ci.org/DerManoMann/ldap-auth-service-provider.png)](https://travis-ci.org/DerManoMann/ldap-auth-service-provider) [![Coverage Status](https://coveralls.io/repos/DerManoMann/ldap-auth-service-provider/badge.png)](https://coveralls.io/r/DerManoMann/ldap-auth-service-provider) - This service provider provides Ldap based authentication and authorization. -Requies Silex 2.0. - -## Features - -TODO - +## Basic Usage + +```php + // register service with name ldap + $ldapAuth = 'ldap'; + $app->register(new LdapAuthenticationServiceProvider($ldapAuth)); + + // configure firewalls + $app->register(new SecurityServiceProvider(), array( + 'security.firewalls' => array( + 'login' => array( + 'pattern' => '^/login$', + ), + 'default' => array( + 'pattern' => '^.*$', + 'anonymous' => true, + $ldapAuth => array( + // form options + 'check_path' => '/login_check_ldap', + 'require_previous_session' => false, + // auth options + 'auth' => array( + 'entryPoint' => 'form', + ), + // ldap options + 'ldap' => array( + 'host' => 'localhost', + 'username' => 'username-for-initial-bind', + 'password' => 'xxx', + + ), + ), + 'users' => function () use ($app, $ldapAuth) { + return new LdapUserProvider( + $ldapAuth, + $app['security.ldap.default.ldap'], + $app['logger'], + array( + 'roles' => array( + 'CN=Development,OU=Groups,DC=radebatz,DC=net' => 'ROLE_USER', + 'CN=Admins,OU=Groups,DC=radebatz,DC=net' => 'ROLE_ADMIN', + ), + 'baseDn' => 'DC=radebatz,DC=net', + ) + ); + }, + ), + ), + +``` ## Installation @@ -29,18 +72,18 @@ run the `php composer.phar install` command to install it: Alternatively, you can download the [`ldap-auth-service-provider.zip`][1] file and extract it. -## Usage +### Configuring Ldap +The Ldap related code depends on [`zend-ldap`](https://github.com/zendframework/zend-ldap), so all configuration options are just passed through. +For more details check the [`zend-ldap docs`](http://framework.zend.com/manual/current/en/index.html#zend-ldap). -### Register per firewall -$app->register(new LdapAuthenticationServiceProvider(), $options); +### Custom user class +The LdapUserProvider class allows to configure a custom User class to be used. Only restriction is that the custom class has a constructor that is compatible with the default class `Symfony\\Component\\Security\\Core\\User\\User`. -### Configuring Ldap --> link to zend ldap docs -### Custom user class --> constructor compatible with sf security User class -TODO +## Requirements +- Silex 2.0 +- PHP 5.5 ## License