Commit 1427c980 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '202-repurpose-authorized-keys-script' into 'master'

Repurpose bin/authorized_keys script

See merge request gitlab-org/gitlab-shell!330
parents 27ac9328 4cee52bd
#!/usr/bin/env ruby
#!/bin/sh
# Legacy script used for AuthorizedKeysCommand when configured without username.
# Executes gitlab-shell-authorized-keys-check with "git" as expected and actual
# username and with the passed key.
#
# GitLab shell authorized_keys. Query GitLab API to get the authorized command for a given ssh key fingerprint
#
# Ex.
# /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...
#
key = ARGV[0]
abort "# No key provided" if key.nil? || key.empty?
require_relative "../lib/gitlab_init"
require_relative "../lib/gitlab_net"
require_relative "../lib/gitlab_keys"
# TODO: Remove this in https://gitlab.com/gitlab-org/gitlab-shell/issues/209.
authorized_key = GitlabNet.new.authorized_key(key)
if authorized_key.nil?
puts "# No key was found for #{key}"
else
puts GitlabKeys.key_line("key-#{authorized_key['id']}", authorized_key["key"])
end
$(dirname $0)/gitlab-shell-authorized-keys-check git git $1
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 to comment