Module: Katello::Authorization::Repository::ClassMethods
- Defined in:
- app/models/katello/authorization/repository.rb
Instance Method Summary collapse
- #deletable ⇒ Object
- #editable ⇒ Object
- #exportable ⇒ Object
- #readable ⇒ Object
- #readable_as(user) ⇒ Object
- #readable_docker_catalog(host = nil) ⇒ Object
- #readable_docker_catalog_as(user) ⇒ Object
- #syncable ⇒ Object
Instance Method Details
#deletable ⇒ Object
68 69 70 |
# File 'app/models/katello/authorization/repository.rb', line 68 def deletable in_product(Katello::Product.(:destroy_products)) end |
#editable ⇒ Object
76 77 78 |
# File 'app/models/katello/authorization/repository.rb', line 76 def editable in_product(Katello::Product.editable) end |
#exportable ⇒ Object
64 65 66 |
# File 'app/models/katello/authorization/repository.rb', line 64 def exportable in_product(Katello::Product.exportable) end |
#readable ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/katello/authorization/repository.rb', line 24 def readable in_products = Repository.in_product(Katello::Product.(:view_products)).select(:id) in_environments = Repository.where(:environment_id => Katello::KTEnvironment.(:view_lifecycle_environments)).select(:id) in_content_views = Repository.joins(:content_view_repositories).where("#{ContentViewRepository.table_name}.content_view_id" => Katello::ContentView.readable).select(:id) in_versions = Repository.joins(:content_view_version).where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.readable).select(:id) joins(:root).where("#{Repository.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?)", in_products, in_content_views, in_versions, in_environments) end |
#readable_as(user) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/models/katello/authorization/repository.rb', line 32 def readable_as(user) in_products = Repository.in_product(Katello::Product.(user, :view_products)).select(:id) in_environments = Repository.where(:environment_id => Katello::KTEnvironment.(user, :view_lifecycle_environments)).select(:id) in_content_views = Repository.joins(:content_view_repositories).where("#{ContentViewRepository.table_name}.content_view_id" => Katello::ContentView.readable_as(user)).select(:id) in_versions = Repository.joins(:content_view_version).where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.readable_as(user)).select(:id) joins(:root).where("#{Repository.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?)", in_products, in_content_views, in_versions, in_environments) end |
#readable_docker_catalog(host = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/katello/authorization/repository.rb', line 40 def readable_docker_catalog(host = nil) #If host is identified in the request via certs or IP addr, and the host is registered (uuid != nil), show only # available repos in host's LCE scope if host && host&.content_facet&.uuid repo_ids = [] if host&.content_view_environments&.any? repo_ids = host.content_view_environments.flat_map do |cve| cve&.content_view_version&.repositories&.where(environment_id: cve.environment)&.pluck(:id) end repo_ids = repo_ids.compact.uniq end base_scope = Katello::Repository.non_archived.docker_type return base_scope.where(id: repo_ids) end readable_docker_catalog_as(User.current) end |
#readable_docker_catalog_as(user) ⇒ Object
58 59 60 61 62 |
# File 'app/models/katello/authorization/repository.rb', line 58 def readable_docker_catalog_as(user) table_name = Repository.table_name in_unauth_environments = Repository.joins(:environment).where("#{Katello::KTEnvironment.table_name}.registry_unauthenticated_pull" => true).select(:id) Repository.readable_as(user).or(Repository.joins(:root).where("#{table_name}.id in (?)", in_unauth_environments)).non_archived.docker_type end |