Commit e48313f709e8d99e954a98bc569cfaccd65efa4d
Merge branch 'api_token_cast' of /home/git/repositories/gitlab/gitlabhq into 6-2-stable
Showing
3 changed files
with
8 additions
and
3 deletions
Show diff stats
VERSION
lib/api/helpers.rb
@@ -6,19 +6,23 @@ module API | @@ -6,19 +6,23 @@ module API | ||
6 | SUDO_PARAM = :sudo | 6 | SUDO_PARAM = :sudo |
7 | 7 | ||
8 | def current_user | 8 | def current_user |
9 | - @current_user ||= User.find_by_authentication_token(params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]) | 9 | + private_token = (params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]).to_s |
10 | + @current_user ||= User.find_by_authentication_token(private_token) | ||
10 | identifier = sudo_identifier() | 11 | identifier = sudo_identifier() |
12 | + | ||
11 | # If the sudo is the current user do nothing | 13 | # If the sudo is the current user do nothing |
12 | if (identifier && !(@current_user.id == identifier || @current_user.username == identifier)) | 14 | if (identifier && !(@current_user.id == identifier || @current_user.username == identifier)) |
13 | render_api_error!('403 Forbidden: Must be admin to use sudo', 403) unless @current_user.is_admin? | 15 | render_api_error!('403 Forbidden: Must be admin to use sudo', 403) unless @current_user.is_admin? |
14 | @current_user = User.by_username_or_id(identifier) | 16 | @current_user = User.by_username_or_id(identifier) |
15 | not_found!("No user id or username for: #{identifier}") if @current_user.nil? | 17 | not_found!("No user id or username for: #{identifier}") if @current_user.nil? |
16 | end | 18 | end |
19 | + | ||
17 | @current_user | 20 | @current_user |
18 | end | 21 | end |
19 | 22 | ||
20 | def sudo_identifier() | 23 | def sudo_identifier() |
21 | identifier ||= params[SUDO_PARAM] ||= env[SUDO_HEADER] | 24 | identifier ||= params[SUDO_PARAM] ||= env[SUDO_HEADER] |
25 | + | ||
22 | # Regex for integers | 26 | # Regex for integers |
23 | if (!!(identifier =~ /^[0-9]+$/)) | 27 | if (!!(identifier =~ /^[0-9]+$/)) |
24 | identifier.to_i | 28 | identifier.to_i |
@@ -29,6 +33,7 @@ module API | @@ -29,6 +33,7 @@ module API | ||
29 | 33 | ||
30 | def set_current_user_for_thread | 34 | def set_current_user_for_thread |
31 | Thread.current[:current_user] = current_user | 35 | Thread.current[:current_user] = current_user |
36 | + | ||
32 | begin | 37 | begin |
33 | yield | 38 | yield |
34 | ensure | 39 | ensure |
lib/tasks/gitlab/check.rake
@@ -736,7 +736,7 @@ namespace :gitlab do | @@ -736,7 +736,7 @@ namespace :gitlab do | ||
736 | end | 736 | end |
737 | 737 | ||
738 | def check_gitlab_shell | 738 | def check_gitlab_shell |
739 | - required_version = Gitlab::VersionInfo.new(1, 7, 4) | 739 | + required_version = Gitlab::VersionInfo.new(1, 7, 8) |
740 | current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) | 740 | current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) |
741 | 741 | ||
742 | print "GitLab Shell version >= #{required_version} ? ... " | 742 | print "GitLab Shell version >= #{required_version} ? ... " |