debian-mirror-gitlab/app/controllers/groups/observability_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.2 KiB
Ruby
Raw Normal View History

2022-10-11 01:57:18 +05:30
# 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'
2023-01-13 00:05:48 +05:30
frame_src_values = Array.wrap(default_frame_src) | [observability_url, "'self'"]
2022-10-11 01:57:18 +05:30
p.frame_src(*frame_src_values)
end
2023-01-13 00:05:48 +05:30
before_action :check_observability_allowed
2022-10-11 01:57:18 +05:30
2023-01-13 00:05:48 +05:30
def dashboards
render_observability
end
2022-10-11 01:57:18 +05:30
2023-01-13 00:05:48 +05:30
def manage
render_observability
end
2022-10-11 01:57:18 +05:30
2023-01-13 00:05:48 +05:30
def explore
render_observability
2022-10-11 01:57:18 +05:30
end
private
2023-01-13 00:05:48 +05:30
def render_observability
render 'observability', layout: 'group', locals: { base_layout: 'layouts/fullscreen' }
end
2022-10-11 01:57:18 +05:30
def self.observability_url
2023-01-13 00:05:48 +05:30
Gitlab::Observability.observability_url
end
2022-10-11 01:57:18 +05:30
2023-01-13 00:05:48 +05:30
def observability_url
self.class.observability_url
2022-10-11 01:57:18 +05:30
end
def check_observability_allowed
2023-01-13 00:05:48 +05:30
return render_404 unless observability_url.present?
2022-10-11 01:57:18 +05:30
render_404 unless can?(current_user, :read_observability, @group)
end
end
end