Created a CSRF token system (#526)

* Implement a basic CSRF token system

* Update forms for all modules

* Added to the theme forms

* Create a config option for CSRF prevention

* Slightly rework the filter

* Let's actually use a global var

* Added the token to API hrefs

* Fixup

* Remove old reference

* Added the token to the installer twig globals

* The token isn't actually needed in the installer

* Fix client searching

* Whoops - those need quotes
This commit is contained in:
Belle Aerni authored and GitHub committed 2022-12-06 18:47:14 +01:00
1 parent 5979a6bfb0
commit 8821d50cff
122 files changed
+326 -110

No files matched your search

@@ -48,6 +48,7 @@
<div class="tab-pane fade show active" id="tab-index" role="tabpanel">
<div class="card-body">
<form method="post" action="{{ 'api/admin/system/update_params'|link }}" class="api-form" data-api-msg="{{ 'Company updated'|trans }}">
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
<div class="form-group mb-3 row">
<label class="form-label col-3 col-form-label">{{ 'Name'|trans }}</label>
<div class="col">
@@ -116,6 +117,7 @@
<hr>
<form method="post" action="{{ 'api/admin/system/update_params'|link }}" class="api-form" data-api-msg="{{ 'Company updated'|trans }}">
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
<div class="mb-3">
<h3>{{ 'Company terms of service, legal regulation'|trans }}</h3>
<textarea class="form-control bb-textarea" name="company_tos" rows="5">{{ params.company_tos }}</textarea>
@@ -137,6 +139,7 @@
<div class="tab-pane fade" id="tab-countries" role="tabpanel">
<div class="card-body">
<form method="post" action="{{ 'api/admin/extension/config_save'|link }}" class="api-form" data-api-msg="{{ 'Countries updated'|trans }}">
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
{% set default_countries %}
AF=Afghanistan
AX=Aland Islands
@@ -403,6 +406,7 @@ ZW=Zimbabwe
<p class="text-muted">{{ 'FTP is used to manage FOSSBilling modules and updates.'|trans }}</p>
<form method="post" action="{{ 'api/admin/system/update_params'|link }}" class="api-form" data-api-msg="{{ 'FTP settings updated'|trans }}">
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
<div class="form-group mb-3 row">
<label class="form-label col-3 col-form-label">{{ 'FTP hostname'|trans }}:</label>
<div class="col">
@@ -449,6 +453,7 @@ ZW=Zimbabwe
<h3>{{ 'Cache control'|trans }}</h3>
<form method="post" action="{{ 'api/admin/system/clear_cache'|link }}" class="api-form" data-api-msg="{{ 'Cache folder cleared'|trans }}">
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
<button class="btn btn-danger w-100" type="submit">{{ 'Invalidate cache'|trans }}</button>
</form>
</div>