added the namespace constraint back to the envelope, protocol route, data type is now plain xml

This commit is contained in:
Ilya Zhitomirskiy 2011-09-15 16:35:48 -07:00
parent c98189b057
commit f1a8b1fd6f
3 changed files with 11 additions and 7 deletions

View file

@ -157,6 +157,9 @@ Diaspora::Application.routes.draw do
get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile' 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 # Startpage
root :to => 'home#show' root :to => 'home#show'

View file

@ -10,21 +10,22 @@ module Salmon
# @return [MagicSigEnvelope] # @return [MagicSigEnvelope]
def self.parse(doc) def self.parse(doc)
env = self.new 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' if env.encoding != 'base64url'
raise ArgumentError, "Magic Signature data must be encoded with base64url, was #{env.encoding}" raise ArgumentError, "Magic Signature data must be encoded with base64url, was #{env.encoding}"
end end
env.data = doc.search('//me:env/me:data').text env.data = doc.search('//me:env/me:data', ns).text
env.alg = doc.search('//me:env/me:alg').text.strip env.alg = doc.search('//me:env/me:alg', ns).text.strip
unless 'RSA-SHA256' == env.alg unless 'RSA-SHA256' == env.alg
raise ArgumentError, "Magic Signature data must be signed with RSA-SHA256, was #{env.alg}" raise ArgumentError, "Magic Signature data must be signed with RSA-SHA256, was #{env.alg}"
end end
env.sig = doc.search('//me:env/me:sig').text env.sig = doc.search('//me:env/me:sig', ns).text
env.data_type = doc.search('//me:env/me:data').first['type'].strip env.data_type = doc.search('//me:env/me:data', ns).first['type'].strip
env env
end end
@ -69,7 +70,7 @@ ENTRY
# @return [String] # @return [String]
def get_data_type def get_data_type
'application/atom+xml' 'application/xml'
end end
# @return [String] # @return [String]

View file

@ -70,7 +70,7 @@ module Salmon
def xml_for(person) def xml_for(person)
@xml =<<ENTRY @xml =<<ENTRY
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<diaspora xmlns="https://github.com/diaspora/diaspora/wiki/Diaspora%27s-federation-protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env"> <diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
#{header(person)} #{header(person)}
#{@magic_sig.to_xml} #{@magic_sig.to_xml}
</diaspora> </diaspora>