monitoring_controller_policy.rb 728 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::MonitoringControllerPolicy < Controllers::ApplicationControllerPolicy
  3. def health_check?
  4. token_or_permission?
  5. end
  6. def status?
  7. token_or_permission?
  8. end
  9. def amount_check?
  10. token_or_permission?
  11. end
  12. def token?
  13. monitoring_admin?
  14. end
  15. def restart_failed_jobs?
  16. monitoring_admin?
  17. end
  18. private
  19. def user_required?
  20. false
  21. end
  22. def token_or_permission?
  23. monitoring_admin? || valid_token_param?
  24. end
  25. def valid_token_param?
  26. Setting.get('monitoring_token') == record.params[:token]
  27. end
  28. def monitoring_admin?
  29. user.present? && user.permissions?('admin.monitoring')
  30. end
  31. end