gpt4 book ai didi

security - Silex Security success_handler

转载 作者:行者123 更新时间:2023-12-01 10:00:13 26 4
gpt4 key购买 nike

如何为表单例份验证提供程序设置 success_handler(和 failure_handler)?

Silex 使用此配置忽略我:

<?php

use WebFactory\Security\UserProvider;

$app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'dev' => array(
'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
'security' => false
),
'default' => array(
'pattern' => '^/.*$',
'anonymous' => true,
'form' => array(
'login_path' => '/login',
'check_path' => '/login_check',
'success_handler' => 'authentication_handler', //<-- here
'failure_handler' => 'authentication_handler', //<-- here
),
'logout' => array('logout_path' => '/logout'),
'users' => $app->share(function () use ($app) {
return new UserProvider($app['db']);
}),
),
),
'security.access_rules' => array(
array('^/login', 'IS_AUTHENTICATED_ANONYMOUSLY'),
array('^/private$', 'ROLE_ADMIN'),
),
'security.role_hierarchy' => array(
'ROLE_SIMPLE_USER' => array('ROLE_USER'),
'ROLE_ASSOCIATE' => array('ROLE_USER'),
)
));

这是我的习惯(从未调用过)

$app['authentication_handler'] = $app->share(function ($app) {
return new \WebFactory\Security\AuthenticationHandler($app['url_generator']);
});

这是一个错误?

最佳答案

设置成功和失败处理程序的方法是定义一个名为 security.authentication.success_handler.$namesecurity.authentication.failure_handler.$name 的服务,其中$name 是防火墙的名称。

例如:

$app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'foo' => ...,
),
));

$app['security.authentication.success_handler.foo'] = $app->share(function ($app) {
return new Your\Own\SuccessHandler();
});

然后安全服务提供商将按照约定检测处理程序。

关于security - Silex Security success_handler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17282223/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com