debian-mirror-gitlab/app/controllers/concerns/project_unauthorized.rb

22 lines
680 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
module ProjectUnauthorized
2019-09-04 21:01:54 +05:30
module ControllerActions
def self.on_routable_not_found
2021-09-30 23:02:18 +05:30
lambda do |routable, path_info|
2019-09-04 21:01:54 +05:30
return unless routable.is_a?(Project)
label = routable.external_authorization_classification_label
2019-07-07 11:18:12 +05:30
rejection_reason = nil
unless ::Gitlab::ExternalAuthorization.access_allowed?(current_user, label)
rejection_reason = ::Gitlab::ExternalAuthorization.rejection_reason(current_user, label)
rejection_reason ||= _('External authorization denied access to this project')
end
2019-09-04 21:01:54 +05:30
access_denied!(rejection_reason) if rejection_reason
2019-07-07 11:18:12 +05:30
end
end
2018-12-13 13:39:08 +05:30
end
end