Commit 8572eee7 authored by Marius Bobin's avatar Marius Bobin Committed by Kamil Trzciński

Fallback to mirror_user for PR pipelines

Pipelines are created without an user if current_user is nil
and the pipeline triggerer is listed as API.
With this commit the pipeline triggerer will fallback to the
mirror_user that set up the project.
parent f80dd77c
---
title: Default current user to mirror user when creating pipelines for GitHub pull requests
merge_request: 19072
author:
type: fixed
......@@ -20,7 +20,7 @@ module API
def valid_github_signature?
request.body.rewind
token = project.external_webhook_token
token = project.external_webhook_token.to_s
payload_body = request.body.read
signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), token, payload_body)
......@@ -43,7 +43,7 @@ module API
end
def process_pull_request
external_pull_request = ProcessGithubPullRequestEventService.new(project, current_user).execute(params)
external_pull_request = ProcessGithubPullRequestEventService.new(project, mirror_user).execute(params)
if external_pull_request
render_validation_error!(external_pull_request)
......@@ -53,10 +53,14 @@ module API
end
def start_pull_mirroring
result = StartPullMirroringService.new(project, current_user).execute
result = StartPullMirroringService.new(project, mirror_user).execute
render_api_error!(result[:message], result[:http_status]) if result[:status] == :error
end
def mirror_user
current_user || project.mirror_user
end
end
params do
......
This diff is collapsed.
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