implement CSRF protection by adding token generation, validation, and cookie management in login flows

This commit is contained in:
Eduardo Silva
2026-03-16 20:23:18 -03:00
parent ebbffca21d
commit ca63b87123
8 changed files with 214 additions and 24 deletions

View File

@@ -7,6 +7,7 @@
<div class="alert alert-error">{{ error }}</div>
{% endif %}
<form method="post" action="{{ external_path }}/login/password" class="stack">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="next" value="{{ next }}">
<label class="field">
<span>Username</span>

View File

@@ -7,6 +7,7 @@
<div class="alert alert-error">{{ error }}</div>
{% endif %}
<form method="post" action="{{ external_path }}/login/totp" class="stack">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="next" value="{{ next }}">
<label class="field">
<span>Verification code</span>

View File

@@ -41,6 +41,7 @@
</table>
<hr>
<form method="post" action="{{ external_path }}/logout">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="next" value="/">
<button class="btn btn-danger" type="submit">Sign out</button>
</form>