diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 12:09:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 12:09:05 +0000 |
commit | 5426ca9908085087d465fa52800335f408eb965a (patch) | |
tree | 6b442cff02fda9402fc7bb9cf9986e363dd5aaa6 /lib/api | |
parent | 67cdfd2683b89bce260600fa8925eefdcdf9e3e5 (diff) | |
download | gitlab-ce-5426ca9908085087d465fa52800335f408eb965a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/deploy_tokens.rb | 22 | ||||
-rw-r--r-- | lib/api/entities/deploy_token.rb | 3 |
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/api/deploy_tokens.rb b/lib/api/deploy_tokens.rb index bf82c63260d..3224157ca05 100644 --- a/lib/api/deploy_tokens.rb +++ b/lib/api/deploy_tokens.rb @@ -4,8 +4,6 @@ module API class DeployTokens < Grape::API include PaginationParams - before { authenticated_as_admin! } - desc 'Return all deploy tokens' do detail 'This feature was introduced in GitLab 12.9.' success Entities::DeployToken @@ -14,7 +12,27 @@ module API use :pagination end get 'deploy_tokens' do + authenticated_as_admin! + present paginate(DeployToken.all), with: Entities::DeployToken end + + params do + requires :id, type: Integer, desc: 'The ID of a project' + end + resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do + params do + use :pagination + end + desc 'List deploy tokens for a project' do + detail 'This feature was introduced in GitLab 12.9' + success Entities::DeployToken + end + get ':id/deploy_tokens' do + authorize!(:read_deploy_token, user_project) + + present paginate(user_project.deploy_tokens), with: Entities::DeployToken + end + end end end diff --git a/lib/api/entities/deploy_token.rb b/lib/api/entities/deploy_token.rb index cac6846a845..9c5bf54e299 100644 --- a/lib/api/entities/deploy_token.rb +++ b/lib/api/entities/deploy_token.rb @@ -3,7 +3,8 @@ module API module Entities class DeployToken < Grape::Entity - expose :id, :name, :username, :expires_at, :token, :scopes + # exposing :token is a security risk and should be avoided + expose :id, :name, :username, :expires_at, :scopes end end end |