经过身份验证的 LDAP 密码未存储在 fos_user 数据库中
Authenticated LDAP password not being stored in fos_user database
我有一个注册并配置了 FOSUserBundle 和 FR3DLdapBundle 的 Symfony 项目,但是当我针对测试 LDAP 服务器进行身份验证时,身份验证有效,但是当我查看 dev.log 时,Doctrine 插入语句没有密码(为空)。
这是我的 config.yml 文件的底部:
fr3d_ldap:
driver:
host: ldap.forumsys.com
user:
baseDn: dc=example, dc=com
attributes:
- { ldap_attr: uid, user_method: setUsername }
- { ldap_attr: mail, user_method: setEmail }
- { ldap_attr: userPassword, user_method: setPassword }
filter: (&(ObjectClass=person))
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AppBundle\Entity\User
我使用这个在线 LDAP 服务器来验证:http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
这是我的用户 class:
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser implements LdapUserInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $dn;
public function __construct()
{
parent::__construct();
if (empty($this->roles)) {
$this->roles[] = 'ROLE_USER';
}
}
/**
* {@inheritDoc}
*/
public function setDn($dn)
{
$this->dn = $dn;
}
/**
* {@inheritDoc}
*/
public function getDn()
{
return $this->dn;
}
}
主要问题发生在我使用 "gauss" 和密码 "password" 登录时,dev.log 显示如下:
[2016-03-11 20:51:40] ldap_driver.DEBUG: {action}({base_dn}, {filter}, {attributes}) {"action":"ldap_search","base_dn":"dc=example, dc=com","filter":"(&(&(ObjectClass=person))(uid=gauss))","attributes":[]} []
[2016-03-11 20:51:41] security.INFO: User {username} {result} on LDAP {"action":"loadUserByUsername","username":"gauss","result":"found"} []
[2016-03-11 20:51:41] ldap_driver.DEBUG: {action}({bind_rdn}, ****) {"action":"ldap_bind","bind_rdn":"uid=gauss,dc=example,dc=com"} []
[2016-03-11 20:51:41] security.INFO: User has been authenticated successfully. {"username":"gauss"} []
[2016-03-11 20:51:41] doctrine.DEBUG: "START TRANSACTION" [] []
[2016-03-11 20:51:41] doctrine.DEBUG: INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) {"1":"gauss","2":"gauss","3":"gauss@ldap.forumsys.com","4":"gauss@ldap.forumsys.com","5":true,"6":"6amuldowmz0oo0ww00wwwgo0k408sc","7":"","8":"2016-03-11 20:51:41","9":false,"10":false,"11":null,"12":null,"13":null,"14":["ROLE_USER"],"15":false,"16":null} []
[2016-03-11 20:51:41] doctrine.DEBUG: "COMMIT" [] []
请注意密码为空。我希望能够获取密码(即使它来自表单)并将其存储在数据库中。我想知道怎么做。
感谢任何help/suggestions。
如果您使用 LDAP 进行身份验证,则无需保留密码。
我有一个注册并配置了 FOSUserBundle 和 FR3DLdapBundle 的 Symfony 项目,但是当我针对测试 LDAP 服务器进行身份验证时,身份验证有效,但是当我查看 dev.log 时,Doctrine 插入语句没有密码(为空)。
这是我的 config.yml 文件的底部:
fr3d_ldap:
driver:
host: ldap.forumsys.com
user:
baseDn: dc=example, dc=com
attributes:
- { ldap_attr: uid, user_method: setUsername }
- { ldap_attr: mail, user_method: setEmail }
- { ldap_attr: userPassword, user_method: setPassword }
filter: (&(ObjectClass=person))
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AppBundle\Entity\User
我使用这个在线 LDAP 服务器来验证:http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
这是我的用户 class:
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser implements LdapUserInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $dn;
public function __construct()
{
parent::__construct();
if (empty($this->roles)) {
$this->roles[] = 'ROLE_USER';
}
}
/**
* {@inheritDoc}
*/
public function setDn($dn)
{
$this->dn = $dn;
}
/**
* {@inheritDoc}
*/
public function getDn()
{
return $this->dn;
}
}
主要问题发生在我使用 "gauss" 和密码 "password" 登录时,dev.log 显示如下:
[2016-03-11 20:51:40] ldap_driver.DEBUG: {action}({base_dn}, {filter}, {attributes}) {"action":"ldap_search","base_dn":"dc=example, dc=com","filter":"(&(&(ObjectClass=person))(uid=gauss))","attributes":[]} []
[2016-03-11 20:51:41] security.INFO: User {username} {result} on LDAP {"action":"loadUserByUsername","username":"gauss","result":"found"} []
[2016-03-11 20:51:41] ldap_driver.DEBUG: {action}({bind_rdn}, ****) {"action":"ldap_bind","bind_rdn":"uid=gauss,dc=example,dc=com"} []
[2016-03-11 20:51:41] security.INFO: User has been authenticated successfully. {"username":"gauss"} []
[2016-03-11 20:51:41] doctrine.DEBUG: "START TRANSACTION" [] []
[2016-03-11 20:51:41] doctrine.DEBUG: INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) {"1":"gauss","2":"gauss","3":"gauss@ldap.forumsys.com","4":"gauss@ldap.forumsys.com","5":true,"6":"6amuldowmz0oo0ww00wwwgo0k408sc","7":"","8":"2016-03-11 20:51:41","9":false,"10":false,"11":null,"12":null,"13":null,"14":["ROLE_USER"],"15":false,"16":null} []
[2016-03-11 20:51:41] doctrine.DEBUG: "COMMIT" [] []
请注意密码为空。我希望能够获取密码(即使它来自表单)并将其存储在数据库中。我想知道怎么做。
感谢任何help/suggestions。
如果您使用 LDAP 进行身份验证,则无需保留密码。