UPDATE I never figured out why the below security.yml file didn't work, but I did learn some stuff along the way that might help someone in the future. I don't know if this 100 percent accurate, but it doesn't appear that the login_path and check_path keys work with route names, you need to use the actual paths (e.g. /login). Also the provider key should be at the same level in the yaml as pattern and anonymous, rather than under ldapsecure as shown below.
更新我从来没有弄清楚为什么下面的security.yml文件不起作用,但我确实学到了一些可能在将来帮助某人的方法。我不知道这是否100%准确,但似乎login_path和check_path键不适用于路由名称,您需要使用实际路径(例如/ login)。此外,提供者密钥应该在yaml中与模式和匿名处于同一级别,而不是在ldapsecure下,如下所示。
I'm getting this error when trying to configure a custom authentication provider using Symfony 2.6.
尝试使用Symfony 2.6配置自定义身份验证提供程序时出现此错误。
Unrecognized options "check_path, login_path, provider" under "security.firewalls.secured_area.ldapsecure"
Here's my security.yml
这是我的security.yml
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
ldap_provider:
id: ldap.security.user.provider
firewalls:
login_firewall:
pattern: ^/app/login$
anonymous: ~
secured_area:
pattern: ^/
ldapsecure:
check_path: app_security_login_check
login_path: app_security_login_path
provider: ldap_provider
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
access_control:
- { path: ^/app/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: ROLE_USER }
The ldapsecure "factory" class exists and if I change the getKey() method to return someone else, it breaks differently, so the ldapsecure is being recognized. But I can't see why it's not accepting check_path, login_path or provider. If I change ldapsecure to form_login, I don't get the error, it's just not using my authentication provider.
ldapsecure“factory”类存在,如果我将getKey()方法更改为返回其他人,则会以不同方式中断,因此正在识别ldapsecure。但我不明白为什么它不接受check_path,login_path或provider。如果我将ldapsecure更改为form_login,我没有收到错误,它只是没有使用我的身份验证提供程序。
So I feel like I'm missing something, but don't know where to look at this point.
所以我觉得我错过了什么,但不知道在哪里看这一点。
1 个解决方案
#1
In your ldapsecure
factory change the body of addConfiguration
method to the following:
在ldapsecure工厂中,将addConfiguration方法的主体更改为以下内容:
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('check_path')
->isRequired()
->end()
->scalarNode('login_path')
->isRequired()
->end()
->scalarNode('provider')
->isRequired()
->end()
->end();
}
This should make it work.
这应该使它工作。
#1
In your ldapsecure
factory change the body of addConfiguration
method to the following:
在ldapsecure工厂中,将addConfiguration方法的主体更改为以下内容:
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('check_path')
->isRequired()
->end()
->scalarNode('login_path')
->isRequired()
->end()
->scalarNode('provider')
->isRequired()
->end()
->end();
}
This should make it work.
这应该使它工作。