经过身份验证的LDAP密码未存储在fos_user数据库中

时间:2016-03-12 16:00:18

标签: symfony fosuserbundle fr3dldapbundle

我有一个注册和配置了FOSUserBundle和FR3DLdapBundle的Symfony项目,但是当我对测试LDAP服务器进行身份验证时,验证工作正常,但是当我查看dev.log时,Doctrine插入语句没有密码(它& #39;空白)。

这是我的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/

这是我的用户类:

/**
 * @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"登录时出现主要问题。密码为"密码",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" [] []

请注意密码为空。我希望能够获取密码(即使它来自表单)并将其存储在数据库中。我想知道怎么做。

感谢任何帮助/建议。

1 个答案:

答案 0 :(得分:1)

如果您使用LDAP进行身份验证,则无需保留密码。