From 95594cfb7a2bafc1b66d4463142196d3d3dadf92 Mon Sep 17 00:00:00 2001 From: Bernhard Suttner Date: Wed, 15 Nov 2017 22:52:18 +0100 Subject: [PATCH] Fixes #15068 - Provide a way to select SSL certs for a product --- .../api/v2/content_credentials_controller.rb | 115 ++++++++++++++++++ .../katello/api/v2/gpg_keys_controller.rb | 5 + .../katello/api/v2/products_controller.rb | 32 ++++- .../gpg_key_content_type_validator.rb | 22 ++++ app/models/katello/glue/pulp/repo.rb | 6 + app/models/katello/gpg_key.rb | 15 ++- app/models/katello/product.rb | 4 + .../v2/content_credentials/index.json.rabl | 3 + .../api/v2/content_credentials/show.json.rabl | 70 +++++++++++ .../katello/api/v2/products/base.json.rabl | 3 + .../katello/api/v2/products/show.json.rabl | 12 ++ config/routes/api/v2.rb | 8 ++ ...0171110082124_add_ssl_certs_to_products.rb | 26 ++++ .../bastion-katello-bootstrap.js | 2 +- .../bastion_katello/bastion_katello.js | 4 +- .../content-credential.factory.js | 63 ++++++++++ .../content-credentials.controller.js} | 16 +-- .../content-credentials.module.js} | 6 +- .../content-credentials.routes.js | 76 ++++++++++++ .../content-type.filter.js | 25 ++++ ...ent-credential-details-info.controller.js} | 20 +-- .../content-credential-details.controller.js | 48 ++++++++ .../content-credential-products.controller.js | 36 ++++++ ...tent-credential-repositories.controller.js | 36 ++++++ .../views/content-credential-details.html | 36 ++++++ .../views/content-credential-info.html} | 30 +++-- .../views/content-credential-products.html} | 8 +- .../content-credential-repositories.html} | 6 +- .../new/new-content-credential.controller.js | 39 ++++++ .../new/views/new-content-credential.html | 53 ++++++++ .../views/content-credentials.html | 51 ++++++++ .../details/gpg-key-details.controller.js | 48 -------- .../details/gpg-key-products.controller.js | 36 ------ .../gpg-key-repositories.controller.js | 36 ------ .../details/views/gpg-key-details.html | 36 ------ .../gpg-keys/gpg-key.factory.js | 43 ------- .../gpg-keys/gpg-keys.routes.js | 76 ------------ .../gpg-keys/new/new-gpg-key.controller.js | 39 ------ .../gpg-keys/new/views/new-gpg-key.html | 44 ------- .../gpg-keys/views/gpg-keys.html | 46 ------- .../bastion_katello/katello-features.run.js | 10 +- .../organizations/fenced-pages.service.js | 2 +- .../product-details-info.controller.js | 37 +++++- .../repository-details-info.controller.js | 12 +- .../details/views/repository-info.html | 2 +- .../new/new-repository.controller.js | 10 +- .../new/views/new-repository.html | 2 +- .../products/details/views/product-info.html | 24 ++++ .../discovery/discovery-create.controller.js | 14 +-- .../discovery/views/discovery-create.html | 6 +- .../products/new/product-form.controller.js | 14 +-- .../products/new/views/product-new-form.html | 31 ++++- .../products/products.module.js | 2 +- .../lib/bastion_katello/engine.rb | 2 +- lib/katello/permission_creator.rb | 24 ++++ lib/katello/plugin.rb | 8 +- 56 files changed, 983 insertions(+), 497 deletions(-) create mode 100644 app/controllers/katello/api/v2/content_credentials_controller.rb create mode 100644 app/lib/katello/validators/gpg_key_content_type_validator.rb create mode 100644 app/views/katello/api/v2/content_credentials/index.json.rabl create mode 100644 app/views/katello/api/v2/content_credentials/show.json.rabl create mode 100644 db/migrate/20171110082124_add_ssl_certs_to_products.rb create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credential.factory.js rename engines/bastion_katello/app/assets/javascripts/bastion_katello/{gpg-keys/gpg-keys.controller.js => content-credentials/content-credentials.controller.js} (51%) rename engines/bastion_katello/app/assets/javascripts/bastion_katello/{gpg-keys/gpg-keys.module.js => content-credentials/content-credentials.module.js} (55%) create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.routes.js create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-type.filter.js rename engines/bastion_katello/app/assets/javascripts/bastion_katello/{gpg-keys/details/gpg-key-details-info.controller.js => content-credentials/details/content-credential-details-info.controller.js} (57%) create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details.controller.js create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-products.controller.js create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-repositories.controller.js create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-details.html rename engines/bastion_katello/app/assets/javascripts/bastion_katello/{gpg-keys/details/views/gpg-key-info.html => content-credentials/details/views/content-credential-info.html} (56%) rename engines/bastion_katello/app/assets/javascripts/bastion_katello/{gpg-keys/details/views/gpg-key-products.html => content-credentials/details/views/content-credential-products.html} (71%) rename engines/bastion_katello/app/assets/javascripts/bastion_katello/{gpg-keys/details/views/gpg-key-repositories.html => content-credentials/details/views/content-credential-repositories.html} (78%) create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/new-content-credential.controller.js create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html create mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/views/content-credentials.html delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-details.controller.js delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-products.controller.js delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-repositories.controller.js delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-details.html delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-key.factory.js delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.routes.js delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/new-gpg-key.controller.js delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/views/new-gpg-key.html delete mode 100644 engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/views/gpg-keys.html diff --git a/app/controllers/katello/api/v2/content_credentials_controller.rb b/app/controllers/katello/api/v2/content_credentials_controller.rb new file mode 100644 index 00000000000..13df4dde58a --- /dev/null +++ b/app/controllers/katello/api/v2/content_credentials_controller.rb @@ -0,0 +1,115 @@ +module Katello + class Api::V2::ContentCredentialsController < Api::V2::ApiController + include Katello::Concerns::FilteredAutoCompleteSearch + before_action :authorize + before_action :find_organization, :only => [:create, :index, :auto_complete_search] + before_action :find_content_credential, :only => [:show, :update, :destroy, :content, :set_content] + skip_before_action :check_content_type, :only => [:create, :content, :set_content] + + def resource_class + Katello::GpgKey + end + + def_param_group :content_credential do + param :name, :identifier, :action_aware => true, :required => true, :desc => N_("identifier of the content credential") + param :content_type, String, :action_aware => true, :required => true, :desc => N_("type of content") + param :content, String, :action_aware => true, :required => true, :desc => N_("public key block in DER encoding / certificate content") + end + + resource_description do + description <<-DESC + # Description + + Content Credentials are used to store credentials like GPG Keys and Certificates for the authentication + to Products / Repositories. + DESC + api_version "v2" + end + + api :GET, "/content_credentials", N_("List content credentials") + param :organization_id, :number, :desc => N_("organization identifier"), :required => true + param :name, String, :desc => N_("name of the Content Credential"), :required => false + param :content_type, String, :desc => N_("type of content"), :required => false + param_group :search, Api::V2::ApiController + def index + respond(:collection => scoped_search(index_relation.uniq, :name, :asc)) + end + + def index_relation + query = GpgKey.readable.where(:organization_id => @organization.id) + query = query.where(:name => params[:name]) if params[:name] + query + end + + api :POST, "/content_credentials", N_("Create a content credential") + param :organization_id, :number, :desc => N_("organization identifier"), :required => true + param_group :content_credential, :as => :create + def create + filepath = params.try(:[], :file_path).try(:path) + + content = nil + if filepath + content = File.open(filepath, "rb") { |file| file.read } + else + content = params[:content] + end + + content_credential = @organization.gpg_keys.create!(content_credential_params.merge(:content => content)) + respond_for_show(:resource => content_credential) + end + + api :GET, "/content_credentials/:id", N_("Show a content credential") + param :id, :number, :desc => N_("content credential numeric identifier"), :required => true + def show + respond_for_show(:resource => @content_credential) + end + + api :PUT, "/content_credentials/:id", N_("Update a content credential") + param :id, :number, :desc => N_("content credential numeric identifier"), :required => true + param_group :content_credential + def update + @content_credential.update_attributes!(content_credential_params) + respond_for_show(:resource => @content_credential) + end + + api :DELETE, "/content_credentials/:id", N_("Destroy a content credential") + param :id, :number, :desc => N_("content credential numeric identifier"), :required => true + def destroy + @content_credential.destroy + respond_for_destroy + end + + api :GET, "/content_credentials/:id/content", N_("Return the content of a content credential, used directly by yum") + param :id, :number, :required => true + def content + render(:plain => @content_credential.content, :layout => false) + end + + api :POST, "/content_credentials/:id/content", N_("Upload content credential contents") + param :id, :number, :desc => N_("content credential numeric identifier"), :required => true + param :content, File, :desc => N_("file contents"), :required => true + def set_content + filepath = params.try(:[], :content).try(:path) + + if filepath + content = File.open(filepath, "rb") { |file| file.read } + @content_credential.update_attributes!(:content => content) + render :json => {:status => "success"} + else + fail HttpErrors::BadRequest, _("No file uploaded") + end + end + + protected + + def find_content_credential + @content_credential = GpgKey.find(params[:id]) + rescue ActiveRecord::RecordNotFound + raise HttpErrors::NotFound, _("Couldn't find Content Credential '%s'") % params[:id] + end + + def content_credential_params + params.permit(:name, :content_type, :content) + end + end +end diff --git a/app/controllers/katello/api/v2/gpg_keys_controller.rb b/app/controllers/katello/api/v2/gpg_keys_controller.rb index b38806c6e9d..004ab3a79d3 100644 --- a/app/controllers/katello/api/v2/gpg_keys_controller.rb +++ b/app/controllers/katello/api/v2/gpg_keys_controller.rb @@ -1,6 +1,7 @@ module Katello class Api::V2::GpgKeysController < Api::V2::ApiController include Katello::Concerns::FilteredAutoCompleteSearch + before_action :deprecated before_action :authorize before_action :find_organization, :only => [:create, :index, :auto_complete_search] before_action :find_gpg_key, :only => [:show, :update, :destroy, :content, :set_content] @@ -103,5 +104,9 @@ def find_gpg_key def gpg_key_params params.permit(:name, :content) end + + def deprecated + ::Foreman::Deprecation.api_deprecation_warning("it will be removed in Katello 4.0, Please see /api/v2/content_credentials") + end end end diff --git a/app/controllers/katello/api/v2/products_controller.rb b/app/controllers/katello/api/v2/products_controller.rb index a80dd9e6692..9db89dbff08 100644 --- a/app/controllers/katello/api/v2/products_controller.rb +++ b/app/controllers/katello/api/v2/products_controller.rb @@ -7,6 +7,9 @@ class Api::V2::ProductsController < Api::V2::ApiController before_action :find_product, :only => [:update, :destroy, :sync] before_action :find_organization_from_product, :only => [:update] before_action :authorize_gpg_key, :only => [:update, :create] + before_action :authorize_ssl_ca_cert, :only => [:update, :create] + before_action :authorize_ssl_client_cert, :only => [:update, :create] + before_action :authorize_ssl_client_key, :only => [:update, :create] resource_description do api_version "v2" @@ -15,6 +18,9 @@ class Api::V2::ProductsController < Api::V2::ApiController def_param_group :product do param :description, String, :desc => N_("Product description") param :gpg_key_id, :number, :desc => N_("Identifier of the GPG key") + param :ssl_ca_cert_id, :number, :desc => N_("Idenifier of the SSL CA Cert") + param :ssl_client_cert_id, :number, :desc => N_("Identifier of the SSL Client Cert") + param :ssl_client_key_id, :number, :desc => N_("Identifier of the SSL Client Key") param :sync_plan_id, :number, :desc => N_("Plan numeric identifier"), :allow_nil => true end @@ -145,12 +151,36 @@ def authorize_gpg_key end end + def authorize_ssl_ca_cert + ssl_ca_cert_id = product_params[:ssl_ca_cert_id] + if ssl_ca_cert_id + ssl_ca_cert = GpgKey.readable.where(:id => ssl_ca_cert_id, :organization_id => @organization).first + fail HttpErrors::NotFound, _("Couldn't find ssl ca cert '%s'") % ssl_ca_cert_id if ssl_ca_cert.nil? + end + end + + def authorize_ssl_client_cert + ssl_client_cert_id = product_params[:ssl_client_cert_id] + if ssl_client_cert_id + ssl_client_cert = GpgKey.readable.where(:id => ssl_client_cert_id, :organization_id => @organization).first + fail HttpErrors::NotFound, _("Couldn't find ssl client cert '%s'") % ssl_client_cert_id if ssl_client_cert.nil? + end + end + + def authorize_ssl_client_key + ssl_client_key_id = product_params[:ssl_client_key_id] + if ssl_client_key_id + ssl_client_key = GpgKey.readable.where(:id => ssl_client_key_id, :organization_id => @organization).first + fail HttpErrors::NotFound, _("Couldn't find ssl client key '%s'") % ssl_client_key_id if ssl_client_key.nil? + end + end + def product_params # only allow sync plan id to be updated if the product is a Red Hat product if @product && @product.redhat? params.require(:product).permit(:sync_plan_id) else - params.require(:product).permit(:name, :label, :description, :provider_id, :gpg_key_id, :sync_plan_id) + params.require(:product).permit(:name, :label, :description, :provider_id, :gpg_key_id, :ssl_ca_cert_id, :ssl_client_cert_id, :ssl_client_key_id, :sync_plan_id) end end end diff --git a/app/lib/katello/validators/gpg_key_content_type_validator.rb b/app/lib/katello/validators/gpg_key_content_type_validator.rb new file mode 100644 index 00000000000..d648dccbb46 --- /dev/null +++ b/app/lib/katello/validators/gpg_key_content_type_validator.rb @@ -0,0 +1,22 @@ +module Katello + module Validators + class GpgKeyContentTypeValidator < ActiveModel::Validator + def validate(record) + # need to verify, that gpg_key is of GpgKey.content type "gpg_key" and + # ssl_ca_cert, ssl_client_cert, ssl_client_key of GpgKey.content type "cert" + + if !record.gpg_key.blank? && record.gpg_key.content_type != "gpg_key" + record.errors[:gpg_key] << _("Wrong content type submitted.") + end + + if record.instance_of?(Katello::Product) + [:ssl_ca_cert, :ssl_client_cert, :ssl_client_key].each do |cert| + if !record.send(cert).blank? && record.send(cert).content_type != "cert" + record.errors[cert] << _("Wrong content type submitted.") + end + end + end + end + end + end +end diff --git a/app/models/katello/glue/pulp/repo.rb b/app/models/katello/glue/pulp/repo.rb index 52765ccac9e..e731b1aa0e4 100644 --- a/app/models/katello/glue/pulp/repo.rb +++ b/app/models/katello/glue/pulp/repo.rb @@ -255,6 +255,12 @@ def importer_connection_options(capsule = SmartProxy.default_capsule!) :ssl_ca_cert => Katello::Repository.feed_ca_cert(url), :proxy_host => self.proxy_host_value } + elsif self.product.ssl_client_cert && self.product.ssl_client_key && self.product.ssl_ca_cert + importer_options = { + :ssl_client_cert => self.product.ssl_client_cert.content, + :ssl_client_key => self.product.ssl_client_key.content, + :ssl_ca_cert => self.product.ssl_ca_cert.content + } else importer_options = { :ssl_client_cert => nil, diff --git a/app/models/katello/gpg_key.rb b/app/models/katello/gpg_key.rb index fe908a52990..04d2bbc8c33 100644 --- a/app/models/katello/gpg_key.rb +++ b/app/models/katello/gpg_key.rb @@ -6,21 +6,32 @@ class GpgKey < Katello::Model has_many :repositories, :class_name => "Katello::Repository", :inverse_of => :gpg_key, :dependent => :nullify has_many :products, :class_name => "Katello::Product", :inverse_of => :gpg_key, :dependent => :nullify - + has_many :ssl_ca_products, :class_name => "Katello::Product", :foreign_key => "ssl_ca_cert_id", + :inverse_of => :ssl_ca_cert, :dependent => :nullify + has_many :ssl_client_products, :class_name => "Katello::Product", :foreign_key => "ssl_client_cert_id", + :inverse_of => :ssl_client_cert, :dependent => :nullify + has_many :ssl_key_products, :class_name => "Katello::Product", :foreign_key => "ssl_client_key_id", + :inverse_of => :ssl_client_key, :dependent => :nullify belongs_to :organization, :inverse_of => :gpg_keys validates_lengths_from_database validates :name, :presence => true, :uniqueness => {:scope => :organization_id, :message => N_("has already been taken")} + validates :content_type, :presence => true, :inclusion => { :in => %w(gpg_key cert), + :message => N_("must be gpg_key or cert")} validates :content, :presence => true, :length => {:maximum => MAX_CONTENT_LENGTH} validates :organization, :presence => true validates_with Validators::KatelloNameFormatValidator, :attributes => :name validates_with Validators::ContentValidator, :attributes => :content - validates_with Validators::GpgKeyContentValidator, :attributes => :content, :if => proc { SETTINGS[:katello][:gpg_strict_validation] } + validates_with Validators::GpgKeyContentValidator, :attributes => :content, :if => :use_gpg_content_validator? scoped_search :on => :name, :complete_value => true scoped_search :on => :organization_id, :complete_value => true, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER + def use_gpg_content_validator? + content_type == "gpg_key" && SETTINGS[:katello][:gpg_strict_validation] + end + def as_json(options = {}) options ||= {} ret = super(options.except(:details)) diff --git a/app/models/katello/product.rb b/app/models/katello/product.rb index b6e60cb96b7..7f724c552c4 100644 --- a/app/models/katello/product.rb +++ b/app/models/katello/product.rb @@ -15,6 +15,9 @@ class Product < Katello::Model belongs_to :gpg_key, :inverse_of => :products has_many :product_contents, :foreign_key => 'product_id', :class_name => "Katello::ProductContent", :dependent => :destroy has_many :displayable_product_contents, -> { displayable }, :foreign_key => 'product_id', :class_name => "Katello::ProductContent", :dependent => :destroy + belongs_to :ssl_ca_cert, :class_name => "Katello::GpgKey", :inverse_of => :ssl_ca_products + belongs_to :ssl_client_cert, :class_name => "Katello::GpgKey", :inverse_of => :ssl_client_products + belongs_to :ssl_client_key, :class_name => "Katello::GpgKey", :inverse_of => :ssl_key_products has_many :repositories, :class_name => "Katello::Repository", :dependent => :restrict_with_exception has_many :subscription_products, :class_name => "Katello::SubscriptionProduct", :dependent => :destroy @@ -27,6 +30,7 @@ class Product < Katello::Model validates_with Validators::KatelloLabelFormatValidator, :attributes => :label validates_with Validators::ProductUniqueAttributeValidator, :attributes => :name validates_with Validators::ProductUniqueAttributeValidator, :attributes => :label + validates_with Validators::GpgKeyContentTypeValidator scoped_search :on => :name, :complete_value => true scoped_search :on => :organization_id, :complete_value => true, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER diff --git a/app/views/katello/api/v2/content_credentials/index.json.rabl b/app/views/katello/api/v2/content_credentials/index.json.rabl new file mode 100644 index 00000000000..8fb548f1c7e --- /dev/null +++ b/app/views/katello/api/v2/content_credentials/index.json.rabl @@ -0,0 +1,3 @@ +object false + +extends "katello/api/v2/common/index" diff --git a/app/views/katello/api/v2/content_credentials/show.json.rabl b/app/views/katello/api/v2/content_credentials/show.json.rabl new file mode 100644 index 00000000000..b32224446a2 --- /dev/null +++ b/app/views/katello/api/v2/content_credentials/show.json.rabl @@ -0,0 +1,70 @@ +object @resource + +extends 'katello/api/v2/common/identifier' +extends 'katello/api/v2/common/org_reference' +extends 'katello/api/v2/common/timestamps' + +attributes :name +attributes :content_type +attributes :content + +child :products => :products do + attributes :id, :cp_id, :name + node :repository_count do |product| + product.repositories.count + end + child :provider => :provider do + attribute :name + attribute :id + end +end + +child :repositories => :repositories do + attribute :id + attribute :name + + child :product do |_product| + attributes :id, :cp_id, :name + end +end + +child :ssl_ca_products => :ssl_ca_products do + attributes :id, :cp_id, :name + node :repository_count do |product| + product.repositories.count + end + child :provider => :provider do + attribute :name + attribute :id + end +end + +child :ssl_client_products => :ssl_client_products do + attributes :id, :cp_id, :name + node :repository_count do |product| + product.repositories.count + end + child :provider => :provider do + attribute :name + attribute :id + end +end + +child :ssl_key_products => :ssl_key_products do + attributes :id, :cp_id, :name + node :repository_count do |product| + product.repositories.count + end + child :provider => :provider do + attribute :name + attribute :id + end +end + +node :permissions do |content_credential| + { + :view_content_credenials => content_credential.readable?, + :edit_content_credenials => content_credential.editable?, + :destroy_content_credenials => content_credential.deletable? + } +end diff --git a/app/views/katello/api/v2/products/base.json.rabl b/app/views/katello/api/v2/products/base.json.rabl index 10c62b637e3..270a83ead7d 100644 --- a/app/views/katello/api/v2/products/base.json.rabl +++ b/app/views/katello/api/v2/products/base.json.rabl @@ -9,6 +9,9 @@ attributes :provider_id attributes :sync_plan_id attributes :sync_summary attributes :gpg_key_id +attributes :ssl_ca_cert_id +attributes :ssl_client_cert_id +attributes :ssl_client_key_id child({:available_content => :available_content}, :if => params[:include_available_content]) do extends "katello/api/v2/products/product_content" diff --git a/app/views/katello/api/v2/products/show.json.rabl b/app/views/katello/api/v2/products/show.json.rabl index c8b82f75031..ce46e47d7d7 100644 --- a/app/views/katello/api/v2/products/show.json.rabl +++ b/app/views/katello/api/v2/products/show.json.rabl @@ -21,6 +21,18 @@ node(:gpg_key, :unless => lambda { |product| product.gpg_key.nil? }) do |product {:id => product.gpg_key.id, :name => product.gpg_key.name} end +node(:ssl_ca_cert, :unless => lambda { |product| product.ssl_ca_cert.nil? }) do |product| + {:id => product.ssl_ca_cert.id, :name => product.ssl_ca_cert.name} +end + +node(:ssl_client_cert, :unless => lambda { |product| product.ssl_client_cert.nil? }) do |product| + {:id => product.ssl_client_cert.id, :name => product.ssl_client_cert.name} +end + +node(:ssl_client_key, :unless => lambda { |product| product.ssl_client_key.nil? }) do |product| + {:id => product.ssl_client_key.id, :name => product.ssl_client_key.name} +end + child :provider do attribute :name end diff --git a/config/routes/api/v2.rb b/config/routes/api/v2.rb index 7dfb66b85fb..9fff8db4c28 100644 --- a/config/routes/api/v2.rb +++ b/config/routes/api/v2.rb @@ -54,6 +54,14 @@ class ActionDispatch::Routing::Mapper end end + api_resources :content_credentials, :only => [:index, :show, :create, :update, :destroy] do + member do + get :content + post :content, :action => :set_content + end + get :auto_complete_search, :on => :collection + end + match '/content_views/:composite_content_view_id/content_view_components' => 'content_view_components#index', :via => :get match '/content_views/:composite_content_view_id/content_view_components/:id' => 'content_view_components#show', :via => :get match '/content_views/:composite_content_view_id/content_view_components/add' => 'content_view_components#add_components', :via => :put diff --git a/db/migrate/20171110082124_add_ssl_certs_to_products.rb b/db/migrate/20171110082124_add_ssl_certs_to_products.rb new file mode 100644 index 00000000000..00fde36d4f4 --- /dev/null +++ b/db/migrate/20171110082124_add_ssl_certs_to_products.rb @@ -0,0 +1,26 @@ +class AddSslCertsToProducts < ActiveRecord::Migration + def up + add_column :katello_products, :ssl_ca_cert_id, :integer, :null => true + add_index :katello_products, :ssl_ca_cert_id + add_foreign_key :katello_products, :katello_gpg_keys, :name => "katello_products_ssl_ca_cert_id_fk", :column => :ssl_ca_cert_id, :primary_key => :id + + add_column :katello_products, :ssl_client_cert_id, :integer, :null => true + add_index :katello_products, :ssl_client_cert_id + add_foreign_key :katello_products, :katello_gpg_keys, :name => "katello_products_ssl_client_cert_id_fk", :column => :ssl_client_cert_id, :primary_key => :id + + add_column :katello_products, :ssl_client_key_id, :integer, :null => true + add_index :katello_products, :ssl_client_key_id + add_foreign_key :katello_products, :katello_gpg_keys, :name => "katello_products_ssl_client_key_id_fk", :column => :ssl_client_key_id, :primary_key => :id + + add_column :katello_gpg_keys, :content_type, :string, :null => false, :default => "gpg_key", :limit => 255 + Katello::GpgKey.update_all(:content_type => "gpg_key") + end + + def down + remove_column :katello_products, :ssl_ca_cert_id + remove_column :katello_products, :ssl_client_cert_id + remove_column :katello_products, :ssl_client_key_id + + remove_column :katello_gpg_keys, :content_type + end +end diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion-katello-bootstrap.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion-katello-bootstrap.js index 3a85dd7d345..3da99f52681 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion-katello-bootstrap.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion-katello-bootstrap.js @@ -13,7 +13,7 @@ BASTION_MODULES.push( 'Bastion.puppet-modules', 'Bastion.ostree-branches', 'Bastion.environments', - 'Bastion.gpg-keys', + 'Bastion.content-credentials', 'Bastion.hosts', 'Bastion.capsules', 'Bastion.organizations', diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js index 4c47af13762..51092b7bb1c 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js @@ -76,8 +76,8 @@ //= require "bastion_katello/tasks/tasks.module.js" //= require_tree "./tasks" -//= require "bastion_katello/gpg-keys/gpg-keys.module.js" -//= require_tree "./gpg-keys" +//= require "bastion_katello/content-credentials/content-credentials.module.js" +//= require_tree "./content-credentials" //= require "bastion_katello/tasks/tasks.module.js" //= require_tree "./tasks" diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credential.factory.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credential.factory.js new file mode 100644 index 00000000000..e99ba72bfcc --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credential.factory.js @@ -0,0 +1,63 @@ +/** + * @ngdoc service + * @name Katello.content-credentials.factory:ContentCredential + * + * @requires BastionResource + * + * @description + * Provides a BastionResource for Content Credentials. + */ +angular.module('Bastion.content-credentials').factory('ContentCredential', + ['BastionResource', 'CurrentOrganization', + function (BastionResource, CurrentOrganization) { + + return BastionResource('katello/api/v2/content_credentials/:id/:action', + {id: '@id', 'organization_id': CurrentOrganization}, + { + autocomplete: {method: 'GET', isArray: true, params: {id: 'auto_complete_search'}}, + update: {method: 'PUT'}, + products: {method: 'GET', transformResponse: + function (data) { + var contentCredential = angular.fromJson(data); + var allProducts = {}; + allProducts.length = 0; + allProducts.products = {}; + + function collectProducts(allP, thisP, usedAs) { + var key; + for (key in thisP) { + if (thisP.hasOwnProperty(key)) { + thisP[key]["used_as"] = usedAs; + allP.products[allP.length] = thisP[key]; + allP.length++; + } + } + } + + collectProducts(allProducts, contentCredential.products, "GPG Key"); + collectProducts(allProducts, contentCredential.ssl_ca_products, "SSL CA Cert"); + collectProducts(allProducts, contentCredential.ssl_client_products, "SSL Client Cert"); + collectProducts(allProducts, contentCredential.ssl_key_products, "SSL Client Key"); + + return { + total: allProducts.length, + subtotal: allProducts.length, + results: allProducts.products + }; + } + }, + repositories: {method: 'GET', transformResponse: + function (data) { + var contentCredential = angular.fromJson(data); + return { + total: contentCredential.repositories.length, + subtotal: contentCredential.repositories.length, + results: contentCredential.repositories + }; + } + } + } + ); + + }] +); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.controller.js similarity index 51% rename from engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.controller.js rename to engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.controller.js index 98fdc0b38bd..45767dc146a 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.controller.js @@ -1,21 +1,21 @@ /** * @ngdoc object - * @name Bastion.gpg-keys.controller:GPGKeysController + * @name Bastion.content-credentials.controller:ContentCredentialsController * * @requires $scope * @requires $location * @requires Nutupane - * @requires GPGKey + * @requires ContentCredential * @requires CurrentOrganization * * @description - * Provides the functionality specific to GPGKeys for use with the Nutupane UI pattern. + * Provides the functionality specific to ContentCredentials for use with the Nutupane UI pattern. * Defines the columns to display and the transform function for how to generate each row * within the table. */ -angular.module('Bastion.gpg-keys').controller('GPGKeysController', - ['$scope', '$location', 'Nutupane', 'GPGKey', 'CurrentOrganization', - function ($scope, $location, Nutupane, GPGKey, CurrentOrganization) { +angular.module('Bastion.content-credentials').controller('ContentCredentialsController', + ['$scope', '$location', 'Nutupane', 'ContentCredential', 'CurrentOrganization', + function ($scope, $location, Nutupane, ContentCredential, CurrentOrganization) { var params = { 'organization_id': CurrentOrganization, 'search': $location.search().search || "", @@ -24,8 +24,8 @@ angular.module('Bastion.gpg-keys').controller('GPGKeysController', 'paged': true }; - var nutupane = new Nutupane(GPGKey, params); - $scope.controllerName = 'katello_gpg_keys'; + var nutupane = new Nutupane(ContentCredential, params); + $scope.controllerName = 'katello_content_credentials'; $scope.table = nutupane.table; $scope.panel = {loading: false}; $scope.removeRow = nutupane.removeRow; diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.module.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.module.js similarity index 55% rename from engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.module.js rename to engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.module.js index 2f8a36f9086..c0a92f07b05 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.module.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.module.js @@ -1,11 +1,11 @@ /** * @ngdoc module - * @name Bastion.gpg-keys + * @name Bastion.content-credentials * * @description - * Module for GPG key related functionality. + * Module for Content Credential related functionality. */ -angular.module('Bastion.gpg-keys', [ +angular.module('Bastion.content-credentials', [ 'ngResource', 'ui.router', 'Bastion', diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.routes.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.routes.js new file mode 100644 index 00000000000..15160b2a9e0 --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.routes.js @@ -0,0 +1,76 @@ +/** + * @ngdoc object + * @name Bastion.content-credentials.config + * + * @requires $stateProvider + * + * @description + * Used for systems level configuration such as setting up the ui state machine. + */ +angular.module('Bastion.content-credentials').config(['$stateProvider', function ($stateProvider) { + $stateProvider.state('content-credentials', { + url: '/content_credentials', + permission: 'view_content_credentials', + template: '
', + views: { + '@': { + controller: 'ContentCredentialsController', + templateUrl: 'content-credentials/views/content-credentials.html' + } + }, + ncyBreadcrumb: { + label: "{{ 'Content Credential' | translate}}" + } + }) + .state('content-credentials.new', { + url: '/new', + permission: 'create_content_credentials', + views: { + '@': { + controller: 'NewContentCredentialController', + templateUrl: 'content-credentials/new/views/new-content-credential.html' + } + }, + ncyBreadcrumb: { + label: "{{'New Content Credential' | translate }}", + parent: 'content-credentials' + } + }) + .state("content-credential", { + abstract: true, + url: '/content_credentials/:contentCredentialId', + permission: 'view_content_credentials', + controller: 'ContentCredentialDetailsController', + templateUrl: 'content-credentials/details/views/content-credential-details.html' + }) + .state('content-credential.info', { + url: '', + permission: 'view_content_credentials', + controller: 'ContentCredentialDetailsInfoController', + templateUrl: 'content-credentials/details/views/content-credential-info.html', + ncyBreadcrumb: { + label: "{{ contentCredential.name }}", + parent: 'content-credentials' + } + }) + .state('content-credential.products', { + url: '/products', + permission: 'view_content_credentials', + controller: 'ContentCredentialProductsController', + templateUrl: 'content-credentials/details/views/content-credential-products.html', + ncyBreadcrumb: { + label: "{{ 'Products' | translate }}", + parent: 'content-credential.info' + } + }) + .state('content-credential.repositories', { + url: '/repositories', + permission: 'view_content_credentials', + controller: 'ContentCredentialRepositoriesController', + templateUrl: 'content-credentials/details/views/content-credential-repositories.html', + ncyBreadcrumb: { + label: "{{ 'Repositories' | translate }}", + parent: 'content-credential.info' + } + }); +}]); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-type.filter.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-type.filter.js new file mode 100644 index 00000000000..965e067cc9a --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-type.filter.js @@ -0,0 +1,25 @@ +/** + * @ngdoc object + * @name Bastion.content-credentials.filter:contentTypeFilter + * + * @requires translate + * + * @description + * Provides filter functionality to replace cert with Certificates and gpg_key with GPG Key + */ + +angular.module('Bastion.content-credentials').filter('contentTypeFilter', + ['$filter', 'translate', + function ($filter, translate) { + return function (contentType) { + var filtered = translate("Unsupported Type!"); + + if (contentType === "cert") { + filtered = translate("Certificate"); + } else if (contentType === "gpg_key") { + filtered = translate("GPG Key"); + } + return filtered; + }; + }] +); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-details-info.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details-info.controller.js similarity index 57% rename from engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-details-info.controller.js rename to engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details-info.controller.js index e7638529d6b..108a8f492e5 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-details-info.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details-info.controller.js @@ -1,35 +1,35 @@ /** * @ngdoc object - * @name Bastion.gpgKeys.controller:GPGKeyDetailsInfoController + * @name Bastion.contentCredentials.controller:ContentCredentialDetailsInfoController * * @requires $scope - * @requires GPGKey + * @requires ContentCredential * @requires translate * @requires Notification * * @description - * Provides the functionality for the gpgKey details action pane. + * Provides the functionality for the contentCredential details action pane. */ -angular.module('Bastion.gpg-keys').controller('GPGKeyDetailsInfoController', - ['$scope', 'GPGKey', 'translate', 'Notification', function ($scope, GPGKey, translate, Notification) { +angular.module('Bastion.content-credentials').controller('ContentCredentialDetailsInfoController', + ['$scope', 'ContentCredential', 'translate', 'Notification', function ($scope, ContentCredential, translate, Notification) { $scope.panel = $scope.panel || {loading: false}; $scope.progress = {uploading: false}; - $scope.gpgKey = $scope.gpgKey || GPGKey.get({id: $scope.$stateParams.gpgKeyId}, function () { + $scope.contentCredential = $scope.contentCredential || ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { $scope.panel.loading = false; }); - $scope.gpgKey.$promise.then(function () { - $scope.uploadURL = 'katello/api/v2/gpg_keys/' + $scope.gpgKey.id + '/content'; + $scope.contentCredential.$promise.then(function () { + $scope.uploadURL = 'katello/api/v2/content_credentials/' + $scope.contentCredential.id + '/content'; }); $scope.uploadContent = function (content) { if (content && (content !== "Please wait...")) { if (content.status === 'success') { - Notification.setSuccessMessage(translate('GPG Key successfully uploaded')); + Notification.setSuccessMessage(translate('Content Credential successfully uploaded')); $scope.uploadStatus = 'success'; - $scope.gpgKey.$get(); + $scope.contentCredential.$get(); } else { Notification.setErrorMessage(content.displayMessage); $scope.uploadStatus = 'error'; diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details.controller.js new file mode 100644 index 00000000000..1bb94e84944 --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details.controller.js @@ -0,0 +1,48 @@ +/** + * @ngdoc object + * @name Bastion.content-credentials.controller:ContentCredentialDetailsController + * + * @requires $scope + * @requires ContentCredential + * @requires $q + * @requires translate + * @requires ApiErrorHandler + * @requires Notification + * + * @description + * Provides the functionality for the contentCredential details action pane. + */ +angular.module('Bastion.content-credentials').controller('ContentCredentialDetailsController', + ['$scope', 'ContentCredential', '$q', 'translate', 'ApiErrorHandler', 'Notification', function ($scope, ContentCredential, $q, translate, ApiErrorHandler, Notification) { + $scope.panel = $scope.panel || {error: false, loading: false}; + + $scope.contentCredential = ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { + $scope.panel.error = false; + $scope.panel.loading = false; + }, function (response) { + $scope.panel.loading = false; + ApiErrorHandler.handleGETRequestErrors(response, $scope); + }); + + $scope.save = function (contentCredential) { + var deferred = $q.defer(); + + contentCredential.$update(function (response) { + deferred.resolve(response); + Notification.setSuccessMessage(translate('Content credential updated')); + + }, function (response) { + deferred.reject(response); + Notification.setErrorMessage(response.data.displayMessage); + }); + + return deferred.promise; + }; + + $scope.removeContentCredential = function (contentCredential) { + contentCredential.$delete(function () { + $scope.transitionTo('content-credentials'); + }); + }; + }] +); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-products.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-products.controller.js new file mode 100644 index 00000000000..ab9b6142315 --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-products.controller.js @@ -0,0 +1,36 @@ +/** + * @ngdoc object + * @name Bastion.content-credentials.controller:ContentCredentialProductsController + * + * @requires $scope + * @requires Nutupane + * @requires ContentCredential + * @requires ApiErrorHandler + * + * @description + * Page for Content Credential products + */ +(function () { + function ContentCredentialProductsController($scope, Nutupane, ContentCredential, ApiErrorHandler) { + var nutupane = new Nutupane(ContentCredential, { + id: $scope.$stateParams.contentCredentialId + }, 'products'); + $scope.controllerName = 'katello_content_credentials'; + nutupane.masterOnly = true; + + $scope.panel = $scope.panel || {error: false, loading: false}; + + $scope.contentCredential = ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { + $scope.panel.error = false; + $scope.panel.loading = false; + }, function (response) { + $scope.panel.loading = false; + ApiErrorHandler.handleGETRequestErrors(response, $scope); + }); + + $scope.table = nutupane.table; + } + + angular.module('Bastion.content-credentials').controller('ContentCredentialProductsController', ContentCredentialProductsController); + ContentCredentialProductsController.$inject = ['$scope', 'Nutupane', 'ContentCredential', 'ApiErrorHandler']; +})(); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-repositories.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-repositories.controller.js new file mode 100644 index 00000000000..a1d0d5b7f4b --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-repositories.controller.js @@ -0,0 +1,36 @@ +(function () { + function ContentCredentialRepositoriesController($scope, Nutupane, ContentCredential, ApiErrorHandler) { + /** + * @ngdoc object + * @name Bastion.content-credentials.controller:ContentCredentialRepositoriesController + * + * @requires $scope + * @requires Nutupane + * @requires ContentCredential + * @requires ApiErrorHandler + * + * @description + * Page for Content Credential repositories + */ + var nutupane = new Nutupane(ContentCredential, { + id: $scope.$stateParams.contentCredentialId + }, 'repositories'); + $scope.controllerName = 'katello_content_credentials'; + nutupane.masterOnly = true; + + $scope.panel = $scope.panel || {error: false, loading: false}; + + $scope.contentCredential = ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { + $scope.panel.error = false; + $scope.panel.loading = false; + }, function (response) { + $scope.panel.loading = false; + ApiErrorHandler.handleGETRequestErrors(response, $scope); + }); + + $scope.table = nutupane.table; + } + + angular.module('Bastion.content-credentials').controller('ContentCredentialRepositoriesController', ContentCredentialRepositoriesController); + ContentCredentialRepositoriesController.$inject = ['$scope', 'Nutupane', 'ContentCredential', 'ApiErrorHandler']; +})(); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-details.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-details.html new file mode 100644 index 00000000000..d2f7a78383b --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-details.html @@ -0,0 +1,36 @@ +
+
+

{{ contentCredential.name }}

+
+ +
+ + +
+
Remove Content Credential {{ contentCredential.name }}
+
Are you sure you want to remove Content Credential {{ contentCredential.name }}?
+
+
+ + + +
+
+
+
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-info.html similarity index 56% rename from engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-info.html rename to engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-info.html index 9d303220461..e986b58201a 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-info.html @@ -3,15 +3,18 @@
Name
-
+
+
Type
+
{{ contentCredential.content_type | contentTypeFilter }}
+
Content
-
+
- +
- \ No newline at end of file + diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-products.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-products.html similarity index 71% rename from engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-products.html rename to engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-products.html index 70a25d3738b..68a623f3e94 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-products.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-products.html @@ -1,8 +1,8 @@ -{{ 'Repositories for ' | translate }} {{ gpgKey.name }} +{{ 'Repositories for ' | translate }} {{ contentCredential.name }}
- You currently don't have any Products associated with this GPG Key. + You currently don't have any Products associated with this Content Credential.
@@ -10,6 +10,7 @@ Name + Used as Repositories @@ -21,6 +22,9 @@ {{ product.name }} + + {{ product.used_as }} + {{ product.repository_count }} diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-repositories.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-repositories.html similarity index 78% rename from engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-repositories.html rename to engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-repositories.html index 8afb16593e2..005957ffbf7 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-repositories.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-repositories.html @@ -1,12 +1,12 @@ -{{ 'Products for ' | translate }} {{ gpgKey.name }} +{{ 'Products for ' | translate }} {{ contentCredential.name }}
- You currently don't have any Repositories associated with this GPG Key. + You currently don't have any Repositories associated with this Content Credential.
- +
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/new-content-credential.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/new-content-credential.controller.js new file mode 100644 index 00000000000..65253274383 --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/new-content-credential.controller.js @@ -0,0 +1,39 @@ +/** + * @ngdoc object + * @name Bastion.content-credentials.controller:NewContentCredentialController + * + * @requires $scope + * @requires $state + * @requires translate + * @requires ContentCredential + * @requires CurrentOrganization + * @requires Notification + * + * @description + * Controls the creation of an empty ContentCredential object for use by sub-controllers. + */ +angular.module('Bastion.content-credentials').controller('NewContentCredentialController', + ['$scope', '$state', 'translate', 'ContentCredential', 'CurrentOrganization', 'Notification', + function ($scope, $state, translate, ContentCredential, CurrentOrganization, Notification) { + $scope.panel = {loading: false}; + $scope.contentCredential = new ContentCredential(); + $scope.CurrentOrganization = CurrentOrganization; + $scope.progress = {uploading: false}; + $scope.uploadURL = 'katello/api/v2/content_credentials?organization_id=' + CurrentOrganization; + + $scope.uploadContent = function (response) { + if (response) { + if (angular.isUndefined(response.errors)) { + $scope.uploadStatus = 'success'; + $scope.transitionTo('content-credential.info', {contentCredentialId: response.id}); + Notification.setSuccessMessage(translate('Content Credential %s has been created.').replace('%s', response.name)); + } else { + Notification.setErrorMessage(translate("An error occurred while creating the Content Credential: ") + response.displayMessage); + $scope.uploadStatus = 'error'; + } + + $scope.progress.uploading = false; + } + }; + }] +); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html new file mode 100644 index 00000000000..713dc361a40 --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html @@ -0,0 +1,53 @@ +
+
+

Create Content Credential

+
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +

Upload Content Credential file

+
+ +
+
+ +
+
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/views/content-credentials.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/views/content-credentials.html new file mode 100644 index 00000000000..5acaf717185 --- /dev/null +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/views/content-credentials.html @@ -0,0 +1,51 @@ +{{ 'Content Credentials' | translate }} + +
+
+

Content Credentials

+
+ +
+ +
+ + + You currently don't have any Content Credential, you can add Content Credentials using the button on the right. + + + + Your search returned zero Content Credential. + + +
+
Name
+ + + + + + + + + + + + + + + + + + + +
NameOrganizationTypeProduct CountRepository Count
+ {{ contentCredential.name }} + {{ contentCredential.organization.name }}{{ contentCredential.content_type | contentTypeFilter }}{{ contentCredential.products.length + + contentCredential.ssl_ca_products.length + + contentCredential.ssl_client_products.length + + contentCredential.ssl_key_products.length || 0 }}{{ contentCredential.repositories.length || 0 }}
+ +
+
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-details.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-details.controller.js deleted file mode 100644 index c55cf63334a..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-details.controller.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.gpg-keys.controller:GPGKeyDetailsController - * - * @requires $scope - * @requires GPGKey - * @requires $q - * @requires translate - * @requires ApiErrorHandler - * @requires Notification - * - * @description - * Provides the functionality for the gpgKey details action pane. - */ -angular.module('Bastion.gpg-keys').controller('GPGKeyDetailsController', - ['$scope', 'GPGKey', '$q', 'translate', 'ApiErrorHandler', 'Notification', function ($scope, GPGKey, $q, translate, ApiErrorHandler, Notification) { - $scope.panel = $scope.panel || {error: false, loading: false}; - - $scope.gpgKey = GPGKey.get({id: $scope.$stateParams.gpgKeyId}, function () { - $scope.panel.error = false; - $scope.panel.loading = false; - }, function (response) { - $scope.panel.loading = false; - ApiErrorHandler.handleGETRequestErrors(response, $scope); - }); - - $scope.save = function (gpgKey) { - var deferred = $q.defer(); - - gpgKey.$update(function (response) { - deferred.resolve(response); - Notification.setSuccessMessage(translate('GPG Key updated')); - - }, function (response) { - deferred.reject(response); - Notification.setErrorMessage(response.data.displayMessage); - }); - - return deferred.promise; - }; - - $scope.removeGPGKey = function (gpgKey) { - gpgKey.$delete(function () { - $scope.transitionTo('gpg-keys'); - }); - }; - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-products.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-products.controller.js deleted file mode 100644 index bfb422fc71e..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-products.controller.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.gpg-keys.controller:GPGKeyProductsController - * - * @requires $scope - * @requires Nutupane - * @requires GPGKey - * @requires ApiErrorHandler - * - * @description - * Page for GPG Key products - */ -(function () { - function GPGKeyProductsController($scope, Nutupane, GPGKey, ApiErrorHandler) { - var nutupane = new Nutupane(GPGKey, { - id: $scope.$stateParams.gpgKeyId - }, 'products'); - $scope.controllerName = 'katello_gpg_keys'; - nutupane.masterOnly = true; - - $scope.panel = $scope.panel || {error: false, loading: false}; - - $scope.gpgKey = GPGKey.get({id: $scope.$stateParams.gpgKeyId}, function () { - $scope.panel.error = false; - $scope.panel.loading = false; - }, function (response) { - $scope.panel.loading = false; - ApiErrorHandler.handleGETRequestErrors(response, $scope); - }); - - $scope.table = nutupane.table; - } - - angular.module('Bastion.gpg-keys').controller('GPGKeyProductsController', GPGKeyProductsController); - GPGKeyProductsController.$inject = ['$scope', 'Nutupane', 'GPGKey', 'ApiErrorHandler']; -})(); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-repositories.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-repositories.controller.js deleted file mode 100644 index d41d8e3eb2d..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/gpg-key-repositories.controller.js +++ /dev/null @@ -1,36 +0,0 @@ -(function () { - function GPGKeyRepositoriesController($scope, Nutupane, GPGKey, ApiErrorHandler) { - /** - * @ngdoc object - * @name Bastion.gpg-keys.controller:GPGKeyRepositoriesController - * - * @requires $scope - * @requires Nutupane - * @requires GPGKey - * @requires ApiErrorHandler - * - * @description - * Page for GPG Key repositories - */ - var nutupane = new Nutupane(GPGKey, { - id: $scope.$stateParams.gpgKeyId - }, 'repositories'); - $scope.controllerName = 'katello_gpg_keys'; - nutupane.masterOnly = true; - - $scope.panel = $scope.panel || {error: false, loading: false}; - - $scope.gpgKey = GPGKey.get({id: $scope.$stateParams.gpgKeyId}, function () { - $scope.panel.error = false; - $scope.panel.loading = false; - }, function (response) { - $scope.panel.loading = false; - ApiErrorHandler.handleGETRequestErrors(response, $scope); - }); - - $scope.table = nutupane.table; - } - - angular.module('Bastion.gpg-keys').controller('GPGKeyRepositoriesController', GPGKeyRepositoriesController); - GPGKeyRepositoriesController.$inject = ['$scope', 'Nutupane', 'GPGKey', 'ApiErrorHandler']; -})(); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-details.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-details.html deleted file mode 100644 index 6b589c775cd..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-details.html +++ /dev/null @@ -1,36 +0,0 @@ -
-
-

{{ gpgKey.name }}

-
- -
- - -
-
Remove GPG Key {{ gpgKey.name }}
-
Are you sure you want to remove GPG key {{ gpgKey.name }}?
-
-
- -
- -
-
-
-
\ No newline at end of file diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-key.factory.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-key.factory.js deleted file mode 100644 index 1af33eba9b1..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-key.factory.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @ngdoc service - * @name Katello.gpg-keys.factory:GPGKey - * - * @requires BastionResource - * - * @description - * Provides a BastionResource for GPG keys. - */ -angular.module('Bastion.gpg-keys').factory('GPGKey', - ['BastionResource', 'CurrentOrganization', - function (BastionResource, CurrentOrganization) { - - return BastionResource('katello/api/v2/gpg_keys/:id/:action', - {id: '@id', 'organization_id': CurrentOrganization}, - { - autocomplete: {method: 'GET', isArray: true, params: {id: 'auto_complete_search'}}, - update: {method: 'PUT'}, - products: {method: 'GET', transformResponse: - function (data) { - var gpgKey = angular.fromJson(data); - return { - total: gpgKey.products.length, - subtotal: gpgKey.products.length, - results: gpgKey.products - }; - } - }, - repositories: {method: 'GET', transformResponse: - function (data) { - var gpgKey = angular.fromJson(data); - return { - total: gpgKey.repositories.length, - subtotal: gpgKey.repositories.length, - results: gpgKey.repositories - }; - } - } - } - ); - - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.routes.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.routes.js deleted file mode 100644 index 1625cf585b8..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/gpg-keys.routes.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.gpg-keys.config - * - * @requires $stateProvider - * - * @description - * Used for systems level configuration such as setting up the ui state machine. - */ -angular.module('Bastion.gpg-keys').config(['$stateProvider', function ($stateProvider) { - $stateProvider.state('gpg-keys', { - url: '/gpg_keys', - permission: 'view_gpg_keys', - template: '
', - views: { - '@': { - controller: 'GPGKeysController', - templateUrl: 'gpg-keys/views/gpg-keys.html' - } - }, - ncyBreadcrumb: { - label: "{{ 'GPG Keys' | translate}}" - } - }) - .state('gpg-keys.new', { - url: '/new', - permission: 'create_gpg_keys', - views: { - '@': { - controller: 'NewGPGKeyController', - templateUrl: 'gpg-keys/new/views/new-gpg-key.html' - } - }, - ncyBreadcrumb: { - label: "{{'New GPG Key' | translate }}", - parent: 'gpg-keys' - } - }) - .state("gpg-key", { - abstract: true, - url: '/gpg_keys/:gpgKeyId', - permission: 'view_gpg_keys', - controller: 'GPGKeyDetailsController', - templateUrl: 'gpg-keys/details/views/gpg-key-details.html' - }) - .state('gpg-key.info', { - url: '', - permission: 'view_gpg_keys', - controller: 'GPGKeyDetailsInfoController', - templateUrl: 'gpg-keys/details/views/gpg-key-info.html', - ncyBreadcrumb: { - label: "{{ gpgKey.name }}", - parent: 'gpg-keys' - } - }) - .state('gpg-key.products', { - url: '/products', - permission: 'view_gpg_keys', - controller: 'GPGKeyProductsController', - templateUrl: 'gpg-keys/details/views/gpg-key-products.html', - ncyBreadcrumb: { - label: "{{ 'Products' | translate }}", - parent: 'gpg-key.info' - } - }) - .state('gpg-key.repositories', { - url: '/repositories', - permission: 'view_gpg_keys', - controller: 'GPGKeyRepositoriesController', - templateUrl: 'gpg-keys/details/views/gpg-key-repositories.html', - ncyBreadcrumb: { - label: "{{ 'Repositories' | translate }}", - parent: 'gpg-key.info' - } - }); -}]); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/new-gpg-key.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/new-gpg-key.controller.js deleted file mode 100644 index 27f2d254523..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/new-gpg-key.controller.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.gpg-keys.controller:NewGPGKeyController - * - * @requires $scope - * @requires $state - * @requires translate - * @requires GPGKey - * @requires CurrentOrganization - * @requires Notification - * - * @description - * Controls the creation of an empty GPGKey object for use by sub-controllers. - */ -angular.module('Bastion.gpg-keys').controller('NewGPGKeyController', - ['$scope', '$state', 'translate', 'GPGKey', 'CurrentOrganization', 'Notification', - function ($scope, $state, translate, GPGKey, CurrentOrganization, Notification) { - $scope.panel = {loading: false}; - $scope.gpgKey = new GPGKey(); - $scope.CurrentOrganization = CurrentOrganization; - $scope.progress = {uploading: false}; - $scope.uploadURL = 'katello/api/v2/gpg_keys?organization_id=' + CurrentOrganization; - - $scope.uploadContent = function (response) { - if (response) { - if (angular.isUndefined(response.errors)) { - $scope.uploadStatus = 'success'; - $scope.transitionTo('gpg-key.info', {gpgKeyId: response.id}); - Notification.setSuccessMessage(translate('GPG key %s has been created.').replace('%s', response.name)); - } else { - Notification.setErrorMessage(translate("An error occurred while creating the GPG key: ") + response.displayMessage); - $scope.uploadStatus = 'error'; - } - - $scope.progress.uploading = false; - } - }; - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/views/new-gpg-key.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/views/new-gpg-key.html deleted file mode 100644 index c6db8c0f95f..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/views/new-gpg-key.html +++ /dev/null @@ -1,44 +0,0 @@ -
-
-

Create GPG Key

-
- -
-
- -
- -
- -
- -
- -
- -

Upload GPG Key file

-
- -
-
-
-
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/views/gpg-keys.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/views/gpg-keys.html deleted file mode 100644 index 8e83b824673..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/views/gpg-keys.html +++ /dev/null @@ -1,46 +0,0 @@ -{{ 'GPG Keys' | translate }} - -
-
-

GPG Keys

-
- -
- -
- - - You currently don't have any GPG keys, you can add GPG keys using the button on the right. - - - - Your search returned zero GPG keys. - - -
- - - - - - - - - - - - - - - - - - -
NameOrganizationProduct CountRepository Count
- {{ gpgKey.name }} - {{ gpgKey.organization.name }}{{ gpgKey.products.length || 0 }}{{ gpgKey.repositories.length || 0 }}
- -
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js index e8b8dbc1878..4ac6677e95b 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js @@ -23,11 +23,11 @@ 'products.discovery', 'products.discovery.scan', 'products.discovery.create', - 'gpg-keys', - 'gpg-keys.new', - 'gpg-key.info', - 'gpg-key.products', - 'gpg-key.repositories' + 'content-credentials', + 'content-credentials.new', + 'content-credential.info', + 'content-credential.products', + 'content-credential.repositories' ]; FeatureFlag.addStates('remote_actions', remoteActions); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js index ea778cb0948..76b3dcf330a 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js @@ -14,7 +14,7 @@ angular.module('Bastion.organizations').service('FencedPages', ['$state', 'content-views', 'docker-tags', 'errata', - 'gpg-keys', + 'content-credentials', 'host-collections', 'lifecycle-environments', 'packages', diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-details-info.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-details-info.controller.js index 21936bb425d..3d0d9722d27 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-details-info.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-details-info.controller.js @@ -7,7 +7,7 @@ * @requires translate * @requires Product * @requires SyncPlan - * @requires GPGKey + * @requires ContentCredential * @requires MenuExpander * @requires Notification * @@ -15,8 +15,8 @@ * Provides the functionality for the product details action pane. */ angular.module('Bastion.products').controller('ProductDetailsInfoController', - ['$scope', '$state', '$q', 'translate', 'Product', 'SyncPlan', 'GPGKey', 'MenuExpander', 'Notification', - function ($scope, $state, $q, translate, Product, SyncPlan, GPGKey, MenuExpander, Notification) { + ['$scope', '$state', '$q', 'translate', 'Product', 'SyncPlan', 'ContentCredential', 'MenuExpander', 'Notification', + function ($scope, $state, $q, translate, Product, SyncPlan, ContentCredential, MenuExpander, Notification) { $scope.menuExpander = MenuExpander; $scope.page = $scope.page || {loading: false}; @@ -27,10 +27,37 @@ angular.module('Bastion.products').controller('ProductDetailsInfoController', $scope.gpgKeys = function () { var deferred = $q.defer(); - GPGKey.queryUnpaged(function (gpgKeys) { - var results = gpgKeys.results; + ContentCredential.queryUnpaged(function (contentCredentials) { + var results = contentCredentials.results; + results = results.filter(function(obj) { + if (obj.content_type === "gpg_key") { + return true; + } + return false; + }); + results.unshift({id: null}); + + deferred.resolve(results); + }); + + return deferred.promise; + }; + + $scope.Certs = function () { + var deferred = $q.defer(); + + ContentCredential.queryUnpaged(function (contentCredentials) { + var results = contentCredentials.results; + + results = results.filter(function(obj) { + if (obj.content_type === "cert") { + return true; + } + return false; + }); results.unshift({id: null}); + deferred.resolve(results); }); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js index 42f9dc83e98..1b10b3d8f2d 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js @@ -6,7 +6,7 @@ * @requires $q * @requires translate * @requires Notification - * @requires GPGKey + * @requires ContentCredential * @requires CurrentOrganization * @requires Checksum * @requires DownloadPolicy @@ -17,8 +17,8 @@ * Provides the functionality for the repository details info page. */ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoController', - ['$scope', '$q', 'translate', 'Notification', 'GPGKey', 'CurrentOrganization', 'Checksum', 'DownloadPolicy', 'OstreeUpstreamSyncPolicy', 'Architecture', - function ($scope, $q, translate, Notification, GPGKey, CurrentOrganization, Checksum, DownloadPolicy, OstreeUpstreamSyncPolicy, Architecture) { + ['$scope', '$q', 'translate', 'Notification', 'ContentCredential', 'CurrentOrganization', 'Checksum', 'DownloadPolicy', 'OstreeUpstreamSyncPolicy', 'Architecture', + function ($scope, $q, translate, Notification, ContentCredential, CurrentOrganization, Checksum, DownloadPolicy, OstreeUpstreamSyncPolicy, Architecture) { $scope.organization = CurrentOrganization; $scope.progress = {uploading: false}; @@ -27,11 +27,11 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll $scope.uploadURL = 'katello/api/v2/repositories/' + $scope.repository.id + '/upload_content'; }); - $scope.gpgKeys = function () { + $scope.contentCredentials = function () { var deferred = $q.defer(); - GPGKey.queryUnpaged(function (gpgKeys) { - var results = gpgKeys.results; + ContentCredential.queryUnpaged(function (contentCredentials) { + var results = contentCredentials.results; results.unshift({id: null}); deferred.resolve(results); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html index b6f10cc33cd..863075e671e 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html @@ -169,7 +169,7 @@

Sync Settings

diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js index 76139c0c563..8fa90526e06 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js @@ -5,7 +5,7 @@ * @requires $scope * @requires Repository * @requires Product - * @requires GPGKey + * @requires ContentCredential * @requires FormUtils * @requires translate * @requires Notification @@ -20,8 +20,8 @@ * Controls the creation of an empty Repository object for use by sub-controllers. */ angular.module('Bastion.repositories').controller('NewRepositoryController', - ['$scope', 'Repository', 'Product', 'GPGKey', 'FormUtils', 'translate', 'Notification', 'ApiErrorHandler', 'BastionConfig', 'Checksum', 'DownloadPolicy', 'OstreeUpstreamSyncPolicy', 'Architecture', - function ($scope, Repository, Product, GPGKey, FormUtils, translate, Notification, ApiErrorHandler, BastionConfig, Checksum, DownloadPolicy, OstreeUpstreamSyncPolicy, Architecture) { + ['$scope', 'Repository', 'Product', 'ContentCredential', 'FormUtils', 'translate', 'Notification', 'ApiErrorHandler', 'BastionConfig', 'Checksum', 'DownloadPolicy', 'OstreeUpstreamSyncPolicy', 'Architecture', + function ($scope, Repository, Product, ContentCredential, FormUtils, translate, Notification, ApiErrorHandler, BastionConfig, Checksum, DownloadPolicy, OstreeUpstreamSyncPolicy, Architecture) { function success() { Notification.setSuccessMessage(translate('Repository %s successfully created.').replace('%s', $scope.repository.name)); @@ -84,8 +84,8 @@ angular.module('Bastion.repositories').controller('NewRepositoryController', } }); - GPGKey.queryUnpaged(function (gpgKeys) { - $scope.gpgKeys = gpgKeys.results; + ContentCredential.queryUnpaged(function (contentCredentials) { + $scope.contentCredentials = contentCredentials.results; }); Architecture.queryUnpaged(function (architecture) { diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html index f6c28fee001..8713e22ed77 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html @@ -209,7 +209,7 @@

Published Reposit

diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-info.html index 5607189d6de..49f7697f4b5 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-info.html @@ -22,6 +22,30 @@

Basic Information

on-save="save(product)"> +
SSL CA Cert
+
+
+ +
SSL Client Cert
+
+
+ +
SSL Client Key
+
+
+
Description
Product Options
-
-

Repository Options

diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/product-form.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/product-form.controller.js index 9dd1665083a..d42940fbd3c 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/product-form.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/product-form.controller.js @@ -6,7 +6,7 @@ * @requires $q * @requires $uibModal * @requires Product - * @requires GPGKey + * @requires ContentCredential * @requires SyncPlan * @requires FormUtils * @@ -17,12 +17,12 @@ * within the table. */ angular.module('Bastion.products').controller('ProductFormController', - ['$scope', '$q', '$uibModal', 'Product', 'GPGKey', 'SyncPlan', 'FormUtils', 'Notification', - function ($scope, $q, $uibModal, Product, GPGKey, SyncPlan, FormUtils, Notification) { + ['$scope', '$q', '$uibModal', 'Product', 'ContentCredential', 'SyncPlan', 'FormUtils', 'Notification', + function ($scope, $q, $uibModal, Product, ContentCredential, SyncPlan, FormUtils, Notification) { - function fetchGpgKeys() { - return GPGKey.queryUnpaged(function (gpgKeys) { - $scope.gpgKeys = gpgKeys.results; + function fetchContentCredentials() { + return ContentCredential.queryUnpaged(function (contentCredentials) { + $scope.contentCredentials = contentCredentials.results; }); } @@ -61,7 +61,7 @@ angular.module('Bastion.products').controller('ProductFormController', product.$save(success, error); }; - $q.all([fetchSyncPlans().$promise, fetchGpgKeys().$promise]).finally(function () { + $q.all([fetchSyncPlans().$promise, fetchContentCredentials().$promise]).finally(function () { $scope.page.loading = false; }); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/views/product-new-form.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/views/product-new-form.html index 1d73b5689a1..86a4d3673e5 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/views/product-new-form.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/new/views/product-new-form.html @@ -22,7 +22,34 @@ + + +
+ +
+ +
+ +
+ +
+
@@ -54,4 +81,4 @@ - \ No newline at end of file + diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.module.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.module.js index 3d1eb4cb0aa..3b2b92d7553 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.module.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.module.js @@ -10,7 +10,7 @@ angular.module('Bastion.products', [ 'ui.router', 'Bastion', 'Bastion.components', - 'Bastion.gpg-keys', + 'Bastion.content-credentials', 'Bastion.architectures', 'Bastion.i18n', 'Bastion.sync-plans', diff --git a/engines/bastion_katello/lib/bastion_katello/engine.rb b/engines/bastion_katello/lib/bastion_katello/engine.rb index 43b065eacf6..d429c1722dc 100644 --- a/engines/bastion_katello/lib/bastion_katello/engine.rb +++ b/engines/bastion_katello/lib/bastion_katello/engine.rb @@ -18,6 +18,7 @@ class Engine < ::Rails::Engine :stylesheet => 'bastion_katello/bastion_katello', :pages => %w( activation_keys + content_credentials content_hosts content_views debs @@ -26,7 +27,6 @@ class Engine < ::Rails::Engine ostree_branches errata packages - gpg_keys lifecycle_environments products puppet_modules diff --git a/lib/katello/permission_creator.rb b/lib/katello/permission_creator.rb index a3a834edc2e..d98e6d09f6d 100644 --- a/lib/katello/permission_creator.rb +++ b/lib/katello/permission_creator.rb @@ -9,6 +9,7 @@ def define capsule_content_permissions content_view_permissions gpg_key_permissions + content_credential_permissions host_collections_permissions lifecycle_environment_permissions product_permissions @@ -165,6 +166,29 @@ def gpg_key_permissions :resource_type => 'Katello::GpgKey' end + def content_credential_permissions + @plugin.permission :view_content_credentials, + { + 'katello/api/v2/content_credentials' => [:index, :show, :content, :auto_complete_search] + }, + :resource_type => 'Katello::GpgKey' + @plugin.permission :create_content_credentials, + { + 'katello/api/v2/content_credentials' => [:create] + }, + :resource_type => 'Katello::GpgKey' + @plugin.permission :edit_content_credentials, + { + 'katello/api/v2/content_credentials' => [:update, :set_content] + }, + :resource_type => 'Katello::GpgKey' + @plugin.permission :destroy_content_credentials, + { + 'katello/api/v2/content_credentials' => [:destroy] + }, + :resource_type => 'Katello::GpgKey' + end + def host_collections_permissions @plugin.permission :view_host_collections, { diff --git a/lib/katello/plugin.rb b/lib/katello/plugin.rb index f773b5b1677..dd22e09b99a 100644 --- a/lib/katello/plugin.rb +++ b/lib/katello/plugin.rb @@ -33,10 +33,10 @@ :turbolinks => false menu :top_menu, - :gpg_keys, - :caption => N_('GPG Keys'), - :url => '/gpg_keys', - :url_hash => {:controller => 'katello/api/v2/gpg_keys', + :content_credentials, + :caption => N_('Content Credentials'), + :url => '/content_credentials', + :url_hash => {:controller => 'katello/api/v2/content_credentials', :action => 'index'}, :engine => Katello::Engine, :turbolinks => false