summaryrefslogtreecommitdiff
path: root/bin/gitlab-shell-authorized-keys-check
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-08-05 05:03:16 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-05 05:03:16 +0000
commitc577eb9ed8bd0336870f7a83302f70821d510169 (patch)
treeed7f7281633d97933e4465a2ac0f86d62c9a216e /bin/gitlab-shell-authorized-keys-check
parented0460374a5ca13d9ea17c6a9c21151319b7fd53 (diff)
parent3b6f9f7583755e041e76142d7caf7716937907fa (diff)
downloadgitlab-shell-c577eb9ed8bd0336870f7a83302f70821d510169.tar.gz
Merge branch '181-migrate-gitlab-shell-checks-fallback' into 'master'
Support falling back to ruby version of checkers See merge request gitlab-org/gitlab-shell!318
Diffstat (limited to 'bin/gitlab-shell-authorized-keys-check')
l---------[-rwxr-xr-x]bin/gitlab-shell-authorized-keys-check43
1 files changed, 1 insertions, 42 deletions
diff --git a/bin/gitlab-shell-authorized-keys-check b/bin/gitlab-shell-authorized-keys-check
index 2ea1a74..3dc14d1 100755..120000
--- a/bin/gitlab-shell-authorized-keys-check
+++ b/bin/gitlab-shell-authorized-keys-check
@@ -1,42 +1 @@
-#!/usr/bin/env ruby
-
-#
-# GitLab shell authorized_keys helper. Query GitLab API to get the authorized
-# command for a given ssh key fingerprint
-#
-# Ex.
-# bin/gitlab-shell-authorized-keys-check <username> <public-key>
-#
-# Returns
-# command="/bin/gitlab-shell key-#",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA...
-#
-# Expects to be called by the SSH daemon, via configuration like:
-# AuthorizedKeysCommandUser git
-# AuthorizedKeysCommand /bin/gitlab-shell-authorized-keys-check git %u %k
-
-abort "# Wrong number of arguments. #{ARGV.size}. Usage:
-# gitlab-shell-authorized-keys-check <expected-username> <actual-username> <key>" unless ARGV.size == 3
-
-expected_username = ARGV[0]
-abort '# No username provided' if expected_username.nil? || expected_username == ''
-
-actual_username = ARGV[1]
-abort '# No username provided' if actual_username.nil? || actual_username == ''
-
-# Only check access if the requested username matches the configured username.
-# Normally, these would both be 'git', but it can be configured by the user
-exit 0 unless expected_username == actual_username
-
-key = ARGV[2]
-abort "# No key provided" if key.nil? || key == ''
-
-require_relative '../lib/gitlab_init'
-require_relative '../lib/gitlab_net'
-require_relative '../lib/gitlab_keys'
-
-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
+./gitlab-shell \ No newline at end of file