Skip to content

Commit a95a5f9

Browse files
committed
Add CSRF protection for login form
1 parent 0a1c24f commit a95a5f9

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy