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

observability_controller.rb « groups « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4b1f2b582ce74b8f872c38bf99609494c003f79a (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
module Groups
  class ObservabilityController < Groups::ApplicationController
    feature_category :tracing

    content_security_policy do |p|
      next if p.directives.blank?

      default_frame_src = p.directives['frame-src'] || p.directives['default-src']

      # When ObservabilityUI is not authenticated, it needs to be able to redirect to the GL sign-in page, hence 'self'
      frame_src_values = Array.wrap(default_frame_src) | [observability_url, "'self'"]

      p.frame_src(*frame_src_values)
    end

    before_action :check_observability_allowed

    def dashboards
      render_observability
    end

    def manage
      render_observability
    end

    def explore
      render_observability
    end

    private

    def render_observability
      render 'observability', layout: 'group', locals: { base_layout: 'layouts/fullscreen' }
    end

    def self.observability_url
      Gitlab::Observability.observability_url
    end

    def observability_url
      self.class.observability_url
    end

    def check_observability_allowed
      return render_404 unless observability_url.present?

      render_404 unless can?(current_user, :read_observability, @group)
    end
  end
end