diff --git a/lib/diaspora_federation/discovery/discovery.rb b/lib/diaspora_federation/discovery/discovery.rb index d327bae..18f4054 100644 --- a/lib/diaspora_federation/discovery/discovery.rb +++ b/lib/diaspora_federation/discovery/discovery.rb @@ -74,10 +74,10 @@ module DiasporaFederation def person @person ||= Entities::Person.new( - guid: hcard.guid || webfinger.guid, + guid: hcard.guid, diaspora_id: diaspora_id, url: webfinger.seed_url, - exported_key: hcard.public_key || webfinger.public_key, + exported_key: hcard.public_key, profile: profile ) end diff --git a/lib/diaspora_federation/discovery/h_card.rb b/lib/diaspora_federation/discovery/h_card.rb index 816127f..129fd3b 100644 --- a/lib/diaspora_federation/discovery/h_card.rb +++ b/lib/diaspora_federation/discovery/h_card.rb @@ -167,8 +167,7 @@ module DiasporaFederation photo_medium_url: photo_from_doc(doc, :photo_medium), photo_small_url: photo_from_doc(doc, :photo_small), searchable: (content_from_doc(doc, :searchable) == "true"), - # TODO: public key is new and can be missing - public_key: (content_from_doc(doc, :key) unless element_from_doc(doc, :key).nil?), + public_key: content_from_doc(doc, :key), # TODO: remove first_name and last_name! first_name: content_from_doc(doc, :given_name), diff --git a/lib/diaspora_federation/discovery/web_finger.rb b/lib/diaspora_federation/discovery/web_finger.rb index 5c9444b..5a9fd46 100644 --- a/lib/diaspora_federation/discovery/web_finger.rb +++ b/lib/diaspora_federation/discovery/web_finger.rb @@ -14,9 +14,7 @@ module DiasporaFederation # seed_url: "https://server.example/", # profile_url: "https://server.example/u/user", # atom_url: "https://server.example/public/user.atom", - # salmon_url: "https://server.example/receive/users/0123456789abcdef", - # guid: "0123456789abcdef", - # public_key: "-----BEGIN PUBLIC KEY-----\nABCDEF==\n-----END PUBLIC KEY-----" + # salmon_url: "https://server.example/receive/users/0123456789abcdef" # ) # xml_string = wf.to_xml # @@ -76,42 +74,12 @@ module DiasporaFederation # This url is used to find another user on the home-pod of the user in the webfinger. property :subscribe_url, :string - # @!attribute [r] guid - # @deprecated Either convert these to +Property+ elements or move to the - # +hCard+, which actually has fields for an +UID+ defined in the +vCard+ - # specification (will affect older diaspora* installations). - # - # @see HCard#guid - # @see Entities::Person#guid - # @return [String] guid - property :guid, :string - - # @!attribute [r] public_key - # @deprecated Either convert these to +Property+ elements or move to the - # +hCard+, which actually has fields for an +KEY+ defined in the +vCard+ - # specification (will affect older diaspora* installations). - # - # @see HCard#public_key - # - # When a user is created on the pod, the pod MUST generate a pgp keypair - # for them. This key is used for signing messages. The format is a - # DER-encoded PKCS#1 key beginning with the text - # "-----BEGIN PUBLIC KEY-----" and ending with "-----END PUBLIC KEY-----". - # @return [String] public key - property :public_key, :string - # +hcard_url+ link relation REL_HCARD = "http://microformats.org/profile/hcard".freeze # +seed_url+ link relation REL_SEED = "http://joindiaspora.com/seed_location".freeze - # @deprecated This should be a +Property+ or moved to the +hCard+, but +Link+ - # is inappropriate according to the specification (will affect older - # diaspora* installations). - # +guid+ link relation - REL_GUID = "http://joindiaspora.com/guid".freeze - # +profile_url+ link relation. # @note This might just as well be an +Alias+ instead of a +Link+. REL_PROFILE = "http://webfinger.net/rel/profile-page".freeze @@ -125,12 +93,6 @@ module DiasporaFederation # +subscribe_url+ link relation REL_SUBSCRIBE = "http://ostatus.org/schema/1.0/subscribe".freeze - # @deprecated This should be a +Property+ or moved to the +hcard+, but +Link+ - # is inappropriate according to the specification (will affect older - # diaspora* installations). - # +pubkey+ link relation - REL_PUBKEY = "diaspora-public-key".freeze - # Creates the XML string from the current WebFinger instance # @return [String] XML string def to_xml @@ -152,9 +114,6 @@ module DiasporaFederation links = data[:links] - # TODO: remove! public key is deprecated in webfinger - public_key = parse_link(links, REL_PUBKEY) - new( acct_uri: data[:subject], alias_url: parse_alias(data[:aliases]), @@ -164,11 +123,7 @@ module DiasporaFederation atom_url: parse_link(links, REL_ATOM), salmon_url: parse_link(links, REL_SALMON), - subscribe_url: parse_link_template(links, REL_SUBSCRIBE), - - # TODO: remove me! ########## - guid: parse_link(links, REL_GUID), - public_key: (Base64.strict_decode64(public_key) if public_key) + subscribe_url: parse_link_template(links, REL_SUBSCRIBE) ) end @@ -195,21 +150,11 @@ module DiasporaFederation doc.links << {rel: REL_HCARD, type: "text/html", href: @hcard_url} doc.links << {rel: REL_SEED, type: "text/html", href: @seed_url} - # TODO: remove me! ############## - doc.links << {rel: REL_GUID, type: "text/html", href: @guid} - ################################## - doc.links << {rel: REL_PROFILE, type: "text/html", href: @profile_url} doc.links << {rel: REL_ATOM, type: "application/atom+xml", href: @atom_url} doc.links << {rel: REL_SALMON, href: @salmon_url} doc.links << {rel: REL_SUBSCRIBE, template: @subscribe_url} - - # TODO: remove me! ############## - doc.links << {rel: REL_PUBKEY, - type: "RSA", - href: Base64.strict_encode64(@public_key)} - ################################## end private_class_method def self.find_link(links, rel) diff --git a/lib/diaspora_federation/test/factories.rb b/lib/diaspora_federation/test/factories.rb index 1efbb59..126f861 100644 --- a/lib/diaspora_federation/test/factories.rb +++ b/lib/diaspora_federation/test/factories.rb @@ -11,7 +11,6 @@ module DiasporaFederation Fabricate.sequence(:public_key) { OpenSSL::PKey::RSA.generate(1024).public_key.export } Fabricator(:webfinger, class_name: DiasporaFederation::Discovery::WebFinger) do - guid { Fabricate.sequence(:guid) } acct_uri { "acct:#{Fabricate.sequence(:diaspora_id)}" } alias_url "http://localhost:3000/people/0123456789abcdef" hcard_url "http://localhost:3000/hcard/users/user" @@ -19,7 +18,6 @@ module DiasporaFederation profile_url "http://localhost:3000/u/user" atom_url "http://localhost:3000/public/user.atom" salmon_url "http://localhost:3000/receive/users/0123456789abcdef" - public_key { Fabricate.sequence(:public_key) } subscribe_url "http://localhost:3000/people?q={uri}" end diff --git a/lib/diaspora_federation/validators/h_card_validator.rb b/lib/diaspora_federation/validators/h_card_validator.rb index 1803bc9..ea8e4f7 100644 --- a/lib/diaspora_federation/validators/h_card_validator.rb +++ b/lib/diaspora_federation/validators/h_card_validator.rb @@ -2,14 +2,11 @@ module DiasporaFederation module Validators # This validates a {Discovery::HCard}. # - # @todo activate guid and public key validation after all pod have it in - # the hcard. - # # @note class HCardValidator < Validation::Validator include Validation - # rule :guid, :guid + rule :guid, :guid # The name must not contain a semicolon because of mentions. # @{ ; } @@ -22,7 +19,7 @@ module DiasporaFederation rule :photo_medium_url, [:not_nil, URI: [:path]] rule :photo_small_url, [:not_nil, URI: [:path]] - # rule :exported_key, :public_key + rule :public_key, :public_key rule :searchable, :boolean end diff --git a/spec/lib/diaspora_federation/discovery/discovery_spec.rb b/spec/lib/diaspora_federation/discovery/discovery_spec.rb index 9ca8c24..a9a36b3 100644 --- a/spec/lib/diaspora_federation/discovery/discovery_spec.rb +++ b/spec/lib/diaspora_federation/discovery/discovery_spec.rb @@ -144,98 +144,6 @@ module DiasporaFederation expect { Discovery::Discovery.new(account).fetch_and_save }.to raise_error Discovery::DiscoveryError end - - it "reads old hcard without guid and public key" do - historic_hcard_html = <<-HTML -
-

#{account}

-
-
-

User profile

-
-
Nickname
-
- -
-
-
-
First name
-
- -
-
-
-
Family name
-
- -
-
-
-
Full name
-
- -
-
-
-
URL
-
-#{alice.url} -
-
-
-
Photo
-
- -
-
-
-
Photo
-
- -
-
-
-
Photo
-
- -
-
-
-
Searchable
-
-true -
-
-
-
-
-HTML - - stub_request(:get, "https://localhost:3000/.well-known/host-meta") - .to_return(status: 200, body: host_meta_xrd) - stub_request(:get, "http://localhost:3000/webfinger?q=acct:#{account}") - .to_return(status: 200, body: webfinger_xrd) - stub_request(:get, "http://localhost:3000/hcard/users/#{alice.guid}") - .to_return(status: 200, body: historic_hcard_html) - - expect_callback(:save_person_after_webfinger, kind_of(Entities::Person)) - person = Discovery::Discovery.new(account).fetch_and_save - - expect(person.guid).to eq(alice.guid) - expect(person.diaspora_id).to eq(account) - expect(person.url).to eq(alice.url) - expect(person.exported_key).to eq(alice.serialized_public_key) - - profile = person.profile - - expect(profile.diaspora_id).to eq(alice.diaspora_id) - expect(profile.first_name).to be_nil - expect(profile.last_name).to be_nil - - expect(profile.image_url).to eq(default_image) - expect(profile.image_url_medium).to eq(default_image) - expect(profile.image_url_small).to eq(default_image) - end end end end diff --git a/spec/lib/diaspora_federation/discovery/h_card_spec.rb b/spec/lib/diaspora_federation/discovery/h_card_spec.rb index e614de4..5644891 100644 --- a/spec/lib/diaspora_federation/discovery/h_card_spec.rb +++ b/spec/lib/diaspora_federation/discovery/h_card_spec.rb @@ -258,85 +258,6 @@ HTML expect(hcard.last_name).to be_nil end - it "reads old-style HTML" do - historic_html = <<-HTML -
-

#{person.full_name}

-
-
-

User profile

-
-
Nickname
-
-#{person.full_name} -
-
-
-
First name
-
-#{person.first_name} -
-
-
-
Family name
-
-#{person.last_name} -
-
-
-
Full name
-
-#{person.full_name} -
-
-
-
URL
-
-#{person.url} -
-
-
-
Photo
-
- -
-
-
-
Photo
-
- -
-
-
-
Photo
-
- -
-
-
-
Searchable
-
-#{person.searchable} -
-
-
-
-
-HTML - - hcard = Discovery::HCard.from_html(historic_html) - expect(hcard.photo_large_url).to eq(photo_large_url) - expect(hcard.photo_medium_url).to eq(photo_medium_url) - expect(hcard.photo_small_url).to eq(photo_small_url) - expect(hcard.searchable).to eq(person.searchable) - - expect(hcard.first_name).to eq(person.first_name) - expect(hcard.last_name).to eq(person.last_name) - - expect(hcard.guid).to be_nil - expect(hcard.public_key).to be_nil - end - it "fails if the document is incomplete" do invalid_html = <<-HTML
diff --git a/spec/lib/diaspora_federation/discovery/web_finger_spec.rb b/spec/lib/diaspora_federation/discovery/web_finger_spec.rb index 69d920e..0c40b51 100644 --- a/spec/lib/diaspora_federation/discovery/web_finger_spec.rb +++ b/spec/lib/diaspora_federation/discovery/web_finger_spec.rb @@ -13,8 +13,6 @@ module DiasporaFederation profile_url: person.profile_url, atom_url: person.atom_url, salmon_url: person.salmon_url, - guid: person.guid, - public_key: person.serialized_public_key, subscribe_url: person.subscribe_url } } @@ -26,12 +24,10 @@ module DiasporaFederation #{person.alias_url} - - XML @@ -57,9 +53,6 @@ XML expect(wf.atom_url).to eq(person.atom_url) expect(wf.salmon_url).to eq(person.salmon_url) expect(wf.subscribe_url).to eq(person.subscribe_url) - - expect(wf.guid).to eq(person.guid) - expect(wf.public_key).to eq(person.serialized_public_key) end it "reads minimal xml" do @@ -108,9 +101,6 @@ XML expect(wf.profile_url).to eq(person.profile_url) expect(wf.atom_url).to eq(person.atom_url) expect(wf.salmon_url).to eq(person.salmon_url) - - expect(wf.guid).to eq(person.guid) - expect(wf.public_key).to eq(person.serialized_public_key) end it "reads friendica XML (two aliases, first with acct)" do @@ -169,9 +159,6 @@ XML expect(wf.atom_url).to eq(person.atom_url) expect(wf.salmon_url).to eq(person.salmon_url) expect(wf.subscribe_url).to eq("https://pod.example.tld/follow?url={uri}") - - expect(wf.guid).to eq(person.guid) - expect(wf.public_key).to eq(person.serialized_public_key) end it "reads redmatrix XML (no alias)" do @@ -214,38 +201,6 @@ XML expect(wf.profile_url).to eq(person.profile_url) expect(wf.atom_url).to eq(person.atom_url) expect(wf.salmon_url).to be_nil - - expect(wf.guid).to eq(person.guid) - expect(wf.public_key).to eq(person.serialized_public_key) - end - - it "reads future XML without guid and public key" do - future_xml = <<-XML - - - #{acct} - #{person.alias_url} - - - - - - - -XML - - wf = Discovery::WebFinger.from_xml(future_xml) - expect(wf.acct_uri).to eq(acct) - expect(wf.alias_url).to eq(person.alias_url) - expect(wf.hcard_url).to eq(person.hcard_url) - expect(wf.seed_url).to eq(person.url) - expect(wf.profile_url).to eq(person.profile_url) - expect(wf.atom_url).to eq(person.atom_url) - expect(wf.salmon_url).to eq(person.salmon_url) - expect(wf.subscribe_url).to eq(person.subscribe_url) - - expect(wf.guid).to be_nil - expect(wf.public_key).to be_nil end it "fails if the document is empty" do