mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-03 21:54:07 +09:00
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:
1 parent
5979a6bfb0
commit
8821d50cff
122 files changed
+326
-110
No files matched your search
@@ -26,6 +26,7 @@
|
||||
<h4>{{ 'Edit client group'|trans }} - {{ group.title }}</h4>
|
||||
</div>
|
||||
<form method="post" action="{{ 'api/admin/client/group_update'|link }}" class="api-form" data-api-redirect="{{ 'client'|alink }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<div class="card-body">
|
||||
<div class="mb-3 row">
|
||||
<label class="form-label col-3 col-form-label">{{ 'Title'|trans }}:</label>
|
||||
@@ -46,7 +47,7 @@
|
||||
</a>
|
||||
<button class="btn btn-primary w-100" type="submit">{{ 'Update'|trans }}</button>
|
||||
<a class="btn btn-danger w-25 api-link"
|
||||
href="{{ 'api/admin/client/group_delete'|link({ 'id': group.id }) }}"
|
||||
href="{{ 'api/admin/client/group_delete'|link({ 'id': group.id, 'CSRFToken': CSRFToken }) }}"
|
||||
data-api-confirm="{{ 'Are you sure?'|trans }}"
|
||||
data-api-redirect="{{ 'client'|alink }}">
|
||||
<svg class="icon">
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<h5>{{ 'Filter clients'|trans }}</h5>
|
||||
|
||||
<form method="get">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<div class="form-group mb-3 row">
|
||||
<label class="form-label col-3 col-form-label">{{ 'ID'|trans }}</label>
|
||||
<div class="col">
|
||||
@@ -242,7 +243,7 @@
|
||||
<use xlink:href="#edit" />
|
||||
</svg>
|
||||
</a>
|
||||
<a class="btn btn-icon api-link" href="{{ 'api/admin/client/delete'|link({ 'id': client.id }) }}" data-api-confirm="{{ 'Are you sure?'|trans }}" data-api-reload="1">
|
||||
<a class="btn btn-icon api-link" href="{{ 'api/admin/client/delete'|link({ 'id': client.id, 'CSRFToken': CSRFToken }) }}" data-api-confirm="{{ 'Are you sure?'|trans }}" data-api-reload="1">
|
||||
<svg class="icon">
|
||||
<use xlink:href="#delete" />
|
||||
</svg>
|
||||
@@ -267,6 +268,7 @@
|
||||
<div class="tab-pane fade" id="tab-new" role="tabpanel">
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ 'api/admin/client/create'|link }}" class="api-form save" data-api-redirect="{{ 'client'|alink }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<div class="form-group mb-3 row">
|
||||
<label class="form-label col-3 col-form-label">{{ 'Status'|trans }}:</label>
|
||||
<div class="col">
|
||||
@@ -397,7 +399,7 @@
|
||||
<use xlink:href="#edit" />
|
||||
</svg>
|
||||
</a>
|
||||
<a class="btn btn-icon api-link" href="{{ 'api/admin/client/group_delete'|link({ 'id': id }) }}" data-api-reload="1" data-api-confirm="{{ 'Are you sure?'|trans }}">
|
||||
<a class="btn btn-icon api-link" href="{{ 'api/admin/client/group_delete'|link({ 'id': id, 'CSRFToken': CSRFToken }) }}" data-api-reload="1" data-api-confirm="{{ 'Are you sure?'|trans }}">
|
||||
<svg class="icon">
|
||||
<use xlink:href="#delete" />
|
||||
</svg>
|
||||
@@ -416,6 +418,7 @@
|
||||
<div class="tab-pane fade" id="tab-new-group" role="tabpanel">
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ 'api/admin/client/group_create'|link }}" class="api-form" data-api-redirect="{{ 'client'|alink }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<div class="form-group mb-3 row">
|
||||
<label class="form-label col-3 col-form-label">{{ 'Title'|trans }}:</label>
|
||||
<div class="col">
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<td>{{ event.created_at|date('Y-m-d H:i') }}</td>
|
||||
<td>
|
||||
<a class="btn btn-icon api-link"
|
||||
href="{{ 'api/admin/client/login_history_delete'|link({ 'id': event.id }) }}"
|
||||
href="{{ 'api/admin/client/login_history_delete'|link({ 'id': event.id, 'CSRFToken': CSRFToken }) }}"
|
||||
data-api-confirm="{{ 'Are you sure?'|trans }}"
|
||||
data-api-redirect="{{ 'client/logins'|alink }}">
|
||||
<svg class="icon">
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
<span class="d-block text-secondary">{{ 'Login to client area'|trans }}</span>
|
||||
</a>
|
||||
<a class="d-inline-block mx-1 btn bg-light bg-gradient api-link"
|
||||
href="{{ 'api/admin/client/delete'|link({ 'id': client.id }) }}"
|
||||
href="{{ 'api/admin/client/delete'|link({ 'id': client.id, 'CSRFToken': CSRFToken }) }}"
|
||||
data-api-confirm="{{ 'Are you sure?'|trans }}"
|
||||
data-api-redirect="{{ 'client'|alink }}">
|
||||
<svg class="mb-2 text-secondary" width="24" height="24">
|
||||
@@ -159,6 +159,7 @@
|
||||
<div class="card-body">
|
||||
<h5>{{ 'Client profile details'|trans }}</h5>
|
||||
<form method="post" action="{{ 'api/admin/client/update'|link }}" class="api-form save" data-api-msg="{{ 'Client Profile updated'|trans }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<div class="mb-3 row">
|
||||
<label class="form-label col-3 col-form-label">{{ 'Status'|trans }}:</label>
|
||||
<div class="col">
|
||||
@@ -360,6 +361,7 @@
|
||||
|
||||
<h5>{{ 'Change password'|trans }}</h5>
|
||||
<form method="post" action="{{ 'api/admin/client/change_password'|link }}" class="api-form" data-api-msg="{{ 'Password changed'|trans }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<div class="form-group mb-3 row">
|
||||
<label class="form-label col-3 col-form-label">{{ 'Password'|trans }}</label>
|
||||
<div class="col">
|
||||
@@ -382,6 +384,7 @@
|
||||
<h5>{{ 'Custom fields'|trans }}</h5>
|
||||
<p class="text-muted">{{ 'Use these fields to define custom client details'|trans }}</p>
|
||||
<form method="post" action="{{ 'api/admin/client/update'|link }}" class="api-form save" data-api-msg="{{ 'Client Profile custom fields updated'|trans }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
{% for i in 1..10 %}
|
||||
{% set fn = 'custom_' ~ i %}
|
||||
<div class="form-group mb-3 row">
|
||||
@@ -527,7 +530,7 @@
|
||||
|
||||
<div class="card-body">
|
||||
<a class="btn btn-primary api-link"
|
||||
href="{{ 'api/admin/invoice/prepare'|link({ 'client_id': client.id }) }}"
|
||||
href="{{ 'api/admin/invoice/prepare'|link({ 'client_id': client.id, 'CSRFToken': CSRFToken }) }}"
|
||||
data-api-jsonp="onAfterInvoicePrepared">
|
||||
<svg class="icon">
|
||||
<use xlink:href="#plus" />
|
||||
@@ -626,7 +629,7 @@
|
||||
<td>{{ tx.created_at|date("Y-m-d H:i") }}</td>
|
||||
<td>
|
||||
<a class="btn btn-icon api-link"
|
||||
href="{{ 'api/admin/client/balance_delete'|link({ 'id': tx.id }) }}"
|
||||
href="{{ 'api/admin/client/balance_delete'|link({ 'id': tx.id, 'CSRFToken': CSRFToken }) }}"
|
||||
data-api-confirm="{{ 'Are you sure?'|trans }}">
|
||||
<svg class="icon">
|
||||
<use xlink:href="#delete" />
|
||||
@@ -650,6 +653,7 @@
|
||||
method="post"
|
||||
action="{{ 'api/admin/client/balance_add_funds'|link }}"
|
||||
data-api-msg="{{ 'Funds added'|trans }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<div class="form-group mb-3 row">
|
||||
<label class="form-label col-3 col-form-label" for="inputAmount">{{ 'Amount'|trans }}:</label>
|
||||
<div class="col input-group">
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
{% set params = admin.extension_config_get({ 'ext': 'mod_client' }) %}
|
||||
<div class="card">
|
||||
<form method="post" action="{{ 'api/admin/extension/config_save'|link }}" class="api-form" data-api-msg="{{ 'Configuration updated'|trans }}">
|
||||
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link active" href="#tab-index" data-bs-toggle="tab">{{ 'General'|trans }}</a>
|
||||
|
||||
Reference in new issue
Block a user