From f1a8b1fd6f425557937647770865379689ad897c Mon Sep 17 00:00:00 2001 From: Ilya Zhitomirskiy Date: Thu, 15 Sep 2011 16:35:48 -0700 Subject: [PATCH] added the namespace constraint back to the envelope, protocol route, data type is now plain xml --- config/routes.rb | 3 +++ lib/salmon/magic_sig_envelope.rb | 13 +++++++------ lib/salmon/slap.rb | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 217b17ef6..a86351dce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -157,6 +157,9 @@ Diaspora::Application.routes.draw do get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile' + #Protocol Url + get 'protocol' => redirect("https://github.com/diaspora/diaspora/wiki/Diaspora%27s-federation-protocol") + # Startpage root :to => 'home#show' diff --git a/lib/salmon/magic_sig_envelope.rb b/lib/salmon/magic_sig_envelope.rb index d43644b95..44527513c 100644 --- a/lib/salmon/magic_sig_envelope.rb +++ b/lib/salmon/magic_sig_envelope.rb @@ -10,21 +10,22 @@ module Salmon # @return [MagicSigEnvelope] def self.parse(doc) env = self.new - env.encoding = doc.search('//me:env/me:encoding').text.strip + ns = {'me'=>'http://salmon-protocol.org/ns/magic-env'} + env.encoding = doc.search('//me:env/me:encoding', ns).text.strip if env.encoding != 'base64url' raise ArgumentError, "Magic Signature data must be encoded with base64url, was #{env.encoding}" end - env.data = doc.search('//me:env/me:data').text - env.alg = doc.search('//me:env/me:alg').text.strip + env.data = doc.search('//me:env/me:data', ns).text + env.alg = doc.search('//me:env/me:alg', ns).text.strip unless 'RSA-SHA256' == env.alg raise ArgumentError, "Magic Signature data must be signed with RSA-SHA256, was #{env.alg}" end - env.sig = doc.search('//me:env/me:sig').text - env.data_type = doc.search('//me:env/me:data').first['type'].strip + env.sig = doc.search('//me:env/me:sig', ns).text + env.data_type = doc.search('//me:env/me:data', ns).first['type'].strip env end @@ -69,7 +70,7 @@ ENTRY # @return [String] def get_data_type - 'application/atom+xml' + 'application/xml' end # @return [String] diff --git a/lib/salmon/slap.rb b/lib/salmon/slap.rb index 1d67987a6..61ea14996 100644 --- a/lib/salmon/slap.rb +++ b/lib/salmon/slap.rb @@ -70,7 +70,7 @@ module Salmon def xml_for(person) @xml =< - + #{header(person)} #{@magic_sig.to_xml}