Commit fe3373c9 by Scott Duckworth

Merge branch 'release/2.0.0'

parents 6480cbea 31fc0938
......@@ -5,6 +5,6 @@ include README.md
include lookup.py
include lookup.sh
include openssh-6.2p2-authorized-keys-command-stdin.diff
recursive-include sshkey/management *.py
recursive-include sshkey/migrations *.py
recursive-include sshkey/templates.example *
recursive-include django_sshkey/management *.py
recursive-include django_sshkey/migrations *.py
recursive-include django_sshkey/templates.example *
......@@ -11,9 +11,9 @@ passed as the first argument to the specified command.
# The Django app
The Django app is located in the sshkey directory at the top level of this
repository. You should point Django to it in your project's settings.py or
copy it into your project's directory.
The Django app is located in the django\_sshkey directory at the top level of
this repository. You should point Django to it in your project's settings.py
or copy it into your project's directory.
In order to associate an incoming public key with a user you must define
SSHKEY\_AUTHORIZED\_KEYS\_OPTIONS in your project's settings.py. This should
......@@ -22,29 +22,29 @@ replaced with the username of the user associated with the incoming public key.
For instance:
> SSHKEY\_AUTHORIZED\_KEYS\_OPTIONS = 'command="my-command {username}",no-pty'
SSHKEY_AUTHORIZED_KEYS_OPTIONS = 'command="my-command {username}",no-pty'
in settings.py will cause keys produced by the below commands to look similar
to:
> command="my-command fred",no-pty ssh-rsa BLAHBLAHBLAH
command="my-command fred",no-pty ssh-rsa BLAHBLAHBLAH
assuming the key "BLAHBLAHBLAH" is owned by fred.
## URL Configuration
This text assumes that your Django project's urls.py maps sshkey.urls into the
This text assumes that your Django project's urls.py maps django\_sshkey.urls into the
url namespace as follows:
> urlpatterns = patterns('',
> ...
> url('^sshkey/', include(sshkey.urls)),
> ...
> )
urlpatterns = patterns('',
...
url('^sshkey/', include(django_sshkey.urls)),
...
)
You will need to adjust your URLs if you use a different mapping.
# Tying OpenSSH's AuthorizedKeysCommand to the sshkey Django app
# Tying OpenSSH's AuthorizedKeysCommand to the django-sshkey
There are three provided ways of connecting AuthorizedKeysCommand to Django.
In all cases it is recommended and/or required that the command specified with
......@@ -76,7 +76,7 @@ This is generally the fastest method.
Same as above, but it's all written in Python and doesn't rely on external
commands.
The parent directory of the sshkey app must be in PYTHONPATH.
The parent directory of the django\_sshkey app must be in PYTHONPATH.
This is generally the second fastest method.
......
Upgrading and Downgrading
=========================
django-sshkey is equipped with [South][1] migrations. This makes changes to
the database schema in upgrades or downgrades a simple process. Migrations
will only be present on minor version changes.
To use South migrations, you must have the south app in your project's
INSTALLED_APPS.
The following table maps django-anyvcs version to migration labels:
Version App Name Label Notes
1.0.x sshkey 0001 Migrations were not present in 1.0.x
1.1.x sshkey 0002
2.0.x django_sshkey 0001 See Upgrading from 1.1.x to 2.x below
To upgrade, install the new version of django-sshkey and then migrate your
project to its corresponding label from the table above using the following
command:
python manage.py migrate <app_name> <label>
To downgrade, perform the migration down to the label of the desired version
before installing the older django-sshkey.
Upgrading from 1.1.x to 2.x
---------------------------
django-sshkey 2.x renames the sshkey app to django_sshkey. However, the
database table names are not changed.
To upgrade, all references to the sshkey module must be changed to
django_sshkey. This includes all instances of "import sshkey" or
"from sshkey import ..." and all references to sshkey in url patterns, views,
or templates, as well as updating INSTALLED_APPS in settings.py.
Once you have made those changes you will need to fake the initial migration
for django_sshkey:
python manage.py migrate --fake django_sshkey 0001_initial
This completes the upgrade process. The only thing that remains is the two
existing migration records in the south_migrationhistory table from the now
nonexistent sshkey app. These records do not cause any problems, but they can
be removed at your discrection using the following SQL statement on your
database:
DELETE FROM south_migrationhistory WHERE app_name="sshkey";
[1]: http://south.aeracode.org/
......@@ -15,4 +15,4 @@
# You should have received a copy of the GNU Lesser General Public License
# along with django-sshkey. If not, see <http://www.gnu.org/licenses/>.
__version__ = '1.1.1'
__version__ = '2.0.0'
......@@ -16,7 +16,7 @@
# along with django-sshkey. If not, see <http://www.gnu.org/licenses/>.
from django.contrib import admin
from sshkey.models import UserKey
from django_sshkey.models import UserKey
class UserKeyAdmin(admin.ModelAdmin):
list_display = [
......
......@@ -16,7 +16,7 @@
# along with django-sshkey. If not, see <http://www.gnu.org/licenses/>.
from django import forms
from sshkey.models import UserKey
from django_sshkey.models import UserKey
class UserKeyForm(forms.ModelForm):
class Meta:
......
......@@ -17,7 +17,7 @@
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from sshkey.models import sshkey_fingerprint, UserKey
from django_sshkey.models import sshkey_fingerprint, UserKey
import base64
import hashlib
import sys
......
......@@ -15,8 +15,10 @@ class Migration(SchemaMigration):
('name', self.gf('django.db.models.fields.CharField')(max_length=50, blank=True)),
('key', self.gf('django.db.models.fields.TextField')(max_length=2000)),
('fingerprint', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=47, blank=True)),
('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, null=True, blank=True)),
('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, null=True, blank=True)),
))
db.send_create_signal('sshkey', ['UserKey'])
db.send_create_signal('django_sshkey', ['UserKey'])
# Adding unique constraint on 'UserKey', fields ['user', 'name']
db.create_unique('sshkey_userkey', ['user_id', 'name'])
......@@ -68,14 +70,16 @@ class Migration(SchemaMigration):
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'sshkey.userkey': {
'Meta': {'unique_together': "[('user', 'name')]", 'object_name': 'UserKey'},
'django_sshkey.userkey': {
'Meta': {'unique_together': "[('user', 'name')]", 'object_name': 'UserKey', 'db_table': "'sshkey_userkey'"},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
'fingerprint': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '47', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
}
}
complete_apps = ['sshkey']
complete_apps = ['django_sshkey']
......@@ -38,6 +38,7 @@ class UserKey(models.Model):
last_modified = models.DateTimeField(auto_now=True, null=True)
class Meta:
db_table = 'sshkey_userkey'
unique_together = [
('user', 'name'),
]
......
<h1>My Keys</h1>
<p><a href="{% url sshkey.views.userkey_add %}">Add Key</a></p>
<p><a href="{% url django_sshkey.views.userkey_add %}">Add Key</a></p>
<table>
<tr>
<th>Key</th>
......@@ -14,8 +14,8 @@
<td>{{ userkey.fingerprint }}</td>
<td>{{ userkey.created }}</td>
<td>{{ userkey.last_modified }}</td>
<td><a href="{% url sshkey.views.userkey_edit userkey.pk %}">Edit</a></td>
<td><a href="{% url sshkey.views.userkey_delete userkey.pk %}">Delete</a></td>
<td><a href="{% url django_sshkey.views.userkey_edit userkey.pk %}">Edit</a></td>
<td><a href="{% url django_sshkey.views.userkey_delete userkey.pk %}">Delete</a></td>
</tr>
{% endfor %}
</table>
......@@ -20,8 +20,8 @@ from django.test.client import Client
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from sshkey.models import UserKey
from sshkey import settings
from django_sshkey.models import UserKey
from django_sshkey import settings
import os
import shutil
import subprocess
......@@ -269,7 +269,7 @@ class UserKeyLookupTestCase(BaseTestCase):
def test_lookup_all(self):
client = Client()
url = reverse('sshkey.views.lookup')
url = reverse('django_sshkey.views.lookup')
response = client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn('Content-Type', response)
......@@ -284,7 +284,7 @@ class UserKeyLookupTestCase(BaseTestCase):
def test_lookup_by_fingerprint(self):
client = Client()
url = reverse('sshkey.views.lookup')
url = reverse('django_sshkey.views.lookup')
fingerprint = ssh_fingerprint(self.key1_path+'.pub')
response = client.get(url, {'fingerprint': fingerprint})
self.assertEqual(response.status_code, 200)
......@@ -299,7 +299,7 @@ class UserKeyLookupTestCase(BaseTestCase):
def test_lookup_by_username_single_result(self):
client = Client()
url = reverse('sshkey.views.lookup')
url = reverse('django_sshkey.views.lookup')
username = self.user2.username
response = client.get(url, {'username': username})
self.assertEqual(response.status_code, 200)
......@@ -314,7 +314,7 @@ class UserKeyLookupTestCase(BaseTestCase):
def test_lookup_by_username_multiple_results(self):
client = Client()
url = reverse('sshkey.views.lookup')
url = reverse('django_sshkey.views.lookup')
username = self.user1.username
response = client.get(url, {'username': username})
self.assertEqual(response.status_code, 200)
......@@ -330,7 +330,7 @@ class UserKeyLookupTestCase(BaseTestCase):
def test_lookup_nonexist_fingerprint(self):
client = Client()
url = reverse('sshkey.views.lookup')
url = reverse('django_sshkey.views.lookup')
fingerprint = ssh_fingerprint(self.key4_path+'.pub')
response = client.get(url, {'fingerprint': fingerprint})
self.assertEqual(response.status_code, 200)
......@@ -340,7 +340,7 @@ class UserKeyLookupTestCase(BaseTestCase):
def test_lookup_nonexist_username(self):
client = Client()
url = reverse('sshkey.views.lookup')
url = reverse('django_sshkey.views.lookup')
response = client.get(url, {'username': 'batman'})
self.assertEqual(response.status_code, 200)
self.assertIn('Content-Type', response)
......
......@@ -17,7 +17,7 @@
from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('sshkey.views',
urlpatterns = patterns('django_sshkey.views',
url(r'^lookup$', 'lookup'),
url(r'^$', 'userkey_list'),
url(r'^add$', 'userkey_add'),
......
......@@ -24,9 +24,9 @@ from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.utils.http import is_safe_url
from sshkey import settings
from sshkey.models import UserKey
from sshkey.forms import UserKeyForm
from django_sshkey import settings
from django_sshkey.models import UserKey
from django_sshkey.forms import UserKeyForm
@require_GET
def lookup(request):
......@@ -73,7 +73,7 @@ def userkey_add(request):
form = UserKeyForm(request.POST, instance=userkey)
if form.is_valid():
form.save()
default_redirect = reverse('sshkey.views.userkey_list')
default_redirect = reverse('django_sshkey.views.userkey_list')
url = request.GET.get('next', default_redirect)
if not is_safe_url(url=url, host=request.get_host()):
url = default_redirect
......@@ -98,7 +98,7 @@ def userkey_edit(request, pk):
form = UserKeyForm(request.POST, instance=userkey)
if form.is_valid():
form.save()
default_redirect = reverse('sshkey.views.userkey_list')
default_redirect = reverse('django_sshkey.views.userkey_list')
url = request.GET.get('next', default_redirect)
if not is_safe_url(url=url, host=request.get_host()):
url = default_redirect
......@@ -122,4 +122,4 @@ def userkey_delete(request, pk):
userkey.delete()
message = 'SSH key %s was deleted.' % userkey.name
messages.success(request, message, fail_silently=True)
return HttpResponseRedirect(reverse('sshkey.views.userkey_list'))
return HttpResponseRedirect(reverse('django_sshkey.views.userkey_list'))
......@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with django-sshkey. If not, see <http://www.gnu.org/licenses/>.
import sshkey.util
import django_sshkey.util
import sys
sshkey.util.lookup_command(sys.argv[1:])
django_sshkey.util.lookup_command(sys.argv[1:])
......@@ -2,10 +2,10 @@ RELEASE INSTRUCTIONS
ensure unit tests pass
git flow release start X.Y.Z
bump __version__ in sshkey/__init__.py
git add sshkey/__init__.py
bump __version__ in django_sshkey/__init__.py
git add django_sshkey/__init__.py
git commit -m 'bump version'
python setup.py sdist
git flow release finish -m 'version X.Y.Z' X.Y.Z
git push origin master X.Y.Z
upload dist/django-sshkey-X.Y.Z.tar.gz to bitbucket
publish dist/django-sshkey-X.Y.Z.tar.gz
......@@ -6,12 +6,12 @@ README = open(os.path.join(os.path.dirname(__file__), 'README.md')).read()
# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
execfile('sshkey/__init__.py')
execfile('django_sshkey/__init__.py')
setup(
name='django-sshkey',
version=__version__,
packages=['sshkey'],
packages=['django_sshkey'],
include_package_data=True,
license='GNU Lesser General Public License v3 (LGPLv3)',
description='A Django app to identify users by their SSH public keys.',
......
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'UserKey.created'
db.add_column('sshkey_userkey', 'created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, null=True, blank=True), keep_default=False)
# Adding field 'UserKey.last_modified'
db.add_column('sshkey_userkey', 'last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, null=True, blank=True), keep_default=False)
def backwards(self, orm):
# Deleting field 'UserKey.created'
db.delete_column('sshkey_userkey', 'created')
# Deleting field 'UserKey.last_modified'
db.delete_column('sshkey_userkey', 'last_modified')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'sshkey.userkey': {
'Meta': {'unique_together': "[('user', 'name')]", 'object_name': 'UserKey'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
'fingerprint': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '47', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
}
}
complete_apps = ['sshkey']
../django_sshkey
\ No newline at end of file
......@@ -123,7 +123,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.admindocs',
'south',
'sshkey',
'django_sshkey',
)
# A sample logging configuration. The only tangible logging
......
../sshkey
\ No newline at end of file
......@@ -3,7 +3,7 @@ from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^', include('sshkey.urls')),
url(r'^', include('django_sshkey.urls')),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
)
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