问题标签 [symfony-guard]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1135 浏览

symfony - 使用 yaml 配置 symfony3

我正在使用 Guard 作为新的身份验证系统。我注册了一个这样的新服务:

并抛出异常:

任何人都可以想象为什么?

谢谢和问候!

0 投票
0 回答
1502 浏览

symfony - Symfony - 保护身份验证

我正在我的 symfony 应用程序中实现一个带保护的登录系统。

我已经设置了系统,但是我犯了一个错误,因此我无法登录...

要点:

我的用户实体实现了“AdvancedUserInterface,\Serializable”,它提供了电子邮件属性而不是用户名属性。此外,我将“getUsername”函数更改为:

安全性.yml:

服务.yml:

login.html.twig:

登录控制器(部分):

最后是我的 FormAuthentificator:

当我输入我的有效凭据时,我得到:

我也尝试过使用其他凭据,但总是同样的错误。

有人可以帮我解决这个问题吗?

谢谢和问候!

0 投票
1 回答
1577 浏览

php - Symfony's Guard start() function not working

I'm new to Symfony and I'm learning how to use Guard to authenticate users. Currently using Symfony 2.8.4.

You can check all my code below, it's mostly from various tutorials I found online.

It seems the start() function from the FormLoginAuthenticator class isn't properly detecting if credentials were sent or not. If I visit any page like /login, /homepage, /login_check, etc.. I get the same return on all of them:

Here's my FormLoginAuthenticator.php:

Here's my SecurityController.php:

The security.yml file:

And finally the services.yml file:

0 投票
2 回答
737 浏览

php - Symfony2 保护非活动会话生命周期

如果用户会话在 X 秒内处于非活动状态,我会尝试使用户会话过期。我找到了很多解决方案来做到这一点,但不是针对非活动会话。

我使用 Symfony2 和 Guard Authentification。我已经实现了这个解决方案,这似乎还不错。但是即使用户处于活动状态,会话也会过期。我可能想念一些东西。使用 Guard 是否有任何特殊性会影响会话时间?

我的身份验证器

我的会话处理程序:

服务.yml

配置.yml

parameters.yml我有这个:sessionLifeTime: 0

我也找到了这个选项,但它可以解决我的问题吗?

0 投票
1 回答
478 浏览

symfony - 带有语言环境的 symfony 安全卫士不工作

所以我在控制器中有这个:

这在安全方面:

在参数中,语言环境是这样的:

在守卫重定向的功能是:

接下来是场景,左边是路径,右边是正在发生的事情:

在我登录而不是保留语言环境 ro 后,我被重定向到 en,如果我尝试访问 /en/welcome 登录,我将被重定向到 /?_locale=en(显示 ro 翻译,因此不起作用)而不是 /en

有谁知道为什么会这样?

0 投票
1 回答
1137 浏览

symfony - Symfony3 Guard 和登录表单

我尝试使用 Guard 来制作登录表单,而不是 security.yml 方式。

Getuser 和 checkcredential 都可以。
onAuthenticationSuccess 没问题(如果我输入dump($token); die;onAuthenticationSuccess 我可以在令牌中看到我的用户)并重定向到 /accueil。
但是当它到达 /accueil 时,它会发送回 /login 因为用户身份验证始终处于匿名状态!

无法找到解决方案:c/

security.yml 中的防火墙:

安全控制器

登录验证器:

0 投票
1 回答
1340 浏览

symfony - symfony3 守卫登录表单未通过身份验证

我尝试使用警卫(symfony 3.2)进行表单登录身份验证,但它不起作用。身份验证正在工作,但是当我被重定向到主页(accueil)时,我被重定向到登录页面而没有进行身份验证。
如果我把我的主页的控制器

我可以看到我的用户、角色,但他没有经过身份验证。

我错过了什么?

安全.ym

测试验证器.php

仪表板控制器.php

编辑:
感谢 leo_ap 的帮助,但问题并非来自那里。
配置会话是这样的:

如果我签入保存路径文件夹,我创建了会话文件但未经过身份验证。

如果我使用 security.yml 尝试正常的 login_form,它工作正常......
我尝试使用 handler_id 和 save_path 为 null,但没有成功。

EDIT2:
我找到了为什么我总是被重定向到登录页面,因为我已经注销了!

并在 GuardAuthenticationProvider.php (86)

但为什么 ???

0 投票
0 回答
1106 浏览

php - Symfony Guard Authenticator 自定义注销功能

我是 Symfony 的新手,我正在学习如何使用 Guard 对用户进行身份验证。目前使用 Symfony 3.2。我关注了创建您的第一个 Symfony 应用程序并添加了身份验证教程,这对我有很大帮助,但在我的应用程序中,我必须将一些自定义数据添加到会话中,我不知道如何在重定向到 logoutAction() 函数后将其从会话中删除。感谢您的任何建议。

0 投票
1 回答
349 浏览

php - 带保护的 Silex 自定义身份验证

我尝试按照Silex 官方网站上的教程进行操作,但是当 Authenticator 注册为服务时出现错误。

Catchable fatal error: Argument 1 passed to App\Security\TokenAuthenticator::__construct() must be an instance of App\Security\EncoderFactoryInterface, instance of Symfony\Component\Security\Core\Encoder\EncoderFactory given, called in C:\wamp\www\api\src\app.php on line 41 and defined in C:\wamp\www\api\src\App\Security\TokenAuthenticator.php on line 17

这是我的 app.php

TokenAuthenticator示例相同。如何使用实现的参数配置此服务App\Security\EncoderFactoryInterface?你能帮我吗 ?

0 投票
1 回答
52 浏览

twig - 在 symfony 2 的 Guard Authenticator 中调用 twigswiftmailer

我使用警卫作为我的自定义身份验证器,我需要在身份验证器中发送一封电子邮件,使用我注入的服务 fos_user.mailer,其中有参数,其中有树枝,因为它呈现它需要发送的消息,现在问题我有是我收到一个错误“检测到服务的循环引用......”,这表示我的身份验证器调用邮件程序,该邮件程序调用了再次调用授权检查器(我的身份验证器)的树枝,导致无限循环,你有什么解决方案为了这