Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-shell
Commits
aedf824d
Commit
aedf824d
authored
Mar 11, 2016
by
Pablo Carranza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change use of fingerprint for whole key
parent
459e4482
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
10 deletions
+10
-10
bin/authorized_keys
bin/authorized_keys
+5
-5
lib/gitlab_net.rb
lib/gitlab_net.rb
+2
-2
spec/vcr_cassettes/ssh-key-not-found.yml
spec/vcr_cassettes/ssh-key-not-found.yml
+1
-1
spec/vcr_cassettes/ssh-key-not-implemented.yml
spec/vcr_cassettes/ssh-key-not-implemented.yml
+1
-1
spec/vcr_cassettes/ssh-key-ok.yml
spec/vcr_cassettes/ssh-key-ok.yml
+1
-1
No files found.
bin/authorized_keys
View file @
aedf824d
...
...
@@ -4,22 +4,22 @@
# GitLab shell authorized_keys. Query gitlab API to get the authorized command for a given ssh key fingerprint
#
# Ex.
# /bin/authorized_keys
e6:17:f2:f3:b7
# /bin/authorized_keys
BASE64-KEY
#
# Returns
# command="/bin/gitlab-shell key-#",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc2EAAAADAQA...
#
fingerprint
=
ARGV
[
0
]
abort
"# No
fingerprint provided"
if
fingerprint
.
nil?
key
=
ARGV
[
0
]
abort
"# No
key provided"
if
key
.
nil?
require_relative
"../lib/gitlab_init"
require_relative
"../lib/gitlab_net"
require_relative
"../lib/gitlab_keys"
authorized_key
=
GitlabNet
.
new
.
authorized_key
(
fingerprint
)
authorized_key
=
GitlabNet
.
new
.
authorized_key
(
key
)
unless
authorized_key
.
nil?
puts
GitlabKey
.
new
.
key_line
(
authorized_key
[
"id"
],
authorized_key
[
"key"
])
else
puts
"# No key was found
with fingerprint
#{
fingerprint
}
"
puts
"# No key was found
for
#{
key
}
"
end
lib/gitlab_net.rb
View file @
aedf824d
...
...
@@ -56,8 +56,8 @@ class GitlabNet
get
(
"
#{
host
}
/check"
,
read_timeout:
CHECK_TIMEOUT
)
end
def
authorized_key
(
fingerprint
)
resp
=
get
(
"
#{
host
}
/authorized_keys?
fingerprint=
#{
fingerprint
}
"
)
def
authorized_key
(
key
)
resp
=
get
(
"
#{
host
}
/authorized_keys?
key=
#{
key
}
"
)
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
"200"
rescue
nil
...
...
spec/vcr_cassettes/ssh-key-not-found.yml
View file @
aedf824d
...
...
@@ -2,7 +2,7 @@
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/
ssh-key?fingerprint
=whatever
uri
:
https://dev.gitlab.org/api/v3/internal/
authorized_keys?key
=whatever
body
:
encoding
:
US-ASCII
string
:
secret_token=a123
...
...
spec/vcr_cassettes/ssh-key-not-implemented.yml
View file @
aedf824d
...
...
@@ -2,7 +2,7 @@
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/authorized_keys?
fingerprint
=whatever
uri
:
https://dev.gitlab.org/api/v3/internal/authorized_keys?
key
=whatever
body
:
encoding
:
US-ASCII
string
:
secret_token=a123
...
...
spec/vcr_cassettes/ssh-key-ok.yml
View file @
aedf824d
...
...
@@ -2,7 +2,7 @@
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/authorized_keys?
fingerprint
=42:18:16
uri
:
https://dev.gitlab.org/api/v3/internal/authorized_keys?
key
=42:18:16
body
:
encoding
:
US-ASCII
string
:
secret_token=a123
...
...
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