<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Django authentication and mod_wsgi</title>
	<atom:link href="http://www.davidfischer.name/2009/10/django-authentication-and-mod_wsgi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidfischer.name/2009/10/django-authentication-and-mod_wsgi/</link>
	<description>Some Things to Some People</description>
	<lastBuildDate>Thu, 02 Sep 2010 05:29:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: David</title>
		<link>http://www.davidfischer.name/2009/10/django-authentication-and-mod_wsgi/comment-page-1/#comment-212</link>
		<dc:creator>David</dc:creator>
		<pubDate>Wed, 26 May 2010 14:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=270#comment-212</guid>
		<description>Alessandro is correct. Without a middleware or something else, RPC4Django will not support some authenticated methods out of the box while others can be used by unauthenticated users. It&#039;s currently all or nothing.

There is currently a blueprint regarding adding a sort of &lt;a href=&quot;https://blueprints.launchpad.net/rpc4django/+spec/handle-authentication&quot; rel=&quot;nofollow&quot;&gt;out of the box authentication&lt;/a&gt; which would solve this but I have not had time to work on it.

I also want to talk about security in the next release. HTTP basic authentication really should not be used without SSL/TLS for maximum security. The new out of the box authentication will not solve the security issue. Unless you don&#039;t care about packet sniffing, passwords should be encrypted.</description>
		<content:encoded><![CDATA[<p>Alessandro is correct. Without a middleware or something else, RPC4Django will not support some authenticated methods out of the box while others can be used by unauthenticated users. It&#8217;s currently all or nothing.</p>
<p>There is currently a blueprint regarding adding a sort of <a href="https://blueprints.launchpad.net/rpc4django/+spec/handle-authentication" rel="nofollow">out of the box authentication</a> which would solve this but I have not had time to work on it.</p>
<p>I also want to talk about security in the next release. HTTP basic authentication really should not be used without SSL/TLS for maximum security. The new out of the box authentication will not solve the security issue. Unless you don&#8217;t care about packet sniffing, passwords should be encrypted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alessandro</title>
		<link>http://www.davidfischer.name/2009/10/django-authentication-and-mod_wsgi/comment-page-1/#comment-211</link>
		<dc:creator>Alessandro</dc:creator>
		<pubDate>Mon, 24 May 2010 10:44:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=270#comment-211</guid>
		<description>Hi,

the suggested method is not compatible with having both open and restricted methods, I solved the problem with a  tiny middleware and with the following directive in the virtual server conf:

&lt;code&gt;WSGIPassAuthorization On&lt;/code&gt;

The middleware :




&lt;pre&gt;&lt;code class=&quot;python&quot;&gt;
class HttpAuthMiddleware:
    &quot;&quot;&quot;
    Simple HTTP-Basic auth for testing webservices
    &quot;&quot;&quot;
    def process_request(self, request):
        auth_basic = request.META.get(&#039;HTTP_AUTHORIZATION&#039;)
        if auth_basic:
            import base64
            try:
                username , dummy,  password = base64.decodestring(auth_basic[6:]).partition(&#039;:&#039;)
                user = User.objects.get(username=username)
                if user.check_password(password):
                   request.user = user
            except User.DoesNotExist:
                pass
        return None
&lt;/code&gt;&lt;/pre&gt;

&lt;strong&gt;Edit:&lt;/strong&gt; Changes to formatting made by David.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>the suggested method is not compatible with having both open and restricted methods, I solved the problem with a  tiny middleware and with the following directive in the virtual server conf:</p>
<p><code>WSGIPassAuthorization On</code></p>
<p>The middleware :</p>
<pre><code class="python">
class HttpAuthMiddleware:
    """
    Simple HTTP-Basic auth for testing webservices
    """
    def process_request(self, request):
        auth_basic = request.META.get('HTTP_AUTHORIZATION')
        if auth_basic:
            import base64
            try:
                username , dummy,  password = base64.decodestring(auth_basic[6:]).partition(':')
                user = User.objects.get(username=username)
                if user.check_password(password):
                   request.user = user
            except User.DoesNotExist:
                pass
        return None
</code></pre>
<p><strong>Edit:</strong> Changes to formatting made by David.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.davidfischer.name/2009/10/django-authentication-and-mod_wsgi/comment-page-1/#comment-153</link>
		<dc:creator>David</dc:creator>
		<pubDate>Fri, 09 Apr 2010 15:00:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=270#comment-153</guid>
		<description>&lt;a href=&quot;#comment-152&quot; rel=&quot;nofollow&quot;&gt;@Vishwajeet &lt;/a&gt; 
I&#039;m not 100% sure what you mean. Instead of using mod_python&#039;s PythonAuthenHandler and pointing to a Django built-in module like &quot;PythonAuthenHandler django.contrib.auth.handlers.modpython&quot;, you have to use mod_wsgi&#039;s WSGIAuthUserScript. However, there is no Django built-in module to point to for authentication. However, since mod_wsgi is the &lt;a href=&quot;http://docs.djangoproject.com/en/1.1/howto/deployment/modwsgi/#howto-deployment-modwsgi&quot; rel=&quot;nofollow&quot;&gt;recommended&lt;/a&gt; Apache module for deploying Django in production, I submitted that &lt;a href=&quot;http://code.djangoproject.com/ticket/10809&quot; rel=&quot;nofollow&quot;&gt;ticket&lt;/a&gt; to add the &lt;span style=&quot;font-family:monospace&quot;&gt;check_password&lt;/span&gt; helper function into Django. In the mean time, you&#039;ll have to roll an .wsgi script similar to the one I have above for authentication. You can put check_password into your main application .wsgi script and simple point to it with WSGIAuthUserScript.</description>
		<content:encoded><![CDATA[<p><a href="#comment-152" rel="nofollow">@Vishwajeet </a><br />
I&#8217;m not 100% sure what you mean. Instead of using mod_python&#8217;s PythonAuthenHandler and pointing to a Django built-in module like &#8220;PythonAuthenHandler django.contrib.auth.handlers.modpython&#8221;, you have to use mod_wsgi&#8217;s WSGIAuthUserScript. However, there is no Django built-in module to point to for authentication. However, since mod_wsgi is the <a href="http://docs.djangoproject.com/en/1.1/howto/deployment/modwsgi/#howto-deployment-modwsgi" rel="nofollow">recommended</a> Apache module for deploying Django in production, I submitted that <a href="http://code.djangoproject.com/ticket/10809" rel="nofollow">ticket</a> to add the <span style="font-family:monospace">check_password</span> helper function into Django. In the mean time, you&#8217;ll have to roll an .wsgi script similar to the one I have above for authentication. You can put check_password into your main application .wsgi script and simple point to it with WSGIAuthUserScript.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishwajeet</title>
		<link>http://www.davidfischer.name/2009/10/django-authentication-and-mod_wsgi/comment-page-1/#comment-152</link>
		<dc:creator>Vishwajeet</dc:creator>
		<pubDate>Fri, 09 Apr 2010 08:19:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=270#comment-152</guid>
		<description>Hi,
Is there way to define an authorization script for mod_wsgi like mod_python Authorization handler ?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Is there way to define an authorization script for mod_wsgi like mod_python Authorization handler ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.davidfischer.name/2009/10/django-authentication-and-mod_wsgi/comment-page-1/#comment-96</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Fri, 30 Oct 2009 11:19:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=270#comment-96</guid>
		<description>Thank you very much for posting this work around. I am using auth.wsgi, as above, to authenticate against Django to provide WebDAV access. I was previously using mod_python just to handle the WebDAV authentication but am much happier using mod_wsgi for everything. Here is the Apache config snippet.

        # mod_wsgi authenticator
        
            dav on
            AuthType Basic
            AuthName &quot;example.org&quot;
            Require valid-user
            AuthBasicProvider wsgi
            WSGIAuthUserScript  /var/local/django/webapp/apache/auth.wsgi
        </description>
		<content:encoded><![CDATA[<p>Thank you very much for posting this work around. I am using auth.wsgi, as above, to authenticate against Django to provide WebDAV access. I was previously using mod_python just to handle the WebDAV authentication but am much happier using mod_wsgi for everything. Here is the Apache config snippet.</p>
<p>        # mod_wsgi authenticator</p>
<p>            dav on<br />
            AuthType Basic<br />
            AuthName &#8220;example.org&#8221;<br />
            Require valid-user<br />
            AuthBasicProvider wsgi<br />
            WSGIAuthUserScript  /var/local/django/webapp/apache/auth.wsgi</p>
]]></content:encoded>
	</item>
</channel>
</rss>
