debian-mirror-gitlab/app/policies/base_policy.rb

24 lines
781 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require_dependency 'declarative_policy'
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
class BasePolicy < DeclarativePolicy::Base
desc "User is an instance admin"
with_options scope: :user, score: 0
condition(:admin) { @user&.admin? }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
with_options scope: :user, score: 0
condition(:external_user) { @user.nil? || @user.external? }
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
with_options scope: :user, score: 0
condition(:can_create_group) { @user&.can_create_group }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
desc "The application is restricted from public visibility"
condition(:restricted_public_level, scope: :global) do
2018-03-17 18:26:18 +05:30
Gitlab::CurrentSettings.current_application_settings.restricted_visibility_levels.include?(Gitlab::VisibilityLevel::PUBLIC)
2016-09-29 09:46:39 +05:30
end
2018-03-27 19:54:05 +05:30
# This is prevented in some cases in `gitlab-ee`
rule { default }.enable :read_cross_project
2016-09-29 09:46:39 +05:30
end