summaryrefslogtreecommitdiff
path: root/lib/gitlab_net.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-09-02 14:21:59 +0000
committerDouwe Maan <douwe@gitlab.com>2016-09-02 14:21:59 +0000
commitdf6e50448a2e97856805f5e4a70831f2ba8a0ef2 (patch)
tree5e5dc709238c54a8e5213cd11f577751fc744ef8 /lib/gitlab_net.rb
parent3043b31c458bf720843a84b35c9fbad5c1488c1d (diff)
parentdcc20876554ae18c6869b80071728f1b91858c5f (diff)
downloadgitlab-shell-df6e50448a2e97856805f5e4a70831f2ba8a0ef2.tar.gz
Merge branch '2fa_recovery' into 'master'
Add option to recover 2FA via SSH Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/3765 Allow users to recover their own account if they lose their 2FA device or recovery codes. ## Questions/Concerns - Does this look secure? I think it is but we need to make sure no one can spoof a username or something and disable two factor. ## Todo - [x] Working code - [x] Tests - [x] GitLab merge requests (including documentation) ![Screen_Shot_2016-08-18_at_2.34.18_PM](/uploads/1ed00e93abdfc3b41187c021e4f9d4db/Screen_Shot_2016-08-18_at_2.34.18_PM.png) See merge request !74
Diffstat (limited to 'lib/gitlab_net.rb')
-rw-r--r--lib/gitlab_net.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 35a8833..47bae95 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -72,6 +72,15 @@ class GitlabNet
nil
end
+ def two_factor_recovery_codes(key)
+ key_id = key.gsub('key-', '')
+ resp = post("#{host}/two_factor_recovery_codes", key_id: key_id)
+
+ JSON.parse(resp.body) if resp.code == '200'
+ rescue
+ {}
+ end
+
def redis_client
redis_config = config.redis
database = redis_config['database'] || 0