BigW Consortium Gitlab

global_policy.rb 1.43 KB
Newer Older
1
class GlobalPolicy < BasePolicy
2 3 4
  desc "User is blocked"
  with_options scope: :user, score: 0
  condition(:blocked) { @user.blocked? }
5

6 7 8
  desc "User is an internal user"
  with_options scope: :user, score: 0
  condition(:internal) { @user.internal? }
9

10 11 12
  desc "User's access has been locked"
  with_options scope: :user, score: 0
  condition(:access_locked) { @user.access_locked? }
13

14 15
  condition(:can_create_fork, scope: :user) { @user.manageable_namespaces.any? { |namespace| @user.can?(:create_projects, namespace) } }

16 17 18 19 20 21 22 23
  rule { anonymous }.policy do
    prevent :log_in
    prevent :access_api
    prevent :access_git
    prevent :receive_notifications
    prevent :use_quick_actions
    prevent :create_group
  end
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

  rule { default }.policy do
    enable :log_in
    enable :access_api
    enable :access_git
    enable :receive_notifications
    enable :use_quick_actions
  end

  rule { blocked | internal }.policy do
    prevent :log_in
    prevent :access_api
    prevent :access_git
    prevent :receive_notifications
    prevent :use_quick_actions
  end

  rule { can_create_group }.policy do
    enable :create_group
  end

45 46 47 48
  rule { can_create_fork }.policy do
    enable :create_fork
  end

49 50
  rule { access_locked }.policy do
    prevent :log_in
51
  end
52

53
  rule { ~(anonymous & restricted_public_level) }.policy do
54
    enable :read_users_list
55
  end
56 57 58 59 60

  rule { admin }.policy do
    enable :read_custom_attribute
    enable :update_custom_attribute
  end
61
end