2018-07-24 10:30:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-05-13 05:08:37 -04:00
|
|
|
# Include this module to have an object respond to user messages without being
|
|
|
|
# a user.
|
|
|
|
#
|
|
|
|
# Use Case 1:
|
|
|
|
# Pass something else than the user to check policies. This defines several
|
|
|
|
# methods which the policy checker would call and check.
|
|
|
|
#
|
|
|
|
# Use Case 2:
|
|
|
|
# Access the API with non-user object such as deploy tokens. This defines
|
|
|
|
# several methods which the API auth flow would call.
|
2018-07-27 05:37:19 -04:00
|
|
|
module PolicyActor
|
2018-07-24 10:30:09 -04:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def blocked?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def admin?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def external?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def internal?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def access_locked?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def required_terms_not_accepted?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_create_group
|
|
|
|
false
|
|
|
|
end
|
2020-02-06 07:10:29 -05:00
|
|
|
|
|
|
|
def alert_bot?
|
|
|
|
false
|
|
|
|
end
|
2020-05-13 05:08:37 -04:00
|
|
|
|
2020-06-22 11:09:27 -04:00
|
|
|
def support_bot?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2020-12-11 13:09:57 -05:00
|
|
|
def security_bot?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2021-06-16 08:10:18 -04:00
|
|
|
def automation_bot?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2020-05-13 05:08:37 -04:00
|
|
|
def deactivated?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def confirmation_required_on_sign_in?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def can?(action, subject = :global)
|
|
|
|
Ability.allowed?(self, action, subject)
|
|
|
|
end
|
|
|
|
|
|
|
|
def preferred_language
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def requires_ldap_check?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def try_obtain_ldap_lease
|
|
|
|
nil
|
|
|
|
end
|
2020-11-11 07:09:06 -05:00
|
|
|
|
|
|
|
def can_read_all_resources?
|
|
|
|
false
|
|
|
|
end
|
2021-06-01 17:10:06 -04:00
|
|
|
|
2021-06-16 14:10:35 -04:00
|
|
|
def password_expired_if_applicable?
|
2021-06-01 17:10:06 -04:00
|
|
|
false
|
|
|
|
end
|
2021-06-10 17:10:02 -04:00
|
|
|
|
|
|
|
def from_ci_job_token?
|
|
|
|
false
|
|
|
|
end
|
2018-07-24 10:30:09 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
PolicyActor.prepend_mod_with('PolicyActor')
|