首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >访问Sulu前端的安全服务:哈希用户密码

访问Sulu前端的安全服务:哈希用户密码
EN

Stack Overflow用户
提问于 2016-01-11 11:24:15
回答 2查看 781关注 0票数 3

我试图为Sulu CMF前端用户注册。我想破解密码。但无论什么原因我都不能得到服务。

代码语言:javascript
复制
You have requested a non-existent service "security.encoder_factory".

代码语言:javascript
复制
You have requested a non-existent service "security.password_encoder"

如果我要求

代码语言:javascript
复制
app/console container:debug | grep encode

这两种服务都有

代码语言:javascript
复制
$ app/console container:debug | grep encode                    
263: security.encoder_factory                                                      Symfony\Component\Security\Core\Encoder\EncoderFactory                                     
266: security.password_encoder                                                     Symfony\Component\Security\Core\Encoder\UserPasswordEncoder                                

你有什么给我的小费吗?我的控制器知道容器,我的代码如下:

代码语言:javascript
复制
$this->container->get('security.password_encoder')

以下是conainer的一些输出:调试

代码语言:javascript
复制
$ app/console container:debug security.password_encoder
[container] Information for service security.password_encoder
Service Id       security.password_encoder
Class            Symfony\Component\Security\Core\Encoder\UserPasswordEncoder
Tags             -
Scope            container
Public           yes
Synthetic        no
Lazy             no
Synchronized     no
Abstract         no


$ app/console container:debug security.encoder_factory 
[container] Information for service security.encoder_factory
Service Id       security.encoder_factory
Class            Symfony\Component\Security\Core\Encoder\EncoderFactory
Tags             -
Scope            container
Public           yes
Synthetic        no
Lazy             no
Synchronized     no
Abstract         no

我目前安装的symfony版本是v2.6.12

sulu提供的命令使用了这种方法。它在开发和prod两种环境中都能工作。

代码语言:javascript
复制
/**
 * Encodes the given password, for the given password, with he given salt and returns the result.
 *
 * @param $user
 * @param $password
 * @param $salt
 *
 * @return mixed
 */
private function encodePassword($user, $password, $salt)
{
    /** @var PasswordEncoderInterface $encoder */
    $encoder = $this->getContainer()->get('security.encoder_factory')->getEncoder($user);

    return $encoder->encodePassword($password, $salt);
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-13 12:21:03

正如xabbuh在评论中所指出的,我们在Sulu有两个不同的内核。如果您使用app/webconsole命令,您将使用该网站的内核。

在标准安装中,我们不包括SecurityBundle,因为它增加了一些开销,对于简单的网站来说是不必要的。然而,如果您正在构建一个更复杂的应用程序,您也可能希望保护您的网站。在本例中,您可以简单地将Symfony\Bundle\SecurityBundle\SecurityBundle的一个新实例添加到app/WebsiteKernel中的$bundles数组。之后,也会有您一直要求的服务。

票数 2
EN

Stack Overflow用户

发布于 2016-01-11 15:02:38

Sulu有一个额外的控制台应用程序,名为app/console网络控制台,它使用不同的内核:-)

我搜索的服务在那里不存在。相反,我可以用

代码语言:javascript
复制
$userManager = $this->container->get('sulu_security.user_manager');
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34720312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档