Handle invalid ssh exception
This commit is contained in:
parent
c48c0f95b2
commit
b03ee4666b
3 changed files with 14 additions and 2 deletions
|
@ -14,6 +14,10 @@ class ApplicationController < ActionController::Base
|
||||||
render "errors/gitolite", layout: "error"
|
render "errors/gitolite", layout: "error"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue_from Gitlab::Gitolite::InvalidKey do |exception|
|
||||||
|
render "errors/invalid_ssh_key", layout: "error"
|
||||||
|
end
|
||||||
|
|
||||||
rescue_from Encoding::CompatibilityError do |exception|
|
rescue_from Encoding::CompatibilityError do |exception|
|
||||||
render "errors/encoding", layout: "error", status: 404
|
render "errors/encoding", layout: "error", status: 404
|
||||||
end
|
end
|
||||||
|
|
3
app/views/errors/invalid_ssh_key.html.haml
Normal file
3
app/views/errors/invalid_ssh_key.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
%h1 Git Error
|
||||||
|
%hr
|
||||||
|
%p Seems like SSH Key you provided is not a valid SSH key.
|
|
@ -6,6 +6,7 @@ require 'fileutils'
|
||||||
module Gitlab
|
module Gitlab
|
||||||
class Gitolite
|
class Gitolite
|
||||||
class AccessDenied < StandardError; end
|
class AccessDenied < StandardError; end
|
||||||
|
class InvalidKey < StandardError; end
|
||||||
|
|
||||||
def set_key key_id, key_content, projects
|
def set_key key_id, key_content, projects
|
||||||
configure do |c|
|
configure do |c|
|
||||||
|
@ -190,8 +191,12 @@ module Gitlab
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
Gitlab::Logger.error(ex.message)
|
if ex.message =~ /is not a valid SSH key string/
|
||||||
raise Gitolite::AccessDenied.new("gitolite timeout")
|
raise Gitolite::InvalidKey.new("ssh key is not valid")
|
||||||
|
else
|
||||||
|
Gitlab::Logger.error(ex.message)
|
||||||
|
raise Gitolite::AccessDenied.new("gitolite timeout")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue