mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: support multiple SSHPubKey records per user
There was one blazing issue with the previous implementation regardless of the multiple records: we were generating fingerprints by storing the key into a file and reading it with ssh-keygen. This is absolutely terrible and was not meant to be left around (it was forgotten, my bad). Took this opportunity to clean up a few things: - simplify pubkey validation - centralize things a bit better Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
660d57340a
commit
4c14a10b91
11 changed files with 162 additions and 108 deletions
|
@ -107,14 +107,16 @@ def invalid_pgp_key(K: str = str(), **kwargs) -> None:
|
|||
|
||||
def invalid_ssh_pubkey(PK: str = str(), user: models.User = None,
|
||||
_: l10n.Translator = None, **kwargs) -> None:
|
||||
if PK:
|
||||
invalid_exc = ValidationError(["The SSH public key is invalid."])
|
||||
if not util.valid_ssh_pubkey(PK):
|
||||
raise invalid_exc
|
||||
if not PK:
|
||||
return
|
||||
|
||||
fingerprint = get_fingerprint(PK.strip().rstrip())
|
||||
if not fingerprint:
|
||||
raise invalid_exc
|
||||
try:
|
||||
keys = util.parse_ssh_keys(PK.strip())
|
||||
except ValueError as exc:
|
||||
raise ValidationError([str(exc)])
|
||||
|
||||
for prefix, key in keys:
|
||||
fingerprint = get_fingerprint(f"{prefix} {key}")
|
||||
|
||||
exists = db.query(models.SSHPubKey).filter(
|
||||
and_(models.SSHPubKey.UserID != user.ID,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue