Introduce PolicyCheckable for checking policies
This commit is contained in:
parent
3f14c56bfe
commit
e3aaa56c92
3 changed files with 38 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
class DeployToken < ActiveRecord::Base
|
||||
include Expirable
|
||||
include TokenAuthenticatable
|
||||
include PolicyCheckable
|
||||
add_authentication_token_field :token
|
||||
|
||||
AVAILABLE_SCOPES = %i(read_repository read_registry).freeze
|
||||
|
@ -58,10 +59,6 @@ class DeployToken < ActiveRecord::Base
|
|||
write_attribute(:expires_at, value.presence || Forever.date)
|
||||
end
|
||||
|
||||
def admin?
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ensure_at_least_one_scope
|
||||
|
|
36
app/policies/concerns/policy_checkable.rb
Normal file
36
app/policies/concerns/policy_checkable.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Include this module if we want to pass something else than the user to
|
||||
# check policies. This defines several methods which the policy checker
|
||||
# would call and check.
|
||||
module PolicyCheckable
|
||||
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
|
||||
end
|
|
@ -43,6 +43,7 @@ module Gitlab
|
|||
#{config.root}/app/models/members
|
||||
#{config.root}/app/models/project_services
|
||||
#{config.root}/app/workers/concerns
|
||||
#{config.root}/app/policies/concerns
|
||||
#{config.root}/app/services/concerns
|
||||
#{config.root}/app/serializers/concerns
|
||||
#{config.root}/app/finders/concerns
|
||||
|
|
Loading…
Reference in a new issue