launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06556
[Merge] lp:~davewalker/maas/sshkeystore into lp:maas
Dave Walker has proposed merging lp:~davewalker/maas/sshkeystore into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~davewalker/maas/sshkeystore/+merge/95389
1. key length isn't safe to assume a certain length.. it can be massively variable.
2. it's a new top level service that shouldn't be a auth'd in or admin access only.
- it could exist under /api i suppose..
- it micmics the likes of https://launchpad.net/~davewalker/+sshkeys
--
https://code.launchpad.net/~davewalker/maas/sshkeystore/+merge/95389
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~davewalker/maas/sshkeystore into lp:maas.
=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py 2012-03-01 15:40:36 +0000
+++ src/maasserver/models.py 2012-03-01 15:43:38 +0000
@@ -545,6 +545,8 @@
token.consumer.delete()
token.delete()
+ def __unicode__(self):
+ return self.user.username
# When a user is created: create the related profile and the default
# consumer/token.
@@ -561,6 +563,20 @@
post_save.connect(create_user, sender=User)
+class SSHKeys(models.Model):
+ """A simple SSH public keystore that can be retrieved, a user
+ can have multiple keys.
+
+ :ivar user: The user which owns the key.
+ :ivar key: The ssh public key.
+ """
+ user = models.ForeignKey(UserProfile)
+ key = models.TextField()
+
+ def __unicode__(self):
+ return self.key
+
+
class FileStorage(models.Model):
"""A simple file storage keyed on file name.
@@ -690,6 +706,7 @@
admin.site.register(FileStorage)
admin.site.register(MACAddress)
admin.site.register(Node)
+admin.site.register(SSHKeys)
class MaaSAuthorizationBackend(ModelBackend):
=== added file 'src/maasserver/templates/maasserver/sshkeys.txt'
--- src/maasserver/templates/maasserver/sshkeys.txt 1970-01-01 00:00:00 +0000
+++ src/maasserver/templates/maasserver/sshkeys.txt 2012-03-01 15:43:38 +0000
@@ -0,0 +1,2 @@
+{% for key in keys %}{{ key }}
+{% endfor %}
=== modified file 'src/maasserver/urls.py'
--- src/maasserver/urls.py 2012-02-29 17:48:13 +0000
+++ src/maasserver/urls.py 2012-03-01 15:43:38 +0000
@@ -34,6 +34,7 @@
settings,
settings_add_archive,
userprefsview,
+ KeystoreView,
)
@@ -90,3 +91,8 @@
urlpatterns += patterns('',
(r'^api/1\.0/', include('maasserver.urls_api'))
)
+
+# Key Store
+urlpatterns += patterns('',
+ (r'^keystore/user/(?P<userid>\w+)/$', KeystoreView)
+ )
=== modified file 'src/maasserver/views.py'
--- src/maasserver/views.py 2012-02-29 13:44:30 +0000
+++ src/maasserver/views.py 2012-03-01 15:43:38 +0000
@@ -46,6 +46,7 @@
from maasserver.models import (
Node,
UserProfile,
+ SSHKeys,
)
@@ -70,6 +71,13 @@
return reverse('index')
+def KeystoreView(request, userid):
+ keys = SSHKeys.objects.filter(user__user__username=userid)
+ return render_to_response('maasserver/sshkeys.txt', {'keys': keys},
+ mimetype="text/plain",
+ context_instance=RequestContext(request))
+
+
def userprefsview(request):
user = request.user
# Process the profile update form.