From 9e348bfdd81a4b0acce2b660940245ed40b26267 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 19 Apr 2023 14:56:20 -0300 Subject: [PATCH 1/2] fix: los subdominios para los sitios vienen de un certificado wildcard #13159 --- app/controllers/api/v1/sites_controller.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/controllers/api/v1/sites_controller.rb b/app/controllers/api/v1/sites_controller.rb index ae64cf74..185d0b24 100644 --- a/app/controllers/api/v1/sites_controller.rb +++ b/app/controllers/api/v1/sites_controller.rb @@ -9,7 +9,7 @@ module Api # Lista de nombres de dominios a emitir certificados def index - render json: sites_names + alternative_names + api_names + www_names + render json: alternative_names + api_names + www_names end private @@ -18,13 +18,6 @@ module Api name.end_with?('.') ? name[0..-2] : "#{name}.#{Site.domain}" end - # Nombres de los sitios - def sites_names - Site.all.order(:name).pluck(:name).map do |name| - canonicalize name - end - end - # Dominios alternativos def alternative_names (DeployAlternativeDomain.all.map(&:hostname) + DeployLocalizedDomain.all.map(&:hostname)).map do |name| From 11fe98ecdc76a25f343414afde8dd1fa86d86c37 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 19 Apr 2023 14:56:56 -0300 Subject: [PATCH 2/2] fix: ignorar los subdominios en los dominios alternativos #13159 --- app/controllers/api/v1/sites_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/api/v1/sites_controller.rb b/app/controllers/api/v1/sites_controller.rb index 185d0b24..05abc38a 100644 --- a/app/controllers/api/v1/sites_controller.rb +++ b/app/controllers/api/v1/sites_controller.rb @@ -18,10 +18,16 @@ module Api name.end_with?('.') ? name[0..-2] : "#{name}.#{Site.domain}" end + def subdomain?(name) + name.end_with? ".#{Site.domain}" + end + # Dominios alternativos def alternative_names (DeployAlternativeDomain.all.map(&:hostname) + DeployLocalizedDomain.all.map(&:hostname)).map do |name| canonicalize name + end.reject do |name| + subdomain? name end end @@ -34,6 +40,8 @@ module Api .or(Site.where(colaboracion_anonima: true)) .select("'api.' || name as name").map(&:name).map do |name| canonicalize name + end.reject do |name| + subdomain? name end end