<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Fischer dot Name &#187; ssl</title>
	<atom:link href="http://www.davidfischer.name/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidfischer.name</link>
	<description>Some Things to Some People</description>
	<lastBuildDate>Thu, 15 Jul 2010 21:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>RPC4Django Update October 2009</title>
		<link>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/</link>
		<comments>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 04:10:04 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rpc4django]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.davidfischer.name/?p=285</guid>
		<description><![CDATA[A user has requested that]]></description>
			<content:encoded><![CDATA[<p>A user has requested that RPC4Django support <a href="https://developer.mozilla.org/en/HTTP_access_control">HTTP access control</a>. This is the new preferred method where newer browsers are allowed to make cross domain AJAX requests (with specific constraints) without having to resort to hacks and workarounds like dynamic script tags. I also want to work on <a href="http://json-rpc.org/wiki/specification#a3.JSONClasshinting">JSON class hinting</a>, which is not currently supported. I&#8217;m shooting to get this going in the next week before I leave for a Mexican vacation. Swine flu has made the Mexican resorts very reasonable.</p>
<h5>Weird Issue on Chrome</h5>
<p>In addition, I have noticed that the <a href="https://rpcauth.davidfischer.name/">authenticated demo site</a> does not work in Google Chrome. Is anyone else experiencing this? Any idea why? There&#8217;s no problem with Chrome on the demo site not running ssl.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>RPC and Authentication</title>
		<link>http://www.davidfischer.name/2009/09/rpc-and-authentication/</link>
		<comments>http://www.davidfischer.name/2009/09/rpc-and-authentication/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 05:04:45 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[amazons3]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[rpc4django]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.davidfischer.name/?p=239</guid>
		<description><![CDATA[I&#8217;m working on adding support]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on adding support for authenticated service calls to <a href="http://www.davidfischer.name/rpc4django/">RPC4Django</a> built on top of Django&#8217;s <a href="http://docs.djangoproject.com/en/dev/topics/auth">user authentication</a>. While doing this, I took a brief look around at how other projects implemented authentication for XMLRPC or JSONRPC. Without exception, they all implemented it such that the username and password was part of the RPC call like so:</p>
<pre><code class="python">from django.contrib.auth import authenticate

def myAuthenticatedMethod(user, password, otherparams):
    # authenticate user
    user = authenticate(username=user, password=password)

    # verify the user is valid and has the appropriate permissions
    # perform method actions</code></pre>
<p>Some of them abstracted the actual username and password checking into a decorator, but in the end, the RPC call had the username and password in the parameters. It seemed bulky and out of place. This led to an analysis about authentication and authorization and what should be handled where. As a little spoiler, I don&#8217;t like the idea of sending the username and password in the RPC parameters one bit.</p>
<h5>Authentication &#038; Authorization</h5>
<p>In applications, authentication is the process that confirms the identity of the user. Usually this takes the form of a login form, HTTP basic authentication,  or something similar. Authorization is the process to determine whether the user has sufficient privileges to perform the specified action. This takes the form of permission checks based on the authenticated user. Therefore, authentication must come before authorization. </p>
<p>Fortunately, Django&#8217;s user authentication helps with both authentication and authorization. The <code><a href="http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.authenticate">authenticate</a></code> method checks a username and password against the set of Django users and gets the user object if everything goes well. Once this user object is retrieved, permissions can be checked using the <code><a href="http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.has_perm">has_perm</a></code> method. Django has a pretty easy way to create new permissions based on your application&#8217;s logic. Permissions have to be checked at the specific method level since permissions are closely tied to the application logic. I like the idea of abstracting much of it into a decorator though. The only remaining question is: where does the username and password come from?</p>
<h5>An Example from the Real World</h5>
<p>Why should every RPC method need to be specially written to accept the login credentials and authenticate the user? This makes the method only usable as an RPC method and not useful at all to the rest of the project which is bad for code reuse. <a href="http://aws.amazon.com/s3/">Amazon s3</a>, a commercial web service for storing files, is a perfect example of the proper way to authenticate and authorize users. With s3, the login information is contained in the HTTP header in a manner similar to HTTP basic authentication and in this way the request can be rejected earlier based on login credentials before the request even routes to the proper method requested. Permission checking, seeing whether the user is allowed to store new files for example, still needs to be done at the method level but at least the identity of the user is known.</p>
<h5>Implementation and Demo</h5>
<p>For RPC4Django, I&#8217;m proposing that authentication be handled at a higher level &#8212; with basic HTTP authentication for example. To illustrate this, I set up an https RPC4Django <a href="https://rpcauth.davidfischer.name/">demo site</a> that requires a username and password (rpc4django/rpc4django). The demo site requires that you accept a self-signed certificate. Using python, it is possible to send authenticated requests like so:</p>
<pre><code class="python">from xmlrpclib import ServerProxy
s = ServerProxy('https://rpc4django:rpc4django@rpcauth.davidfischer.name/')
s.system.listMethods()</code></pre>
<p>The next step is to modify RPC4Django to actually be able to specify permissions for specific methods and to actually log in the users. Expect a release this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidfischer.name/2009/09/rpc-and-authentication/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
