使用 Symfony 框架在生产服务器上登录失败的用户(由于...,无法处理身份验证请求)
2022-08-30 20:43:02
我正在使用Symfony进行项目,并且我一直在尝试使登录名在生产服务器上工作,但在过去的2天中没有成功。我不断收到错误
由于系统问题,无法处理身份验证请求。
我已按照此处的指南(http://symfony.com/doc/current/cookbook/security/entity_provider.html)设置从数据库加载用户。
My security.yml file:
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
Acceptme\UserBundle\Entity\User: plaintext
role_hierarchy:
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
in_memory:
memory:
users:
patricia:
password: patricia
roles: 'ROLE_ADMIN'
users:
name: user_provider
entity: { class: AcceptmeUserBundle:User, property: username }
firewalls:
user_area:
pattern: ^/
anonymous: ~
provider: user_provider
form_login:
login_path: login_route
check_path: _login_check
default_target_path: homepage
dev:
pattern: ^/(_(profiler|wdt|error)|css|images|js)/
security: false
default:
anonymous: ~
http_basic: ~
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
我的安全控制器.php:
namespace AppBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Security\Core\SecurityContext;
class SecurityController extends Controller
{
/**
* @Route("/login", name="login_route")
* @Template("security/login.html.twig")
*/
public function loginAction(Request $request)
{
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
return array(
'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
'error' => $error,
);
}
/**
* @Route("/login_check", name="_login_check")
*/
public function securityCheckAction()
{
// this controller will not be executed,
// as the route is handled by the Security system
}
}
我尝试在2个不同的Web主机(FatCow和GoDaddy)上上传该项目,问题仍然存在。在本地,我使用的是PHP 5.4.19(FatCow使用5.3.2,GoDaddy使用5.4.37)。请记住,当使用XAMPP在本地主机上工作时,一切正常!
我已确认在这两种情况下都启用了PDO。我已确认数据库用户名,密码和主机在参数.yml文件中是正确的。本地和远程服务器上的错误日志均不显示任何内容。
我已经遵循了上一篇文章的所有指示 部署Symfony2应用程序 获得 fosuserbundle 错误,但仍然没有成功。