我嘗試使用Symfony(3.0.1)提供的LDAP組件在我的Silex(1.3.5)應用程序中配置LDAP身份驗證。 這裏是我當前的配置:使用Silex和Symfony 3配置LDAP身份驗證
$app['ldap'] = function() {
return new Symfony\Component\Ldap\LdapClient('ldap.example.com');
};
$app->register(new SecurityServiceProvider(), [
'security.providers' => [
'users' => [
'ldap' => [
'service' => 'ldap',
'base_dn' => 'dc=example,dc=com',
'search_dn' => 'CN={username},OU=DEV,DC=example,DC=com',
],
],
],
'security.firewalls' => [
'stats' => [
'pattern' => '^/',
'provider' => 'users',
'http' => true,
'stateless' => true,
'http_basic_ldap' => [
'service' => 'ldap',
'dn_string' => '{username}@example.com',
],
],
],
]);
但是根據上述的結構,我得到以下異常:
Fatal error: Uncaught exception 'LogicException' with message 'The "provider" authentication entry is not registered.' in /var/www/my-site/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php:243 Stack trace: #0 /var/www/my-site/vendor/pimple/pimple/lib/Pimple.php(126): Silex\Provider\SecurityServiceProvider->Silex\Provider{closure}(Object(Silex\Application)) #1 /var/www/my-site/vendor/pimple/pimple/lib/Pimple.php(83): Silex\Application::{closure}(Object(Silex\Application)) #2 /var/www/my-site/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php(150): Pimple->offsetGet('security.firewa...') #3 /var/www/my-site/vendor/pimple/pimple/lib/Pimple.php(126): Silex\Provider\SecurityServiceProvider->Silex\Provider{closure}(Object(Silex\Application)) #4 /var/www/my-site/vendor/pimple/pimple/lib/Pimple.php(83): Silex\Application::{closure}(Object(Silex\Application)) #5 /var/www/my-site/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php(584): in /var/www/my-site/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php on line 243
有什麼做的,使與Silex的LDAP組件的工作?或者我錯過了一些配置?我沒有找到該組件的任何文檔...
謝謝,它現在正在工作。 –