Commit 442a49db authored by Grzegorz Bizon's avatar Grzegorz Bizon

Skip authentication when requesting commit status badge

parent 28c4c949
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment