From 62a27f38b5724dfed4e378e5592cdba4da2c7577 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 8 Nov 2013 18:49:38 +0200 Subject: [PATCH 1/3] Make sure private_token for API is a string Signed-off-by: Dmitriy Zaporozhets --- lib/api/helpers.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index edc662eaaa..b0f8d5a6da 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -6,19 +6,23 @@ module API SUDO_PARAM = :sudo def current_user - @current_user ||= User.find_by_authentication_token(params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]) + private_token = (params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]).to_s + @current_user ||= User.find_by_authentication_token(private_token) 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? @current_user = User.by_username_or_id(identifier) 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 @@ -29,6 +33,7 @@ module API def set_current_user_for_thread Thread.current[:current_user] = current_user + begin yield ensure From 059f7decd9858df4843fe42820a44c6b5d580a2e Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 14 Nov 2013 13:16:28 +0100 Subject: [PATCH 2/3] Bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index bee9433817..42cc526d6c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.2.3 +6.2.4 From 3909048279a84fab5e16468d83c45f55db1178c1 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 14 Nov 2013 14:01:06 +0100 Subject: [PATCH 3/3] Use gitlab-shell 1.7.8 --- lib/tasks/gitlab/check.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 3c92dac8b8..5e49a2e591 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -736,7 +736,7 @@ namespace :gitlab do end def check_gitlab_shell - required_version = Gitlab::VersionInfo.new(1, 7, 4) + required_version = Gitlab::VersionInfo.new(1, 7, 8) current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) print "GitLab Shell version >= #{required_version} ? ... "