问题描述
登录Symfony2应用程序时出现以下错误:
I am getting the following error on logging in to a Symfony2 application:
运行:
- Symfony2
- SonataUserBundle
- 无业游民(通过Puphpet.com使用人偶)
- Safari/OSX
相同的设置正在Ubuntu主机系统上运行.
Same setting is Working on an Ubuntu host system.
感谢您的帮助.
security.yml:
security.yml:
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
secured_area:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: fos_user_security_login
check_path: fos_user_security_check
logout:
invalidate_session : false
path: fos_user_security_logout
anonymous: true
switch_user: true
Application/Sonata/UserBundle/Resources/views/Security/login.html.twig
Application/Sonata/UserBundle/Resources/views/Security/login.html.twig
{% extends "FOSUserBundle::layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
{% if error %}
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ error|trans }}
</div>
{% endif %}
<form class="form-horizontal" action="{{ path("fos_user_security_check") }}" method="post">
<fieldset>
<legend>Login</legend>
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
<div class="form-group">
<label class="col-lg-2 control-label required" for="username">{{ 'security.login.username'|trans }}</label>
<div class="col-lg-5">
<input type="text" id="username" name="_username" placeholder="Username" value="{{ last_username }}" required="required" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label required" for="password">{{ 'security.login.password'|trans }}</label>
<div class="col-lg-5">
<input type="password" id="password" name="_password" placeholder="Password" required="required" class="form-control" />
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-5">
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-5">
<a href="{{ path("fos_user_resetting_request") }}">{{ 'resetting.request.submit'|trans }}</a>
<input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans }}" class="btn btn-primary form-control" />
</div>
</div>
</fieldset>
</form>
{% endblock fos_user_content %}
FOSUserBundle和SonataUserBundle的其他所有内容
Anything else is used of the FOSUserBundle and SonataUserBundle
推荐答案
我现在可以解决我的问题.会话保存路径上的写权限似乎是一个问题.如果我更改配置以使用默认会话保存路径,如下所示:
I could solve my problem now. It seems to be a problem with write permissions on the session save path. If I change the configuration to use the default session save path as following:
# app/config/config.yml
framework:
session:
save_path: null
然后使用/var/lib/php/session
代替/var/www/myproject/app/cache/dev/sessions
/var/www/crowdcustoms/app/cache/dev/sessions
上的权限:
drwxr-xr-x 4 501 dialout 136 Jun 29 20:37 sessions/
对/var/lib/php/session
drwxrwxr-x 2 www-data www-data 4096 Jun 29 20:36 session
这篇关于Symfony:身份验证请求失败:无效的CSRF令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!