don't add key_id to legacy private encrypted slap xml
This commit is contained in:
parent
3811cd0c03
commit
0990eff69c
3 changed files with 13 additions and 4 deletions
|
|
@ -114,7 +114,7 @@ module DiasporaFederation
|
||||||
EncryptedSlap.new.tap do |slap|
|
EncryptedSlap.new.tap do |slap|
|
||||||
slap.author_id = author_id
|
slap.author_id = author_id
|
||||||
|
|
||||||
magic_envelope = MagicEnvelope.new(entity, author_id)
|
magic_envelope = MagicEnvelope.new(entity)
|
||||||
slap.cipher_params = magic_envelope.encrypt!
|
slap.cipher_params = magic_envelope.encrypt!
|
||||||
slap.magic_envelope_xml = magic_envelope.envelop(privkey)
|
slap.magic_envelope_xml = magic_envelope.envelop(privkey)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ module DiasporaFederation
|
||||||
# @param [Entity] payload Entity instance
|
# @param [Entity] payload Entity instance
|
||||||
# @param [String] sender diaspora-ID of the sender
|
# @param [String] sender diaspora-ID of the sender
|
||||||
# @raise [ArgumentError] if either argument is not of the right type
|
# @raise [ArgumentError] if either argument is not of the right type
|
||||||
def initialize(payload, sender)
|
def initialize(payload, sender=nil)
|
||||||
raise ArgumentError unless payload.is_a?(Entity) && sender.is_a?(String)
|
raise ArgumentError unless payload.is_a?(Entity)
|
||||||
|
|
||||||
@payload = payload
|
@payload = payload
|
||||||
@sender = sender
|
@sender = sender
|
||||||
|
|
@ -69,7 +69,7 @@ module DiasporaFederation
|
||||||
xml["me"].data(Base64.urlsafe_encode64(payload_data), type: DATA_TYPE)
|
xml["me"].data(Base64.urlsafe_encode64(payload_data), type: DATA_TYPE)
|
||||||
xml["me"].encoding(ENCODING)
|
xml["me"].encoding(ENCODING)
|
||||||
xml["me"].alg(ALGORITHM)
|
xml["me"].alg(ALGORITHM)
|
||||||
xml["me"].sig(Base64.urlsafe_encode64(sign(privkey)), key_id: Base64.urlsafe_encode64(sender))
|
xml["me"].sig(Base64.urlsafe_encode64(sign(privkey)), key_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
@ -132,6 +132,10 @@ module DiasporaFederation
|
||||||
@payload_data ||= XmlPayload.pack(@payload).to_xml.strip
|
@payload_data ||= XmlPayload.pack(@payload).to_xml.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def key_id
|
||||||
|
sender ? {key_id: Base64.urlsafe_encode64(sender)} : {}
|
||||||
|
end
|
||||||
|
|
||||||
# Builds the xml root node of the magic envelope.
|
# Builds the xml root node of the magic envelope.
|
||||||
#
|
#
|
||||||
# @yield [xml] Invokes the block with the
|
# @yield [xml] Invokes the block with the
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,11 @@ module DiasporaFederation
|
||||||
expect(doc1.xpath("d:diaspora/me:env", ns).to_xml).to eq(doc2.xpath("d:diaspora/me:env", ns).to_xml)
|
expect(doc1.xpath("d:diaspora/me:env", ns).to_xml).to eq(doc2.xpath("d:diaspora/me:env", ns).to_xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not add the sender to the magic envelope" do
|
||||||
|
doc = Nokogiri::XML::Document.parse(slap_xml)
|
||||||
|
expect(doc.at_xpath("d:diaspora/me:env/me:sig", ns)["key_id"]).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
context "header" do
|
context "header" do
|
||||||
subject {
|
subject {
|
||||||
doc = Nokogiri::XML::Document.parse(slap_xml)
|
doc = Nokogiri::XML::Document.parse(slap_xml)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue