summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/packages_access.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns/packages_access.rb')
-rw-r--r--app/controllers/concerns/packages_access.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/controllers/concerns/packages_access.rb b/app/controllers/concerns/packages_access.rb
new file mode 100644
index 00000000000..6df2e064bb2
--- /dev/null
+++ b/app/controllers/concerns/packages_access.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module PackagesAccess
+ extend ActiveSupport::Concern
+
+ included do
+ before_action :verify_packages_enabled!
+ before_action :verify_read_package!
+ end
+
+ private
+
+ def verify_packages_enabled!
+ render_404 unless Gitlab.config.packages.enabled
+ end
+
+ def verify_read_package!
+ authorize_read_package!(project)
+ end
+end