Skip to content

Commit 247fed7

Browse files
committed
Fixed login CSFR token error
1 parent c834058 commit 247fed7

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

config/packages/framework.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ framework:
2828
#esi: true
2929
#fragments: true
3030

31+
32+
form: { csrf_protection: { token_id: 'submit' } }
33+
csrf_protection:
34+
stateless_token_ids: ['submit', 'authenticate', 'logout']
35+
3136
when@test:
3237
framework:
3338
test: true

config/packages/ux_turbo.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Enable stateless CSRF protection for forms and logins/logouts
2+
framework:
3+
csrf_protection:
4+
check_header: true

symfony.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,13 +748,16 @@
748748
]
749749
},
750750
"symfony/ux-turbo": {
751-
"version": "2.27",
751+
"version": "2.28",
752752
"recipe": {
753753
"repo": "github.com/symfony/recipes",
754754
"branch": "main",
755755
"version": "2.20",
756-
"ref": "e4b951d7de760751e170c6d2e3b565cf9ed5182f"
757-
}
756+
"ref": "287f7c6eb6e9b65e422d34c00795b360a787380b"
757+
},
758+
"files": [
759+
"config/packages/ux_turbo.yaml"
760+
]
758761
},
759762
"symfony/validator": {
760763
"version": "7.3",

templates/security/login.html.twig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
{% block card_content %}
2323
<form action="{{ path('login') }}" method="post" data-turbo="false" class="form-horizontal">
2424

25-
<input type="hidden" name="_csrf_token"
26-
value="{{ csrf_token('authenticate') }}">
25+
<input type="hidden" name="_csrf_token" data-controller="csrf-protection" value="{{ csrf_token('authenticate') }}">
2726

2827
<input type="hidden" name="_target_path" value="{{ app.request.query.get('_target_path') }}" />
2928

@@ -72,4 +71,4 @@
7271
{% if allow_email_pw_reset %}
7372
<a class="offset-sm-2" href="{{ path('pw_reset_request') }}">{% trans %}pw_reset.password_forget{% endtrans %}</a>
7473
{% endif %}
75-
{% endblock %}
74+
{% endblock %}

0 commit comments

Comments
 (0)