Commit e8d249b6 by Scott Duckworth

ensure key is exactly one line and stripped

Keys with more than one line of text create invalid authorized_keys
output.
parent 35f4b7f4
......@@ -17,6 +17,12 @@ class UserKey(models.Model):
def __unicode__(self):
return unicode(self.user) + u': ' + self.name
def clean_fields(self, exclude=None):
if not exclude or 'key' not in exclude:
self.key = self.key.strip()
if len(self.key.splitlines()) > 1:
raise ValidationError('Only one line is allowed')
def clean(self):
try:
self.fingerprint = sshkey_fingerprint(self.key)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment