Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-sshkey
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
97957b88
authored
Aug 07, 2013
by
Scott Duckworth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add setting SSHKEY_AUTHORIZED_KEYS_OPTIONS
SSHKEY_AUTHORIZED_KEYS_COMMAND is now deprecated
parent
a7871041
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
9 deletions
+24
-9
README.md
+5
-6
sshkey/settings.py
+13
-0
sshkey/views.py
+6
-3
No files found.
README.md
View file @
97957b88
...
@@ -16,19 +16,18 @@ repository. You should point Django to it in your project's settings.py or
...
@@ -16,19 +16,18 @@ repository. You should point Django to it in your project's settings.py or
copy it into your project's directory.
copy it into your project's directory.
In order to associate an incoming public key with a user you must define
In order to associate an incoming public key with a user you must define
SSHKEY
\_
AUTHORIZED
\_
KEYS
\_
COMMAND in your project's settings.py. This should
SSHKEY
\_
AUTHORIZED
\_
KEYS
\_
OPTIONS in your project's settings.py. This should
be a string containing the command which is run after successful
be a string containing options accepted by sshd, with "{username}" being
authentication, with "{username}" being replaced with the username of the user
replaced with the username of the user associated with the incoming public key.
associated with the incoming public key.
For instance:
For instance:
> SSHKEY\_AUTHORIZED\_KEYS\_
COMMAND = 'my-command {username}
'
> SSHKEY\_AUTHORIZED\_KEYS\_
OPTIONS = 'command="my-command {username}",no-pty
'
in settings.py will cause keys produced by the below commands to look similar
in settings.py will cause keys produced by the below commands to look similar
to:
to:
> command="my-command fred" ssh-rsa BLAHBLAHBLAH
> command="my-command fred"
,no-pty
ssh-rsa BLAHBLAHBLAH
assuming the key "BLAHBLAHBLAH" is owned by fred.
assuming the key "BLAHBLAHBLAH" is owned by fred.
...
...
sshkey/settings.py
0 → 100644
View file @
97957b88
from
django.conf
import
settings
SSHKEY_AUTHORIZED_KEYS_OPTIONS
=
getattr
(
settings
,
'SSHKEY_AUTHORIZED_KEYS_OPTIONS'
,
None
)
SSHKEY_AUTHORIZED_KEYS_COMMAND
=
getattr
(
settings
,
'SSHKEY_AUTHORIZED_KEYS_COMMAND'
,
None
)
if
SSHKEY_AUTHORIZED_KEYS_COMMAND
is
not
None
:
import
warnings
with
warnings
.
catch_warnings
():
import
warnings
warnings
.
simplefilter
(
'default'
,
DeprecationWarning
)
warnings
.
warn
(
'SSHKEY_AUTHORIZED_KEYS_COMMAND has been deprecated; '
'use SSHKEY_AUTHORIZED_KEYS_OPTIONS instead.'
,
DeprecationWarning
)
sshkey/views.py
View file @
97957b88
...
@@ -5,7 +5,7 @@ from django.template import RequestContext
...
@@ -5,7 +5,7 @@ from django.template import RequestContext
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
sshkey
import
settings
from
sshkey.models
import
UserKey
from
sshkey.models
import
UserKey
from
sshkey.forms
import
UserKeyForm
from
sshkey.forms
import
UserKeyForm
...
@@ -22,13 +22,16 @@ def lookup(request):
...
@@ -22,13 +22,16 @@ def lookup(request):
keys
=
UserKey
.
objects
.
iterator
()
keys
=
UserKey
.
objects
.
iterator
()
response
=
''
response
=
''
for
key
in
keys
:
for
key
in
keys
:
try
:
if
settings
.
SSHKEY_AUTHORIZED_KEYS_OPTIONS
:
options
=
settings
.
SSHKEY_AUTHORIZED_KEYS_OPTIONS
.
format
(
username
=
key
.
user
.
username
)
+
' '
elif
settings
.
SSHKEY_AUTHORIZED_KEYS_COMMAND
:
options
=
'command="
%
s" '
%
(
options
=
'command="
%
s" '
%
(
settings
.
SSHKEY_AUTHORIZED_KEYS_COMMAND
settings
.
SSHKEY_AUTHORIZED_KEYS_COMMAND
.
format
(
username
=
key
.
user
.
username
)
.
format
(
username
=
key
.
user
.
username
)
.
replace
(
'"'
,
r'\"'
)
.
replace
(
'"'
,
r'\"'
)
)
)
e
xcept
AttributeError
:
e
lse
:
options
=
''
options
=
''
response
+=
options
+
key
.
key
+
'
\n
'
response
+=
options
+
key
.
key
+
'
\n
'
return
HttpResponse
(
response
,
mimetype
=
'text/plain'
)
return
HttpResponse
(
response
,
mimetype
=
'text/plain'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment