-
Notifications
You must be signed in to change notification settings - Fork 1
Description
We need a way that applications can define their own key types so that keys don't have to be tied to users.
The thinking was that we store keys in a model which isn't really associated with anything called Key
and clients create their own model types which hold a foreign key to Key
. User keys work using this sort of model. A UserKey
is just has foreign keys to Key
and auth.User
.
The API looks something like this:
>>> from django_sshkey.models import UserKey
>>> from django.contrib.auth.models import User
>>> basekey = UserKey.base(key='ssh-rsa AAA...')
>>> basekey.full_clean()
>>> basekey.save()
>>> userkey = UserKey(basekey=basekey, user=User.objects.create(username='fred'))
>>> userkey.full_clean()
>>> userkey.save()
and users can define their own key types like so
>>> from django_sshkey.models import NamedKey
>>> class ServiceKey(NamedKey): pass
>>> basekey = ServiceKey.base(key='ssh-rsa AAA...')
...
where NamedKey
is one of a couple of abstract models a user can inherit from to make the API consistent between key types. This type also requires keys to be named.
We expect this change to be mostly backwards compatible, but will probably breaking in Django's generated APIs (i.e. QuerySets). For that, this probably requires a major release. People who just use the views and forms, but don't deal extensively with the UserKey
model should not be affected. This is because several attributes on UserKey
will be moved into the Key
model, so anyone expecting those attributes to exist on that particular model would see breakage.
- Bitbucket: https://bitbucket.org/OEP/ClemsonSoCUnix/django-sshkey/issue/2
- Originally reported by: Paul Kilgo
- Originally created at: 2014-10-10T21:03:19.127