<?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 pgcrypto)</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>Extensions in PostgreSQL 9.1 fixes another pet-peeve</title>
    <link>http://blog.hagander.net/archives/193-Extensions-in-PostgreSQL-9.1-fixes-another-pet-peeve.html</link>
            <category>PostgreSQL</category>
    
    <comments>http://blog.hagander.net/archives/193-Extensions-in-PostgreSQL-9.1-fixes-another-pet-peeve.html#comments</comments>
    <wfw:comment>http://blog.hagander.net/wfwcomment.php?cid=193</wfw:comment>

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

    <author>nospam@example.com (Magnus Hagander)</author>
    <content:encoded>
    &lt;p&gt;One thing I&#039;ve really disliked is the fact that contrib modules had installation scripts that enforced the schema to public for the installation. In my opinion, for no useful reason at all.&lt;/p&gt;

&lt;p&gt;For example, I often install the &lt;i&gt;pgcrypto&lt;/i&gt; contrib module. And I install this in the &lt;i&gt;pgcrypto&lt;/i&gt; schema, that I then either add to the &lt;i&gt;search_path&lt;/i&gt; variable or just explicitly use in my queries, with things like &lt;i&gt;pcrypto.crypt(&#039;foobar&#039;,&#039;barfoo&#039;)&lt;/i&gt;. For versions prior to 9.1, being able to do this required me to manually edit the installed pgcrypto.sql file, to remove the &lt;i&gt;SET search_path = public;&lt;/i&gt; command.&lt;/p&gt;

&lt;p&gt;Extensions in 9.1 makes this so much nicer. To get pgcrypto into it&#039;s own schema, I now just need to do:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;postgres=# CREATE SCHEMA pgcrypto;
CREATE SCHEMA
postgres=# CREATE EXTENSION pgcrypto SCHEMA pgcrypto;
CREATE EXTENSION&lt;/code&gt;&lt;/pre&gt;

If I happen to create it in public by mistake, I can even move it after the fact!
&lt;pre&gt;&lt;code&gt;postgres=# ALTER EXTENSION pgcrypto SET SCHEMA pgcrypto;
ALTER EXTENSION&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You still need to create the schema manually - in theory we could auto-create that, but the work is still a lot easier than before. And fully supported!&lt;/p&gt;

 
    </content:encoded>

    <pubDate>Mon, 16 May 2011 07:58:00 +0000</pubDate>
    <guid isPermaLink="false">http://blog.hagander.net/archives/193-guid.html</guid>
    <category>9.1</category>
<category>extensions</category>
<category>pgcrypto</category>
<category>postgresql</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>
<item>
    <title>pgcon, 1st talk day</title>
    <link>http://blog.hagander.net/archives/144-pgcon,-1st-talk-day.html</link>
            <category>Conferences</category>
            <category>PostgreSQL</category>
    
    <comments>http://blog.hagander.net/archives/144-pgcon,-1st-talk-day.html#comments</comments>
    <wfw:comment>http://blog.hagander.net/wfwcomment.php?cid=144</wfw:comment>

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

    <author>nospam@example.com (Magnus Hagander)</author>
    <content:encoded>
    &lt;p&gt;We&#039;re now up to the third day of pgcon, the first one of the actual conference - the previous ones being dedicated to tutorials. The day started with &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.chesnok.com/daily/&#039;]);&quot;  href=&quot;http://www.chesnok.com/daily/&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;Selena&lt;/a&gt;, me and &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/pgsnake.blogspot.com/2009/05/pgcon-2009-day-1.html&#039;]);&quot;  href=&quot;http://pgsnake.blogspot.com/2009/05/pgcon-2009-day-1.html&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;Dave&lt;/a&gt; doing a semi-improvised keynote. Well, it started with Dan saying welcome and going through some details, but he doesn&#039;t count... I doubt we actually spread any knowledge with that talk, but at least we got to plug some interesting talks at the conference, and show pictures of elephants.&lt;/p&gt;

&lt;p&gt;Missed the start of the &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.asterdata.com/index.php&#039;]);&quot;  href=&quot;http://www.asterdata.com/index.php&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;Aster&lt;/a&gt; talk on Petabyte databases using standard PostgreSQL, but the parts I caught sounded very interesting. I&#039;m especially excited to hear they are planning to contribute a whole set of very interesting features back to core PostgreSQL. This makes a lot of sense since they&#039;re building their scaling on standard PostgreSQL and not a heavily modified one like some other players in the area, and it&#039;s very nice to see that they are realizing this.&lt;/p&gt;

&lt;p&gt;After this talk, it was time for my own talk on &lt;i&gt;PostgreSQL Encryption&lt;/i&gt;. I had a hard time deciding the split between pgcrypto and SSL when I made the talk, but I think it came out fairly well. Had a number of very good questions at the end, so clearly some people were interested. Perhaps even &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/momjian.us/main/blogs/pgblog.html&#039;]);&quot;  href=&quot;http://momjian.us/main/blogs/pgblog.html&quot; onclick=&quot;window.open(this.href, &#039;_blank&#039;); return false;&quot;&gt;Bruce&lt;/a&gt; managed to learn something...&lt;/p&gt;

&lt;p&gt;After this we had lunch, and I&#039;m now sitting in Greg Smiths talk about benchmarking hardware. This is some very low level stuff compared to what you usually see around database benchmarking, but since this is what sits underneath the database, it&#039;s important stuff. And very interesting.&lt;/p&gt;

&lt;p&gt;The rest of the day has a lineup of some very nice talks, I think. So there&#039;ll be no sitting around in the hallway! And in the evening there is the EnterpriseDB party, of course!&lt;/p&gt;

&lt;p&gt;Yesterday had the developer meeting, where a bunch (~20) of the most active developers that are here in Ottawa sat down together for the whole day to discuss topics around the next version of PostgreSQL, and how our development model works. Got some very important discussions started, and actually managed to get agreement on a couple of issues that have previously been going in circles. All in all, a very useful day.&lt;/p&gt;

 
    </content:encoded>

    <pubDate>Thu, 21 May 2009 17:37:39 +0000</pubDate>
    <guid isPermaLink="false">http://blog.hagander.net/archives/144-guid.html</guid>
    <category>conferences</category>
<category>encryption</category>
<category>keynote</category>
<category>pgcon</category>
<category>pgcrypto</category>
<category>postgresql</category>
<category>security</category>
<category>ssl</category>
<category>talk</category>

</item>

</channel>
</rss>