<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Magnus Hagander's PostgreSQL blog (Entries tagged as django)</title>
    <link>http://blog.hagander.net/</link>
    <description></description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.6.2 - http://www.s9y.org/</generator>
    
    

<item>
    <title>www.postgresql.org - brand new, yet old and familiar</title>
    <link>http://blog.hagander.net/archives/202-www.postgresql.org-brand-new,-yet-old-and-familiar.html</link>
            <category>PostgreSQL</category>
    
    <comments>http://blog.hagander.net/archives/202-www.postgresql.org-brand-new,-yet-old-and-familiar.html#comments</comments>
    <wfw:comment>http://blog.hagander.net/wfwcomment.php?cid=202</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://blog.hagander.net/rss.php?version=2.0&amp;type=comments&amp;cid=202</wfw:commentRss>
    

    <author>nospam@example.com (Magnus Hagander)</author>
    <content:encoded>
    &lt;p&gt;Most of the visitors to &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.postgresql.org/&#039;]);&quot;  href=&quot;http://www.postgresql.org/&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;www.postgresql.org&lt;/a&gt; probably never noticed that a couple of weeks back, the entire site was replaced with a new one. In fact, we didn&#039;t just change the website - just days before, we made large changes to our ftp network as well (more about that in another post, from me or others). So in fact, we &lt;strong&gt;hope&lt;/strong&gt; that most people didn&#039;t notice. The changes were mainly a technical refresh, and there hasn&#039;t been much change to the contents at all yet. We did sneak in a few content changes as well, that have been requested for a while, so I&#039;m going to start with listing those:&lt;/p&gt;


&lt;ul&gt;
    &lt;li&gt;The &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.postgresql.org/docs/devel/&#039;]);&quot;  href=&quot;http://www.postgresql.org/docs/devel/&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;developer version of the documentation&lt;/a&gt; (updated serveral times per day from the tip of the HEAD branch that will eventually become the next version of PostgreSQL) now live on the main website, and will use the same stylesheets to look a lot nicer than before.&lt;/li&gt;
    &lt;li&gt;Anybody who submits content to our site (news, events, professional services, products, etc) will notice there is now a new concept of an &lt;i&gt;Organisation&lt;/i&gt;. This means that it will finally be possible to have more than one person manage the submissions from a single company or group.&lt;/li&gt;
    &lt;li&gt;Again for those that submit content, it is now possible to view which of your submissions are still in the moderation queue, and it&#039;s also possible to edit something after it&#039;s been submitted. In fact, you can edit your items even after they&#039;ve been approved. Any such editing will be &lt;i&gt;post-moderated&lt;/i&gt;, and if this is abused that organization will be banned from post-moderation - but we don&#039;t expect that to ever be necessary.&lt;/li&gt;
    &lt;li&gt;And finally, for those that submit content again, we&#039;ve switched to markdown to format your submissions, instead of a very random subset of allowed HTML tags.&lt;/li&gt;
&lt;/ul&gt;

The rest of the changes are under the hood, and it&#039;s mostly done for two reasons:
&lt;ul&gt;
    &lt;li&gt;The technology powering the site was simply very old&lt;/li&gt;
    &lt;li&gt;The frameworks used were quite obscure, which severely limited the number of people who could (or wanted to) work with them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully these two changes will make it easier to contribute to the website, so if you&#039;re potentially interested in doing that, please read on!&lt;/p&gt;

 &lt;br /&gt;&lt;a href=&quot;http://blog.hagander.net/archives/202-www.postgresql.org-brand-new,-yet-old-and-familiar.html#extended&quot;&gt;Continue reading &quot;www.postgresql.org - brand new, yet old and familiar&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 21 Dec 2011 13:33:00 +0000</pubDate>
    <guid isPermaLink="false">http://blog.hagander.net/archives/202-guid.html</guid>
    <category>django</category>
<category>intrastructure</category>
<category>pgweb</category>
<category>postgresql</category>
<category>python</category>
<category>varnish</category>

</item>
<item>
    <title>Integrating django authentication with PostgreSQL</title>
    <link>http://blog.hagander.net/archives/161-Integrating-django-authentication-with-PostgreSQL.html</link>
            <category>PostgreSQL</category>
    
    <comments>http://blog.hagander.net/archives/161-Integrating-django-authentication-with-PostgreSQL.html#comments</comments>
    <wfw:comment>http://blog.hagander.net/wfwcomment.php?cid=161</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://blog.hagander.net/rss.php?version=2.0&amp;type=comments&amp;cid=161</wfw:commentRss>
    

    <author>nospam@example.com (Magnus Hagander)</author>
    <content:encoded>
    &lt;p&gt;If you&#039;ve been to any of my &lt;i&gt;pgcrypto&lt;/i&gt; talks, you know I&#039;m a fan of exposing a login interface in the database. It&#039;s a great way to allow multiple systems to use the same authentication system, without being limited to a single framework. However, it can often be nice and easy to  be able to use the account management system in said framework, because it&#039;s already there.&lt;/p&gt;

&lt;p&gt;When I go to frameworks, &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.djangoproject.com/&#039;]);&quot;  href=&quot;http://www.djangoproject.com/&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;django&lt;/a&gt; is my current favorite, and I do like the ability to use it&#039;s integrated admin system to edit users. For this reason, I wanted to add the ability to use a database function to authenticate other systems using the django user tables. Thanks to the fact that django choose a nicely readable text format for their hashes, and that PostgreSQL has the awesome &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.postgresql.org/docs/current/static/pgcrypto.html&#039;]);&quot;  href=&quot;http://www.postgresql.org/docs/current/static/pgcrypto.html&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;pgcrypto&lt;/a&gt; library, this is pretty simple. Here&#039;s a function that will simply return true if authentication was successful, and false if not.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;div class=&quot;geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;OR&lt;/span&gt; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;REPLACE&lt;/span&gt; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FUNCTION&lt;/span&gt; django_login &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;_username text, _password text&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;RETURNS &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;BOOLEAN&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;AS&lt;/span&gt; $$&lt;br /&gt;BEGIN&lt;br /&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;IF&lt;/span&gt; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;EXISTS&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt; * &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; auth_user &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; username=_username&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; THEN&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;RETURN&lt;/span&gt; encode&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;pgcrypto.digest&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;split_part&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;password, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;$&#039;&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; || _password, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;sha1&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;hex&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;split_part&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;password, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;$&#039;&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; auth_user &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; username=_username;&lt;br /&gt;&amp;#160; &amp;#160;ELSE&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;RETURN&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;f&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160;END &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;IF&lt;/span&gt;;&lt;br /&gt;END;&lt;br /&gt;$$&lt;br /&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;LANGUAGE&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;plpgsql&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This assumes you have installed &lt;i&gt;pgcrypto&lt;/i&gt; in it&#039;s own schema, something I always recommend. If you haven&#039;t, just remove the schema specifier in the query.&lt;/p&gt;

&lt;p&gt;Finally, if you use this type of authentication, remember to &lt;strong&gt;use SSL&lt;/strong&gt;. And don&#039;t enable query logging...&lt;/p&gt;

 
    </content:encoded>

    <pubDate>Tue, 12 Jan 2010 20:50:00 +0000</pubDate>
    <guid isPermaLink="false">http://blog.hagander.net/archives/161-guid.html</guid>
    <category>django</category>
<category>pgcrypto</category>
<category>postgresql</category>
<category>security</category>

</item>

</channel>
</rss>