Welcome to mirror list, hosted at ThFree Co, Russian Federation.

forward_event_worker.rb « jira_connect « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 877ab46cfe5eda8857f209ca4dbb78b5ff7d90a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module JiraConnect
  class ForwardEventWorker # rubocop:disable Scalability/IdempotentWorker
    include ApplicationWorker

    queue_namespace :jira_connect
    feature_category :integrations
    worker_has_external_dependencies!

    def perform(installation_id, base_path, event_path)
      installation = JiraConnectInstallation.find_by_id(installation_id)

      return if installation&.instance_url.nil?

      proxy_url = installation.instance_url + event_path
      qsh = Atlassian::Jwt.create_query_string_hash(proxy_url, 'POST', installation.instance_url + base_path)
      jwt = Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret)

      Gitlab::HTTP.post(proxy_url, headers: { 'Authorization' => "JWT #{jwt}" })
    ensure
      installation.destroy if installation
    end
  end
end