As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit aedf824d authored by Pablo Carranza's avatar Pablo Carranza
Browse files

Change use of fingerprint for whole key

parent 459e4482
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment