Skip to content
Snippets Groups Projects

Add support to configure webhook_timeout in gitlab.yaml

Closed gitlab-qa-bot requested to merge github/fork/wesgurn/master into master
3 files
+ 27
20
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 33
2
module API
module APIHelpers
PRIVATE_TOKEN_HEADER = "HTTP_PRIVATE_TOKEN"
PRIVATE_TOKEN_PARAM = :private_token
SUDO_HEADER ="HTTP_SUDO"
SUDO_PARAM = :sudo
def current_user
@current_user ||= User.find_by_authentication_token(params[:private_token] || env["HTTP_PRIVATE_TOKEN"])
@current_user ||= User.find_by_authentication_token(params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER])
identifier = sudo_identifier()
# If the sudo is the current user do nothing
if (identifier && !(@current_user.id == identifier || @current_user.username == identifier))
render_api_error!('403 Forbidden: Must be admin to use sudo', 403) unless @current_user.is_admin?
begin
@current_user = User.by_username_or_id(identifier)
rescue => ex
not_found!("No user id or username for: #{identifier}")
end
not_found!("No user id or username for: #{identifier}") if current_user.nil?
end
@current_user
end
def sudo_identifier()
identifier ||= params[SUDO_PARAM] ||= env[SUDO_HEADER]
# Regex for integers
if (!!(identifier =~ /^[0-9]+$/))
identifier.to_i
else
identifier
end
end
def user_project
@@ -37,6 +64,10 @@ module API
end
end
def authorize_admin_project
authorize! :admin_project, user_project
end
def can?(object, action, subject)
abilities.allowed?(object, action, subject)
end
@@ -55,7 +86,7 @@ module API
def attributes_for_keys(keys)
attrs = {}
keys.each do |key|
attrs[key] = params[key] if params[key].present?
attrs[key] = params[key] if params[key].present? or (params.has_key?(key) and params[key] == false)
end
attrs
end
Loading