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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
4e2a4c7e
authored
Jul 02, 2014
by
Scott Duckworth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provide key_id template in SSHKEY_AUTHORIZED_KEYS_OPTIONS
parent
dad8a403
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
django_sshkey/tests.py
+17
-17
django_sshkey/views.py
+3
-1
No files found.
django_sshkey/tests.py
View file @
4e2a4c7e
...
...
@@ -362,39 +362,39 @@ class UserKeyLookupTestCase(BaseTestCase):
def
setUpClass
(
cls
):
super
(
UserKeyLookupTestCase
,
cls
)
.
setUpClass
()
cls
.
original_options
=
settings
.
SSHKEY_AUTHORIZED_KEYS_OPTIONS
settings
.
SSHKEY_AUTHORIZED_KEYS_OPTIONS
=
'command="{username}"'
settings
.
SSHKEY_AUTHORIZED_KEYS_OPTIONS
=
'command="{username}
{key_id}
"'
cls
.
user1
=
User
.
objects
.
create
(
username
=
'user1'
)
cls
.
user2
=
User
.
objects
.
create
(
username
=
'user2'
)
cls
.
key1_path
=
os
.
path
.
join
(
cls
.
key_dir
,
'key1'
)
ssh_keygen
(
file
=
cls
.
key1_path
)
key1
=
UserKey
(
cls
.
key1
=
UserKey
(
user
=
cls
.
user1
,
name
=
'key1'
,
key
=
open
(
cls
.
key1_path
+
'.pub'
)
.
read
(),
)
key1
.
full_clean
()
key1
.
save
()
cls
.
key1
.
full_clean
()
cls
.
key1
.
save
()
cls
.
key2_path
=
os
.
path
.
join
(
cls
.
key_dir
,
'key2'
)
ssh_keygen
(
file
=
cls
.
key2_path
)
key2
=
UserKey
(
cls
.
key2
=
UserKey
(
user
=
cls
.
user1
,
name
=
'key2'
,
key
=
open
(
cls
.
key2_path
+
'.pub'
)
.
read
(),
)
key2
.
full_clean
()
key2
.
save
()
cls
.
key2
.
full_clean
()
cls
.
key2
.
save
()
cls
.
key3_path
=
os
.
path
.
join
(
cls
.
key_dir
,
'key3'
)
ssh_keygen
(
file
=
cls
.
key3_path
)
key3
=
UserKey
(
cls
.
key3
=
UserKey
(
user
=
cls
.
user2
,
name
=
'key3'
,
key
=
open
(
cls
.
key3_path
+
'.pub'
)
.
read
(),
)
key3
.
full_clean
()
key3
.
save
()
cls
.
key3
.
full_clean
()
cls
.
key3
.
save
()
cls
.
key4_path
=
os
.
path
.
join
(
cls
.
key_dir
,
'key4'
)
ssh_keygen
(
file
=
cls
.
key4_path
)
...
...
@@ -414,9 +414,9 @@ class UserKeyLookupTestCase(BaseTestCase):
self
.
assertEqual
(
response
[
'Content-Type'
],
'text/plain'
)
actual_content
=
set
(
response
.
content
.
strip
()
.
split
(
'
\n
'
))
correct_content
=
set
((
'command="user1
" '
+
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
(
),
'command="user1
" '
+
open
(
self
.
key2_path
+
'.pub'
)
.
read
()
.
strip
(
),
'command="user2
" '
+
open
(
self
.
key3_path
+
'.pub'
)
.
read
()
.
strip
(
),
'command="user1
%
s"
%
s'
%
(
self
.
key1
.
id
,
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
()
),
'command="user1
%
s"
%
s'
%
(
self
.
key2
.
id
,
open
(
self
.
key2_path
+
'.pub'
)
.
read
()
.
strip
()
),
'command="user2
%
s"
%
s'
%
(
self
.
key3
.
id
,
open
(
self
.
key3_path
+
'.pub'
)
.
read
()
.
strip
()
),
))
self
.
assertEqual
(
actual_content
,
correct_content
)
...
...
@@ -431,7 +431,7 @@ class UserKeyLookupTestCase(BaseTestCase):
username
=
self
.
user1
.
username
actual_content
=
set
(
response
.
content
.
strip
()
.
split
(
'
\n
'
))
correct_content
=
set
((
'command="user1
" '
+
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
(
),
'command="user1
%
s"
%
s'
%
(
self
.
key1
.
id
,
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
()
),
))
self
.
assertEqual
(
actual_content
,
correct_content
)
...
...
@@ -446,7 +446,7 @@ class UserKeyLookupTestCase(BaseTestCase):
body
=
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
()
actual_content
=
set
(
response
.
content
.
strip
()
.
split
(
'
\n
'
))
correct_content
=
set
((
'command="user2
" '
+
open
(
self
.
key3_path
+
'.pub'
)
.
read
()
.
strip
(
),
'command="user2
%
s"
%
s'
%
(
self
.
key3
.
id
,
open
(
self
.
key3_path
+
'.pub'
)
.
read
()
.
strip
()
),
))
self
.
assertEqual
(
actual_content
,
correct_content
)
...
...
@@ -461,8 +461,8 @@ class UserKeyLookupTestCase(BaseTestCase):
body
=
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
()
actual_content
=
set
(
response
.
content
.
strip
()
.
split
(
'
\n
'
))
correct_content
=
set
((
'command="user1
" '
+
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
(
),
'command="user1
" '
+
open
(
self
.
key2_path
+
'.pub'
)
.
read
()
.
strip
(
),
'command="user1
%
s"
%
s'
%
(
self
.
key1
.
id
,
open
(
self
.
key1_path
+
'.pub'
)
.
read
()
.
strip
()
),
'command="user1
%
s"
%
s'
%
(
self
.
key2
.
id
,
open
(
self
.
key2_path
+
'.pub'
)
.
read
()
.
strip
()
),
))
self
.
assertEqual
(
actual_content
,
correct_content
)
...
...
django_sshkey/views.py
View file @
4e2a4c7e
...
...
@@ -54,7 +54,9 @@ def lookup(request):
for
key
in
keys
:
if
settings
.
SSHKEY_AUTHORIZED_KEYS_OPTIONS
:
options
=
settings
.
SSHKEY_AUTHORIZED_KEYS_OPTIONS
.
format
(
username
=
key
.
user
.
username
)
+
' '
username
=
key
.
user
.
username
,
key_id
=
key
.
id
,
)
+
' '
else
:
options
=
''
response
+=
options
+
key
.
key
+
'
\n
'
...
...
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