2020-12-03 18:10:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DependencyProxy
|
|
|
|
module GroupAccess
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
before_action :verify_dependency_proxy_enabled!
|
|
|
|
before_action :authorize_read_dependency_proxy!
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def verify_dependency_proxy_enabled!
|
2021-08-04 09:08:21 +00:00
|
|
|
render_404 unless group&.dependency_proxy_feature_available?
|
2020-12-03 18:10:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_read_dependency_proxy!
|
2021-08-04 09:08:21 +00:00
|
|
|
access_denied! unless can?(auth_user, :read_dependency_proxy, group)
|
2020-12-03 18:10:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_admin_dependency_proxy!
|
2021-08-04 09:08:21 +00:00
|
|
|
access_denied! unless can?(auth_user, :admin_dependency_proxy, group)
|
2020-12-03 18:10:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|