Skip to content

Commit 7e201d2

Browse files
committed
feature symfony#57 Add CSRF protection for login form (xelaris)
This PR was merged into the master branch. Discussion ---------- Add CSRF protection for login form Commits ------- a95a5f9 Add CSRF protection for login form
2 parents cd2d222 + a95a5f9 commit 7e201d2

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

app/Resources/views/security/login.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<label for="password">Password:</label>
2424
<input type="password" id="password" name="_password" class="form-control" />
2525
</div>
26+
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
2627
<button type="submit" class="btn btn-primary">
2728
<i class="fa fa-sign-in"></i> Sign in
2829
</button>

app/config/security.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ security:
2929
# The name of the route where the login form lives
3030
# When the user tries to access a protected page, they are redirected here
3131
login_path: security_login_form
32+
# Secure the login form against CSRF
33+
# Reference: http://symfony.com/doc/current/cookbook/security/csrf_in_login_form.html
34+
csrf_provider: security.csrf.token_manager
3235

3336
logout:
3437
# The route name the user can go to in order to logout

0 commit comments

Comments
 (0)