summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-02-05 14:42:01 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-02-11 10:29:14 +0100
commit442a49db2bc5e3f6cea827879fa4f5c532a5f6f1 (patch)
treee757605148341535d92d52da22ab46996702b8e4
parent28c4c949a5965f0328bb94d7ab1a318c9e226ff7 (diff)
downloadgitlab-ce-442a49db2bc5e3f6cea827879fa4f5c532a5f6f1.tar.gz
Skip authentication when requesting commit status badge
-rw-r--r--app/controllers/projects/commit_controller.rb8
-rw-r--r--config/routes.rb2
2 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 36fef1740e2..493cd332d9f 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -10,6 +10,11 @@ class Projects::CommitController < Projects::ApplicationController
before_action :commit
before_action :define_show_vars, only: [:show, :builds]
+ # Skip authentication for status badge only
+ skip_before_action :authenticate_user!, :reject_blocked!, :project,
+ :repository, :require_non_empty_project, :authorize_download_code!,
+ :commit, only: [:badge]
+
def show
return git_not_found! unless @commit
@@ -58,7 +63,8 @@ class Projects::CommitController < Projects::ApplicationController
end
def badge
- image = Ci::ImageForBuildService.new.execute(@project, ref: params[:id])
+ project = Project.find_with_namespace("#{params[:namespace_id]}/#{params[:project_id]}")
+ image = Ci::ImageForBuildService.new.execute(project, ref: params[:id])
send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml')
end
diff --git a/config/routes.rb b/config/routes.rb
index 152a04061f2..6b710bc45ea 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -498,7 +498,7 @@ Rails.application.routes.draw do
'/status/*id/badge',
to: 'commit#badge',
constraints: { format: /png/ },
- as: :commit_badge
+ as: :build_badge
)
end