使用Symfony框架的生产服务器用户登录失败(由于...无法处理验证请求) [英] Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

查看:378
本文介绍了使用Symfony框架的生产服务器用户登录失败(由于...无法处理验证请求)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Symfony进行项目,并且我一直试图让登录在生产服务器上工作,而在过去的两天中没有成功。我不断收到错误


由于系统问题,验证请求无法处理。




我已经按照这里的指南( http://symfony.com/doc/current/cookbook/security/entity_provider.html )设置从数据库加载用户。



我的 security.yml 文件:

 安全性:
编码器:
Symfony\Component \Security\Core\User\User:plaintext
Acceptme\UserBundle\Entity\User:plaintext
role_hierarchy:
ROLE_SUPER_ADMIN:[ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH]

提供者:
in_memory:
内存:
用户:
patricia:
密码:patricia
角色:'ROLE_ADMIN'
用户:
name:user_provider
entity:{class:AcceptmeUserBundle:User,property:username}

防火墙:
user_area:
pattern:^ /
匿名:〜
提供者: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

默认值:
anonymous:〜
http_basic: 〜

access_control:
- {path:^ / admin,roles:ROLE_ADMIN}

我的 SecurityController.php:

 命名空间AppBundle\Controller; 

使用Symfony\Component\HttpFoundation\Request;
使用Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
使用Symfony\Bundle\FrameworkBundle\Controller\Controller;
使用Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
使用Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
使用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);
}

返回数组(
'last_username'=> $ request-> getSession() - > get(SecurityContext :: LAST_USERNAME),
' error'=> $ error,
);
}

/ **
* @Route(/ login_check,name =_ login_check)
* /
public function securityCheckAction
{
//该控制器不会执行,
//因为路由由安全系统处理
}
}

我已经尝试在2个不同的网络主机(FatCow& GoDaddy)上载项目,问题依然存在。本地我使用PHP 5.4.19(FatCow使用5.3.2和GoDaddy使用5.4.37)。请记住,当使用XAMPP在localhost上工作时,一切都可以正常运行!



我已经确认在这两种情况下都启用了PDO。我已经确认数据库用户名,密码和主机在 parameters.yml 文件中是正确的。本地和远程服务器上的错误日志都不显示任何内容。



我已经遵循上一篇文章的所有方向部署Symfony2应用程序获取fosuserbundle错误,仍然没有成功。



我感谢所有的帮助提前。

解决方案

更新:问题解决。问题是实体php文件中的表以大写字母命名,而数据库表以小写命名。向ClémentBERTILLON+1,指向正确的方向,即prod.log


I'am using Symfony for a project and I have been trying to get the login to work on production server with no success for the past 2 days. I keep getting the error

Authentication request could not be processed due to a system problem.

I have followed the guide here (http://symfony.com/doc/current/cookbook/security/entity_provider.html) to setup loading users from database.

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 }

My SecurityController.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
}
}

I have tried uploading the project on 2 different web hosts (FatCow & GoDaddy) and the problem remains. Locally i am using PHP 5.4.19 (FatCow uses 5.3.2 and GoDaddy uses 5.4.37). Keep in mind that when working on localhost with XAMPP everything works fine!

I've confirmed that PDO is enabled in both cases. I've confirmed that the database username, password and host are correct in the parameters.yml file. Error logs on both local and remote servers show nothing.

I have followed all directions from this previous post Deploying Symfony2 app getting fosuserbundle errors and still no success.

I appreciate all the help in advance.

解决方案

UPDATE: Issue solved. The issue was that a table in the entity php file was named with upper case letters while the database table was named with lower case. +1 to ClémentBERTILLON for pointing in the right direction, namely prod.log

这篇关于使用Symfony框架的生产服务器用户登录失败(由于...无法处理验证请求)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆