summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2016-12-19 14:40:24 +0000
committerFilipa Lacerda <filipa@gitlab.com>2016-12-19 14:40:24 +0000
commit54ab4adc335a46eb38f43c93e3216c9029068fbf (patch)
tree9eb94d60fcf4172a35985af40d9fe7e45f081435 /lib/api/helpers.rb
parent083e185cdaee03e66dec0ab267a2f3b5d3dab9a7 (diff)
parent16f950b4c321708c8701e031316b5ed91c50f2eb (diff)
downloadgitlab-ce-54ab4adc335a46eb38f43c93e3216c9029068fbf.tar.gz
Merge branch 'master' into 19703-direct-link-pipelines
* master: (175 commits) Fix typo Always use `fixture_file_upload` helper to upload files in tests. Add CHANGELOG Fix extra spacing in all rgba methods in status file Improve spacing and fixes manual status color Add `ci-manual` status CSS with darkest gray color Move admin application spinach test to rspec Move admin deploy keys spinach test to rspec Fix CI/CD statuses actions' CSS on pipeline graphs Fix rubocop failures Store mattermost_url in settings Improve Mattermost Session specs Ensure the session is destroyed Improve session tests Setup mattermost session Fix link from doc/development/performance.md to 'Performance Monitoring' Fix query in Projects::ProjectMembersController to fetch members Improve test for sort dropdown on members page Fix sort dropdown alignment Undo changes on members search button stylesheet ...
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb15
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 746849ef4c0..4be659fc20b 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -2,8 +2,6 @@ module API
module Helpers
include Gitlab::Utils
- PRIVATE_TOKEN_HEADER = "HTTP_PRIVATE_TOKEN"
- PRIVATE_TOKEN_PARAM = :private_token
SUDO_HEADER = "HTTP_SUDO"
SUDO_PARAM = :sudo
@@ -308,7 +306,7 @@ module API
private
def private_token
- params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]
+ params[APIGuard::PRIVATE_TOKEN_PARAM] || env[APIGuard::PRIVATE_TOKEN_HEADER]
end
def warden
@@ -323,18 +321,11 @@ module API
warden.try(:authenticate) if %w[GET HEAD].include?(env['REQUEST_METHOD'])
end
- def find_user_by_private_token
- token = private_token
- return nil unless token.present?
-
- User.find_by_authentication_token(token) || User.find_by_personal_access_token(token)
- end
-
def initial_current_user
return @initial_current_user if defined?(@initial_current_user)
- @initial_current_user ||= find_user_by_private_token
- @initial_current_user ||= doorkeeper_guard
+ @initial_current_user ||= find_user_by_private_token(scopes: @scopes)
+ @initial_current_user ||= doorkeeper_guard(scopes: @scopes)
@initial_current_user ||= find_user_from_warden
unless @initial_current_user && Gitlab::UserAccess.new(@initial_current_user).allowed?