diff options
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 3 | ||||
-rw-r--r-- | lib/api/helpers.rb | 2 | ||||
-rw-r--r-- | lib/api/internal.rb | 13 | ||||
-rw-r--r-- | lib/api/project_hooks.rb | 16 |
4 files changed, 27 insertions, 7 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index ffa3e8a149e..80e9470195e 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -30,7 +30,8 @@ module API end class ProjectHook < Hook - expose :project_id, :push_events, :issues_events, :merge_requests_events + expose :project_id, :push_events + expose :issues_events, :merge_requests_events, :tag_push_events end class ForkedFromProject < Grape::Entity diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 3a619169eca..3262884f6d3 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -71,7 +71,7 @@ module API forbidden! unless current_user.is_admin? end - def authorize! action, subject + def authorize!(action, subject) unless abilities.allowed?(current_user, action, subject) forbidden! end diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 5f484f63418..9ac659f50fd 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -14,13 +14,20 @@ module API # post "/allowed" do status 200 + project_path = params[:project] # Check for *.wiki repositories. # Strip out the .wiki from the pathname before finding the # project. This applies the correct project permissions to # the wiki repository as well. - project_path = params[:project] - project_path.gsub!(/\.wiki/,'') if project_path =~ /\.wiki/ + access = + if project_path =~ /\.wiki\Z/ + project_path.sub!(/\.wiki\Z/, '') + Gitlab::GitAccessWiki.new + else + Gitlab::GitAccess.new + end + project = Project.find_with_namespace(project_path) return false unless project @@ -32,7 +39,7 @@ module API return false unless actor - Gitlab::GitAccess.new.allowed?( + access.allowed?( actor, params[:action], project, diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb index 79c3d122d32..7d056b9bf58 100644 --- a/lib/api/project_hooks.rb +++ b/lib/api/project_hooks.rb @@ -38,7 +38,13 @@ module API # POST /projects/:id/hooks post ":id/hooks" do required_attributes! [:url] - attrs = attributes_for_keys [:url, :push_events, :issues_events, :merge_requests_events] + attrs = attributes_for_keys [ + :url, + :push_events, + :issues_events, + :merge_requests_events, + :tag_push_events + ] @hook = user_project.hooks.new(attrs) if @hook.save @@ -62,7 +68,13 @@ module API put ":id/hooks/:hook_id" do @hook = user_project.hooks.find(params[:hook_id]) required_attributes! [:url] - attrs = attributes_for_keys [:url, :push_events, :issues_events, :merge_requests_events] + attrs = attributes_for_keys [ + :url, + :push_events, + :issues_events, + :merge_requests_events, + :tag_push_events + ] if @hook.update_attributes attrs present @hook, with: Entities::ProjectHook |