From ed8e340fa29f6d2afea3b9d9bcd89670893425d5 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 23 Jul 2022 00:17:06 +0200 Subject: [PATCH 1/2] Add a dummy route for /.well-known/host-meta This was removed from the diaspora_federation gem, since it's not used for the federation/discovery anymore since a long time. But old versions of the ConnectionTester up to version 0.7.17 still check if this route exist or else they mark the pod as offline. So lets add a dummy host-meta with an empty response back, so the ConnectionTester is happy again until we can remove this workaround again. --- app/controllers/node_info_controller.rb | 10 ++++++++++ config/initializers/cors.rb | 1 - config/routes.rb | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/node_info_controller.rb b/app/controllers/node_info_controller.rb index cb831a595..18aa93c98 100644 --- a/app/controllers/node_info_controller.rb +++ b/app/controllers/node_info_controller.rb @@ -20,4 +20,14 @@ class NodeInfoController < ApplicationController format.all { @statistics = NodeInfoPresenter.new("1.0") } end end + + # TODO: this is only a dummy endpoint, because old versions of the ConnectionTester (<= 0.7.17.0) + # checked for this endpoint. Remove this endpoint again once most pods are updated to >= 0.7.18.0 + def host_meta + render xml: <<~XML + + + + XML + end end diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 11a6a225b..4575c3b64 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -11,7 +11,6 @@ Rails.application.config.middleware.insert_before 0, Rack::Cors do allow do origins "*" resource "/api/*", methods: :any - resource "/.well-known/host-meta" resource "/.well-known/webfinger" resource "/.well-known/openid-configuration" end diff --git a/config/routes.rb b/config/routes.rb index f15cdd1d1..45f992209 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -213,6 +213,7 @@ Rails.application.routes.draw do get ".well-known/nodeinfo", to: "node_info#jrd" get "nodeinfo/:version", to: "node_info#document", as: "node_info", constraints: {version: /\d+\.\d+/} get "statistics", to: "node_info#statistics" + get ".well-known/host-meta", to: "node_info#host_meta" # Terms if AppConfig.settings.terms.enable? || Rails.env.test? From 419ed4d9fc6c7ab52fbfa4fae6993c4ee7e3504d Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 23 Jul 2022 00:21:06 +0200 Subject: [PATCH 2/2] Remove old stubs for /.well-known/host-meta Since the diaspora_federation gem doesn't try to access host-meta anymore, there is no need to create stubs for it anymore. --- spec/integration/migration_service_spec.rb | 2 -- spec/lib/archive_importer/post_importer_spec.rb | 2 -- spec/lib/archive_importer_spec.rb | 2 -- .../archive_validator/author_private_key_validator_spec.rb | 2 -- spec/spec_helper.rb | 4 ---- 5 files changed, 12 deletions(-) diff --git a/spec/integration/migration_service_spec.rb b/spec/integration/migration_service_spec.rb index 84de21a6a..9ec5680f1 100644 --- a/spec/integration/migration_service_spec.rb +++ b/spec/integration/migration_service_spec.rb @@ -438,8 +438,6 @@ describe MigrationService do expect(DiasporaFederation::Discovery::Discovery).to receive(:new).with(archive_author).and_call_original stub_request(:get, "https://#{old_pod_hostname}/.well-known/webfinger?resource=acct:#{archive_author}") .to_return(status: 404) - stub_request(:get, %r{https*://#{old_pod_hostname}/\.well-known/host-meta}) - .to_return(status: 404) expect_relayable_parent_fetch(archive_author, existing_subscription_guid) .and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable) diff --git a/spec/lib/archive_importer/post_importer_spec.rb b/spec/lib/archive_importer/post_importer_spec.rb index 9d7852349..15df64f88 100644 --- a/spec/lib/archive_importer/post_importer_spec.rb +++ b/spec/lib/archive_importer/post_importer_spec.rb @@ -87,8 +87,6 @@ describe ArchiveImporter::PostImporter do :get, %r{https*://old_pod\.nowhere/\.well-known/webfinger\?resource=acct:old_id@old_pod\.nowhere} ).to_return(status: 404, body: "", headers: {}) - stub_request(:get, %r{https*://old_pod\.nowhere/\.well-known/host-meta}) - .to_return(status: 404, body: "", headers: {}) expect { instance.import diff --git a/spec/lib/archive_importer_spec.rb b/spec/lib/archive_importer_spec.rb index 1579371c9..2ad211965 100644 --- a/spec/lib/archive_importer_spec.rb +++ b/spec/lib/archive_importer_spec.rb @@ -95,8 +95,6 @@ describe ArchiveImporter do before do stub_request(:get, %r{https*://old_pod\.nowhere/\.well-known/webfinger\?resource=acct:old_id@old_pod\.nowhere}) .to_return(status: 404, body: "", headers: {}) - stub_request(:get, %r{https*://old_pod\.nowhere/\.well-known/host-meta}) - .to_return(status: 404, body: "", headers: {}) end it "doesn't fail" do diff --git a/spec/lib/archive_validator/author_private_key_validator_spec.rb b/spec/lib/archive_validator/author_private_key_validator_spec.rb index cbaae8a8e..544661ea5 100644 --- a/spec/lib/archive_validator/author_private_key_validator_spec.rb +++ b/spec/lib/archive_validator/author_private_key_validator_spec.rb @@ -56,8 +56,6 @@ describe ArchiveValidator::AuthorPrivateKeyValidator do before do stub_request(:get, %r{https*://old_pod\.nowhere/\.well-known/webfinger\?resource=acct:old_id@old_pod\.nowhere}) .to_return(status: 404, body: "", headers: {}) - stub_request(:get, %r{https*://old_pod\.nowhere/\.well-known/host-meta}) - .to_return(status: 404, body: "", headers: {}) end include_examples "validation result is valid" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e50ea8b09..3926b7f9f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -108,10 +108,6 @@ RSpec.configure do |config| :get, "https://example.com/.well-known/webfinger?resource=acct:bob@example.com" ) - stub_request( - :get, - "https://example.com/.well-known/host-meta" - ) $process_queue = false end