mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(accounts): an SSH key is a whole key, and added once
The profile took an SSH key whose blob only named its type
("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5") or was cut short, and offered it
for a VM, where it lets no one in. A key is now parsed whole with
cryptography (which paramiko already brings), security keys
(sk-ssh-ed25519) included.
The same key with another comment was added a second time, and
deleting one left the other to be installed. Keys are now compared by
their type and key, without the comment.
This commit is contained in:
parent
2ab1bac0c7
commit
f18be7c33e
4 changed files with 47 additions and 35 deletions
|
|
@ -71,8 +71,9 @@ class UserSSHKeyForm(ModelForm):
|
|||
return self.cleaned_data["keyname"]
|
||||
|
||||
def clean_keypublic(self):
|
||||
# the same key with another comment is the same key
|
||||
for key in self.publickeys:
|
||||
if self.cleaned_data["keypublic"] == key.keypublic:
|
||||
if self.cleaned_data["keypublic"].split()[:2] == key.keypublic.split()[:2]:
|
||||
raise ValidationError(_("Public key already exist"))
|
||||
|
||||
if not validate_ssh_key(self.cleaned_data["keypublic"]):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue