1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(virtsecrets): a secret in use is not deleted, and a password is stored as typed

- A secret is in use when a VM names it in a disk, a host device or its
  vTPM, or a pool in its source, by UUID or by its usage within the usage
  type, as they run and as saved. The vTPM, host devices and pools' saved
  definitions were not checked before.
- A Ceph key is taken in base64, as `ceph auth get-key` prints it; any other
  value is a password or passphrase stored as typed, spaces included.
- A new secret takes its value at once; a value refused leaves no secret.
- TLS and vTPM secrets can be created; the usage has no length limit.
- Every POST redirects; the list is read once and only with its users; a
  secret, VM or pool gone meanwhile is left out.
- domain_trees() is shared by the in-use checks of secrets, network filters,
  networks and pools; the storage page's Ceph secret picker reads the same
  listing.
This commit is contained in:
catborise 2026-10-29 09:29:20 +03:00
parent 2c99dae701
commit 1850d2de8e
17 changed files with 429 additions and 249 deletions

View file

@ -15,24 +15,6 @@
</div>
<form method="post" action="" role="form" aria-label="Create Secret form">{% csrf_token %}
<div class="modal-body">
<div class="row">
<label for="secret_ephemeral" class="col-sm-3 col-form-label">{% trans "Ephemeral" %}</label>
<div class="col-sm-6">
<select id="secret_ephemeral" name="ephemeral" class="form-control">
<option value="no">{% trans "no" %}</option>
<option value="yes">{% trans "yes" %}</option>
</select>
</div>
</div>
<div class="row">
<label for="secret_private" class="col-sm-3 col-form-label">{% trans "Private" %}</label>
<div class="col-sm-6">
<select id="secret_private" name="private" class="form-control">
<option value="no">{% trans "no" %}</option>
<option value="yes">{% trans "yes" %}</option>
</select>
</div>
</div>
<div class="row">
<label for="secret_usage_type" class="col-sm-3 col-form-label">{% trans "Usage" %}</label>
<div class="col-sm-6">
@ -44,11 +26,25 @@
</div>
</div>
<div class="row">
<label for="secret_data" class="col-sm-3 col-form-label">{% trans "Data" %}</label>
<label for="secret_usage" class="col-sm-3 col-form-label">{% trans "Data" %}</label>
<div class="col-sm-6">
<input id="secret_data" type="text" name="data" class="form-control" value="" maxlength="100" required />
<input id="secret_usage" type="text" name="usage" class="form-control" required>
</div>
</div>
<div class="row">
<label for="secret_value" class="col-sm-3 col-form-label">{% trans "Value" %}</label>
<div class="col-sm-6">
<input id="secret_value" type="password" name="value" class="form-control" autocomplete="new-password">
</div>
</div>
<div class="form-check">
<input id="secret_ephemeral" type="checkbox" name="ephemeral" class="form-check-input">
<label for="secret_ephemeral" class="form-check-label">{% trans "Ephemeral" %}</label>
</div>
<div class="form-check">
<input id="secret_private" type="checkbox" name="private" class="form-check-input">
<label for="secret_private" class="form-check-label">{% trans "Private" %}</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Close" %}</button>

View file

@ -41,8 +41,8 @@
{% for secret in secrets_all %}
<tr>
<th scope="row">{{ secret.uuid }}</th>
<td>{{ secret.usageType }}</td>
<td>{{ secret.usage|default_if_none:"" }}</td>
<td>{{ secret.usage_type }}</td>
<td>{{ secret.usage }}</td>
<td>
<form action="" method="post" role="form" aria-label="Delete secret form">{% csrf_token %}
<input type="hidden" name="uuid" value="{{ secret.uuid }}"/>
@ -69,7 +69,7 @@
<label class="col-sm-3 col-form-label" for="secret_value_{{ secret.uuid }}">{% trans "Value" %}</label>
<input type="hidden" name="uuid" value="{{ secret.uuid }}">
<div class="col-sm-6">
<input type="password" id="secret_value_{{ secret.uuid }}" name="value" class="form-control" autocomplete="new-password" required pattern="[A-Za-z0-9+\/]*={0,2}">
<input type="password" id="secret_value_{{ secret.uuid }}" name="value" class="form-control" autocomplete="new-password" required>
</div>
</div>
</div> <!-- /.modal-content -->