diff options
author | James Fargher <proglottis@gmail.com> | 2019-05-02 13:07:38 +1200 |
---|---|---|
committer | James Fargher <proglottis@gmail.com> | 2019-05-07 08:37:04 +1200 |
commit | beb66cfcba26d0796644ccce2dfac8c65a808144 (patch) | |
tree | 6bb32fccb64f91776e946d84c5717d1ae52a9d7e /app/controllers/concerns | |
parent | 8db382b05545fdef0a60bcff65f8c23e8b1ed282 (diff) | |
download | gitlab-ce-beb66cfcba26d0796644ccce2dfac8c65a808144.tar.gz |
Check instance cluster feature at policy level
Try to simplify feature flag checks by using policies
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/enforces_admin_authentication.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/concerns/enforces_admin_authentication.rb b/app/controllers/concerns/enforces_admin_authentication.rb new file mode 100644 index 00000000000..3ef92730df6 --- /dev/null +++ b/app/controllers/concerns/enforces_admin_authentication.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# == EnforcesAdminAuthentication +# +# Controller concern to enforce that users are authenticated as admins +# +# Upon inclusion, adds `authenticate_admin!` as a before_action +# +module EnforcesAdminAuthentication + extend ActiveSupport::Concern + + included do + before_action :authenticate_admin! + end + + def authenticate_admin! + render_404 unless current_user.admin? + end +end |