Commit b03ee4666bc5dfa3c509768918cbc8a477d24efb
1 parent
c48c0f95
Exists in
master
and in
4 other branches
Handle invalid ssh exception
Showing
3 changed files
with
14 additions
and
2 deletions
Show diff stats
app/controllers/application_controller.rb
... | ... | @@ -14,6 +14,10 @@ class ApplicationController < ActionController::Base |
14 | 14 | render "errors/gitolite", layout: "error" |
15 | 15 | end |
16 | 16 | |
17 | + rescue_from Gitlab::Gitolite::InvalidKey do |exception| | |
18 | + render "errors/invalid_ssh_key", layout: "error" | |
19 | + end | |
20 | + | |
17 | 21 | rescue_from Encoding::CompatibilityError do |exception| |
18 | 22 | render "errors/encoding", layout: "error", status: 404 |
19 | 23 | end | ... | ... |
lib/gitlab/backend/gitolite.rb
... | ... | @@ -6,6 +6,7 @@ require 'fileutils' |
6 | 6 | module Gitlab |
7 | 7 | class Gitolite |
8 | 8 | class AccessDenied < StandardError; end |
9 | + class InvalidKey < StandardError; end | |
9 | 10 | |
10 | 11 | def set_key key_id, key_content, projects |
11 | 12 | configure do |c| |
... | ... | @@ -190,8 +191,12 @@ module Gitlab |
190 | 191 | end |
191 | 192 | end |
192 | 193 | rescue Exception => ex |
193 | - Gitlab::Logger.error(ex.message) | |
194 | - raise Gitolite::AccessDenied.new("gitolite timeout") | |
194 | + if ex.message =~ /is not a valid SSH key string/ | |
195 | + raise Gitolite::InvalidKey.new("ssh key is not valid") | |
196 | + else | |
197 | + Gitlab::Logger.error(ex.message) | |
198 | + raise Gitolite::AccessDenied.new("gitolite timeout") | |
199 | + end | |
195 | 200 | end |
196 | 201 | end |
197 | 202 | end | ... | ... |