From c4b5a076040a6f6156c26f66cdc47610fc267db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 8 Aug 2018 11:39:04 +0200 Subject: Fix two regressions in SSH certificate support Fix two regressions in my 2e8b670 ("Add support for SSH certificate authentication", 2018-06-14) merged in gitlab-org/gitlab-shell!207. This fixes the issue noted in gitlab-org/gitlab-shell#145 where the command-line contains things other than the key/user/username, and also a regression where SSH certificates are being used, and the username presented in the key is unknown to GitLab. In that case, we should log the user in as "Anonymous" (on an instance that allows public access), but because of how the error checking around api.discover() was implemented we ended up erroring out instead. --- lib/gitlab_shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/gitlab_shell.rb') diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index 78fdfe8..c6b28ce 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -208,7 +208,7 @@ class GitlabShell # rubocop:disable Metrics/ClassLength begin if defined?(@who) @user = api.discover(@who) - @gl_id = "user-#{@user['id']}" + @gl_id = "user-#{@user['id']}" if @user else @user = api.discover(@gl_id) end -- cgit v1.2.1 From cce62b3571617e2df3aee8df4b3b1908191dc495 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Thu, 9 Aug 2018 18:27:45 +0100 Subject: Guard discovery by username or key against bad API responses --- lib/gitlab_shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/gitlab_shell.rb') diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index c6b28ce..03edf65 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -208,7 +208,7 @@ class GitlabShell # rubocop:disable Metrics/ClassLength begin if defined?(@who) @user = api.discover(@who) - @gl_id = "user-#{@user['id']}" if @user + @gl_id = "user-#{@user['id']}" if @user && @user.key?('id') else @user = api.discover(@gl_id) end -- cgit v1.2.1