<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>?WEB? &#187; Protocols</title>
	<atom:link href="http://whatwebwhat.com/category/technology/protocols/feed/" rel="self" type="application/rss+xml" />
	<link>http://whatwebwhat.com</link>
	<description>WhatWebWhat / Marc Worrell / Freelance Pragmatic Innovation</description>
	<pubDate>Fri, 13 Nov 2009 18:34:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>OAuth and URL encoding</title>
		<link>http://whatwebwhat.com/2008/10/11/oauth-and-url-encoding/</link>
		<comments>http://whatwebwhat.com/2008/10/11/oauth-and-url-encoding/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 18:07:11 +0000</pubDate>
		<dc:creator>Marc Worrell</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<category><![CDATA[Protocols]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[oauth]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://whatwebwhat.com/?p=82</guid>
		<description><![CDATA[Differences in URL encoding functions will make implementation of OAuth harder. There is an immediate need for correct parameter encoding implementations.
I maintain an implementation of OAuth. Whilst checking existing code and implementing my own version I wondered how some implementations will differ.
OAuth uses RFC3986 for the encoding of URI parameters. Another often used encoding scheme is RFC1738 or RFC2396 (updated in RFC2732).
The [...]]]></description>
			<content:encoded><![CDATA[<p>Differences in URL encoding functions will make implementation of OAuth harder. There is an immediate need for correct parameter encoding implementations.</p>
<p>I maintain an <a href="http://code.google.com/p/oauth-php/">implementation</a> of <a href="http://oauth.net/">OAuth</a>. Whilst checking existing code and implementing my own version I wondered how some implementations will differ.</p>
<p>OAuth uses <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC3986</a> for the encoding of URI parameters. Another often used encoding scheme is <a href="http://www.faqs.org/rfcs/rfc1738">RFC1738</a> or <a href="http://www.faqs.org/rfcs/rfc2396.html">RFC2396</a> (updated in RFC2732).</p>
<p>The differences? Quite a bit.</p>
<p>The <em>unreserved</em> characters in RFC3986 are:</p>
<pre>unreserved = ALPHA, DIGIT, '-', '.', '_', '~'</pre>
<p>And in RFC17138:</p>
<pre>
unreserved     = alpha | digit | safe | extra
safe           = "$" | "-" | "_" | "." | "+"
extra          = "!" | "*" | "'" | "(" | ")" | ","
</pre>
<p>And in RFC2396/2732</p>
<pre>
"A" .. "Z", "a" .. "z", "0" .. "9",
"-", "_", ".", "!", "~", "*", "'", "(", ")"
</pre>
<h2>What do some programming languages use?</h2>
<h3>PHP</h3>
<p>PHP has two options. Use <tt>urlencode</tt> or <tt>rawurlencode</tt>. The difference between the two is the escaping of the “<tt>+</tt>” character.</p>
<p><tt>rawurlencode</tt> claim to fame is to be compatible with RFC1738. In fact it is not. It encodes all characters as in RFC3986, and then also the “<tt>~</tt>”. So <tt>rawurlencode</tt> comes close. It escapes everything, except:</p>
<pre>A-Za-z0-9\-_.</pre>
<p>So the only difference here is the “<tt>~</tt>” character. The correct funtion will be:</p>
<pre>function oauth_urlencode ( $s )
{
    return str_replace('%7E', '~', rawurlencode($s);
}
</pre>
<h3>Perl</h3>
<p>CPAN implements <tt>URI:Escape</tt>. This one uses RFC2396/2732 as the basis for its character encoding. The default for this function is to escape everything except:</p>
<pre>A-Za-z0-9\-_.!~*'()</pre>
<h3>Javascript</h3>
<p>Yet another encoding method. Most javascript programmers will use the function <tt>escape</tt>. This one encoded everything except:</p>
<pre>A-Za-z0-9\-_.+*/@</pre>
<p>Addition from John Kristian: when you want to encode with Javascript you can take a look at<tt>OAuth.percentEncode</tt> in <a href="http://oauth.googlecode.com/svn/code/javascript/oauth.js">oauth.googlecode.com/svn/code/javascript/oauth.js</a></p>
<h2>It is a mess, what to do?</h2>
<p>I assume that programmers are lazy and will re-use their good old trusty encoding functions. They should, it is how we train programmers. This will give some interesting problems with OAuth though, as OAuth insists on encoding and sometimes double encoding parameters. And uses those encoded values to calculate the signature of a message.</p>
<p>This insistance on using a very specific implementation of encoding is, in my opinion, the Achilles heel of OAuth.</p>
<p>When checking the signature we have basically two options:</p>
<ol>
<li><em>Not decode</em> whatever comes in before recalculating the signature. In that way we won&#8217;t make any false assumptions about parameters being encoded one way or the other.</li>
<li><em>Recode</em> all incoming parameter values and names, in that way we make sure that we use the correct encoding (according to the spec) for our signature calculation.</li>
</ol>
<p>However, we <em>must assume</em> that the encoding used in calculating the signature base string and the key from the consumer secret and the token secret is correct according to RFC3986.</p>
<h2>Conclusion</h2>
<p>We, as a community using OAuth, need to create test sets that will test all edge cases, otherwise we are in for a rough ride. And, to help other programmers, there is an immediate need for correct implementations of the RFC3986 parameter encoding.</p>
<h2>Update</h2>
<p>The OAuth community has a nice set of testcases online at <a href="http://wiki.oauth.net/TestCases">wiki.oauth.net/TestCases</a> Let&#8217;s all use them and make sure that our implementations are correct!</p>
]]></content:encoded>
			<wfw:commentRss>http://whatwebwhat.com/2008/10/11/oauth-and-url-encoding/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Open-CI — The Technology</title>
		<link>http://whatwebwhat.com/2008/10/11/open-ci-the-technology/</link>
		<comments>http://whatwebwhat.com/2008/10/11/open-ci-the-technology/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 17:56:07 +0000</pubDate>
		<dc:creator>Marc Worrell</dc:creator>
		
		<category><![CDATA[Protocols]]></category>

		<category><![CDATA[Web Projects]]></category>

		<category><![CDATA[oauth]]></category>

		<category><![CDATA[open-ci]]></category>

		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://whatwebwhat.com/?p=76</guid>
		<description><![CDATA[We are proposing a range of existing technologies to enable the federation of social networks. Some are quite new, some are well established. Here I give a short overview of the technologies and how to work together in creating a personal network.
We are not the only ones interested in integrating our content. So far, we&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>We are proposing a range of existing technologies to enable the federation of social networks. Some are quite new, some are well established. Here I give a short overview of the technologies and how to work together in creating a personal network.</p>
<p>We are not the only ones interested in integrating our content. So far, we&#8217;ve started looking at various possibilities- for users and servers signing on to (federated) social networks, for publishing, aggregating, exchanging and subscription to content, and for better ways to describe content and meta-content on the social networks.</p>
<h3>Authenticating People: OpenID</h3>
<p>To avoid having to create a separate login and password for each social network, we have been integrating the decentralized log-in system provided by OpenID for user authentication.</p>
<h3>Servers Communicating With Other Servers: OAuth</h3>
<p>Once we have users signed into one social network, we want to allow them to move their data from one network to another. For this we are looking at the open protocol OAuth, which will standardize server to server communication, i.e. the passing of authentication tokens through APIs. This will help make our server-side communication more robust and streamlined.</p>
<h3>Representing Information: Atom + RDF</h3>
<p>After authenticating, but before we can move content from one place to another, we also need a way to define our content. We&#8217;re starting to use RDF as a standard formatting method for our content. We see users and their contacts as another form of content, and are using FOAF to describe their networks. Other forms of content, such as events or projects, allow other standard formatting techniques permissible in RDF- such as DOAF, SOAF and MicroFormats.</p>
<h3>Finding Information In The Network: OpenSearch</h3>
<p>Since our implementation of RDF will be done in XML, it could be pretty easy to search through the various pages&#8217; content and meta-content. To do this, we&#8217;re looking into OpenSearch, which should standardize the presentation of information as well as allow auto-discovery, for instance of things like OpenIDs. We&#8217;re still looking into ways to keep our website scalable while using OpenSearch.</p>
<h3>Staying Up To Date With Changes: XMPP Publish &#038; Subscribe</h3>
<p>Once we have our content properly labeled, we can use standards like Atom1.0 to exchange parts of our content. Specifically, we can use Atom to format newsfeeds and other time-sensitive content, and then use XMPP to announce it. By using XMPP instead of HTTP, we can have persistant connections which will allow the networks to propagate changes as fast as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://whatwebwhat.com/2008/10/11/open-ci-the-technology/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.114 seconds -->
