Commit fa43cd77 by Paul Kilgo

Merge branch 'release/2.1.0'

parents ae7e943b 83174171
...@@ -4,6 +4,7 @@ include COPYING.LESSER ...@@ -4,6 +4,7 @@ include COPYING.LESSER
include README.md include README.md
include lookup.py include lookup.py
include lookup.sh include lookup.sh
include django-sshkey-lookup
include openssh-6.2p2-authorized-keys-command-stdin.diff include openssh-6.2p2-authorized-keys-command-stdin.diff
recursive-include django_sshkey/management *.py recursive-include django_sshkey/management *.py
recursive-include django_sshkey/migrations *.py recursive-include django_sshkey/migrations *.py
......
...@@ -51,9 +51,9 @@ In all cases it is recommended and/or required that the command specified with ...@@ -51,9 +51,9 @@ In all cases it is recommended and/or required that the command specified with
AuthorizedKeysCommand be a shell script that is owned by and only writable by AuthorizedKeysCommand be a shell script that is owned by and only writable by
root which invokes one of the commands below: root which invokes one of the commands below:
## Using lookup.sh ## Using django-sshkey-lookup
*Usage: lookup.sh URL [USERNAME]* *Usage: django-sshkey-lookup URL [USERNAME]*
URL should be the full URL to /sshkey/lookup on your Django web server running URL should be the full URL to /sshkey/lookup on your Django web server running
the sshkey app. the sshkey app.
...@@ -67,15 +67,23 @@ standard input; if the key is found it is printed to standard output. ...@@ -67,15 +67,23 @@ standard input; if the key is found it is printed to standard output.
This command assumes that some fairly standard commands, like ssh-keygen and This command assumes that some fairly standard commands, like ssh-keygen and
curl, are found in $PATH. curl, are found in $PATH.
This command is equivalent to the old script `lookup.sh` but was renamed to
have a less ambiguous name when installed system-wide. A symlink is left in
its place for backwards compatibility.
This is generally the fastest method. This is generally the fastest method.
## Using lookup.py ## Using django-sshkey-pylookup
*Usage: lookup.py URL [USERNAME]* *Usage: django-sshkey-pylookup URL [USERNAME]*
Same as above, but it's all written in Python and doesn't rely on external Same as above, but it's all written in Python and doesn't rely on external
commands. commands.
This script is generated by setuptools when this package is installed. The old
equivalent, `lookup.py` is available with a deprecation warning for backwards
compatibility.
The parent directory of the django\_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. This is generally the second fastest method.
......
...@@ -8,7 +8,7 @@ will only be present on minor version changes. ...@@ -8,7 +8,7 @@ will only be present on minor version changes.
To use South migrations, you must have the south app in your project's To use South migrations, you must have the south app in your project's
INSTALLED_APPS. INSTALLED_APPS.
The following table maps django-anyvcs version to migration labels: The following table maps django-sshkey version to migration labels:
Version App Name Label Notes Version App Name Label Notes
1.0.x sshkey 0001 Migrations were not present in 1.0.x 1.0.x sshkey 0001 Migrations were not present in 1.0.x
......
...@@ -15,4 +15,4 @@ ...@@ -15,4 +15,4 @@
# You should have received a copy of the GNU Lesser General Public License # 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/>. # along with django-sshkey. If not, see <http://www.gnu.org/licenses/>.
__version__ = '2.0.1' __version__ = '2.1.0'
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.conf import settings from django.conf import settings
from django_sshkey.models import sshkey_fingerprint, UserKey from django_sshkey.models import UserKey
import base64 from django_sshkey.util import sshkey_fingerprint
import hashlib
import sys import sys
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -18,17 +18,11 @@ ...@@ -18,17 +18,11 @@
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
import base64 from django_sshkey.util import sshkey_fingerprint
import hashlib
import re import re
sshkey_re = re.compile(r'(?P<type>[\w-]+)\s+(?P<b64key>\S+)(?:\s+(?P<comment>\S+))?$') sshkey_re = re.compile(r'(?P<type>[\w-]+)\s+(?P<b64key>\S+)(?:\s+(?P<comment>\S+))?$')
def sshkey_fingerprint(b64key):
key = base64.b64decode(b64key)
fp_plain = hashlib.md5(key).hexdigest()
return ':'.join(a+b for a,b in zip(fp_plain[::2], fp_plain[1::2]))
class UserKey(models.Model): class UserKey(models.Model):
user = models.ForeignKey(User, db_index=True) user = models.ForeignKey(User, db_index=True)
name = models.CharField(max_length=50, blank=True) name = models.CharField(max_length=50, blank=True)
......
...@@ -15,6 +15,13 @@ ...@@ -15,6 +15,13 @@
# You should have received a copy of the GNU Lesser General Public License # 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/>. # along with django-sshkey. If not, see <http://www.gnu.org/licenses/>.
def sshkey_fingerprint(b64key):
import base64
import hashlib
key = base64.b64decode(b64key)
fp_plain = hashlib.md5(key).hexdigest()
return ':'.join(a+b for a,b in zip(fp_plain[::2], fp_plain[1::2]))
def lookup_command(args): def lookup_command(args):
import sys import sys
import urllib import urllib
...@@ -38,3 +45,7 @@ def lookup_command(args): ...@@ -38,3 +45,7 @@ def lookup_command(args):
status = 0 status = 0
sys.stdout.write(line) sys.stdout.write(line)
sys.exit(status) sys.exit(status)
def lookup_main():
import sys
lookup_command(sys.argv[1:])
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License # 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/>. # along with django-sshkey. If not, see <http://www.gnu.org/licenses/>.
import warnings
import django_sshkey.util import django_sshkey.util
import sys
django_sshkey.util.lookup_command(sys.argv[1:]) warnings.warn("lookup.py is deprecated; use django-sshkey-pylookup",
DeprecationWarning)
django_sshkey.util.lookup_main()
django-sshkey-lookup
\ No newline at end of file
...@@ -31,4 +31,12 @@ setup( ...@@ -31,4 +31,12 @@ setup(
'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
], ],
scripts=[
'django-sshkey-lookup',
],
entry_points={
'console_scripts': [
'django-sshkey-pylookup = django_sshkey.util:lookup_main',
],
},
) )
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