fedora-iot / zezere

Zezere is a provisioning service for Fedora IoT. It can be used for deploying Fedora IoT to devices without needing a physical console.
MIT License
58 stars 33 forks source link

improve ssh key management #57

Closed nullr0ute closed 4 years ago

nullr0ute commented 4 years ago

The ssh key management could be improved.

There's only one text box which appears to be where the key should go: ssh-keys

But when I put my key in there it errors out with the following error so I'm not sure if that's the key itself or a name for the key:

Environment:

Request Method: POST
Request URL: https://provision.fedoraproject.org/portal/sshkeys/add/

Django Version: 3.0.4
Python Version: 3.6.9
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'mozilla_django_oidc',
 'rest_framework',
 'rules.apps.AutodiscoverRulesConfig',
 'zezere']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
  File "/opt/app-root/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/opt/app-root/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/app-root/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/opt/app-root/lib/python3.6/site-packages/django/views/decorators/http.py", line 40, in inner
    return func(request, *args, **kwargs)
  File "/opt/app-root/src/zezere/views_portal.py", line 98, in add_ssh_key
    key.full_clean()
  File "/opt/app-root/lib/python3.6/site-packages/django/db/models/base.py", line 1222, in full_clean
    raise ValidationError(errors)

Exception Type: ValidationError at /portal/sshkeys/add/
Exception Value: {'key': ['Ensure this value has at most 255 characters (it has 402).']}

It would also be useful to be able to provide a friendly name for the key.