debian-mirror-gitlab/app/controllers/clusters/base_controller.rb

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

48 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
class Clusters::BaseController < ApplicationController
include RoutableActions
skip_before_action :authenticate_user!
2022-04-04 11:22:00 +05:30
before_action :authorize_admin_cluster!, except: [:show, :index, :new, :authorize_aws_role, :update]
2018-12-13 13:39:08 +05:30
helper_method :clusterable
2021-01-03 14:25:43 +05:30
feature_category :kubernetes_management
2022-07-16 23:28:13 +05:30
urgency :low, [
:index, :show, :environments, :cluster_status, :prometheus_proxy,
:destroy, :new_cluster_docs, :connect, :new, :create_user
]
2021-01-03 14:25:43 +05:30
2018-12-13 13:39:08 +05:30
private
def cluster
@cluster ||= clusterable.clusters.find(params[:id])
.present(current_user: current_user)
end
def authorize_update_cluster!
2022-04-04 11:22:00 +05:30
access_denied! unless can?(current_user, :update_cluster, clusterable)
2018-12-13 13:39:08 +05:30
end
def authorize_admin_cluster!
2022-04-04 11:22:00 +05:30
access_denied! unless can?(current_user, :admin_cluster, clusterable)
2018-12-13 13:39:08 +05:30
end
def authorize_read_cluster!
access_denied! unless can?(current_user, :read_cluster, clusterable)
end
def authorize_create_cluster!
access_denied! unless can?(current_user, :create_cluster, clusterable)
end
2019-12-04 20:38:33 +05:30
def authorize_read_prometheus!
access_denied! unless can?(current_user, :read_prometheus, clusterable)
end
2018-12-13 13:39:08 +05:30
def clusterable
raise NotImplementedError
end
end