<?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>Richard K Miller &#187; Ruby on Rails</title>
	<atom:link href="http://richardkmiller.com/category/ruby-on-rails/feed" rel="self" type="application/rss+xml" />
	<link>http://richardkmiller.com</link>
	<description></description>
	<lastBuildDate>Sun, 11 Mar 2012 00:27:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Password Protect Redmine with Apache, mod_perl, and Redmine.pm</title>
		<link>http://richardkmiller.com/932/how-to-password-protect-redmine-with-apache-mod_perl-redmine-pm</link>
		<comments>http://richardkmiller.com/932/how-to-password-protect-redmine-with-apache-mod_perl-redmine-pm#comments</comments>
		<pubDate>Sun, 13 Nov 2011 01:16:01 +0000</pubDate>
		<dc:creator>Richard K Miller</dc:creator>
				<category><![CDATA[Main]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://richardkmiller.com/?p=932</guid>
		<description><![CDATA[Today I needed to password-protect a Redmine installation. I&#8217;ve typically used mod_auth_mysql for similar projects, but Redmine uses a salted password format that&#8217;s incompatible with mod_auth_mysql. So, I turned to Apache/Perl authentication, a first for me (I rarely touch Perl) &#8230; <a href="http://richardkmiller.com/932/how-to-password-protect-redmine-with-apache-mod_perl-redmine-pm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='microid-36009b2faccc89c3eb8fe905eb5d37cd1cffcf97'><p>Today I needed to password-protect a <a href="http://www.redmine.org/">Redmine</a> installation. I&#8217;ve typically used mod_auth_mysql for similar projects, but Redmine uses a salted password format that&#8217;s incompatible with mod_auth_mysql. So, I turned to Apache/Perl authentication, a first for me (I rarely touch Perl) and was able to make it work.</p>
<ol>
<li>Install mod_perl, and the DBI, MySQL, and Digest (SHA1) Perl modules.
<pre class="brush: bash; title: ;">
$ apt-get install libapache-dbi-perl libapache2-mod-perl2 libdbd-mysql-perl libdigest-sha1-perl
</pre>
</li>
<li>Copy Redmine.pm to the appropriate Perl location.
<pre class="brush: bash; title: ;">
$ cd /path/to/redmine
$ mkdir -p /usr/lib/perl5/Apache/Authn
$ cp extra/svn/Redmine.pm /usr/lib/perl5/Apache/Authn/
</pre>
</li>
<li>Perhaps I&#8217;m not using Redmine&#8217;s projects/members/permissions correctly, but I had to patch Redmine.pm to get it to work for me. I greatly simplified the SQL statement used to authenticate a user. There&#8217;s no sense of permissions; it&#8217;s simply a yes/no for authenticated users.
<pre class="brush: diff; title: ;">
--- Redmine.pm	2011-11-12 17:33:10.000000000 -0700
+++ Redmine.richardkmiller.pm	2011-11-12 17:37:26.000000000 -0700
@@ -148,16 +148,11 @@
   my ($self, $parms, $arg) = @_;
   $self-&gt;{RedmineDSN} = $arg;
   my $query = &quot;SELECT
-                 hashed_password, salt, auth_source_id, permissions
-              FROM members, projects, users, roles, member_roles
+                 hashed_password, salt
+              FROM users
               WHERE
-                projects.id=members.project_id
-                AND member_roles.member_id=members.id
-                AND users.id=members.user_id
-                AND roles.id=member_roles.role_id
-                AND users.status=1
-                AND login=?
-                AND identifier=? &quot;;
+                    users.status=1
+                AND login=?&quot;;
   $self-&gt;{RedmineQuery} = trim($query);
 }

@@ -336,11 +331,12 @@
   }
   my $query = $cfg-&gt;{RedmineQuery};
   my $sth = $dbh-&gt;prepare($query);
-  $sth-&gt;execute($redmine_user, $project_id);
+  $sth-&gt;execute($redmine_user);

   my $ret;
-  while (my ($hashed_password, $salt, $auth_source_id, $permissions) = $sth-&gt;fetchrow_array) {
-
+  while (my ($hashed_password, $salt) = $sth-&gt;fetchrow_array) {
+      my $permissions = &quot;:commit_access&quot;;
+      my $auth_source_id = 0;
       unless ($auth_source_id) {
 	  			my $method = $r-&gt;method;
           my $salted_password = Digest::SHA1::sha1_hex($salt.$pass_digest);
</pre>
</li>
<li>Configure and restart Apache.
<pre class="brush: perl; title: ;">
&lt;virtualhost *:80&gt;
    ServerName example.com
    DocumentRoot &quot;/var/www/sites/example.com/public&quot;
    RailsEnv production

    PerlLoadModule Apache::Authn::Redmine

    &lt;directory &quot;/var/www/sites/example.com/public&quot;&gt;
        AuthType basic
        AuthName &quot;Private Area&quot;
        Require valid-user
        PerlAccessHandler Apache::Authn::Redmine::access_handler
        PerlAuthenHandler Apache::Authn::Redmine::authen_handler
        RedmineDSN &quot;DBI:mysql:database=my_database;host=localhost&quot;
        RedmineDbUser my_db_user
        RedmineDbPass my_db_password
    &lt;/directory&gt;
&lt;/virtualhost&gt;
</pre>
</li>
</ol>
<p>By the way, I&#8217;m running Ubuntu 11.10 (oneiric), Apache 2.2, MySQL 5.1, and Redmine 1.2.2.</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://richardkmiller.com/932/how-to-password-protect-redmine-with-apache-mod_perl-redmine-pm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amtrak series: Ruby on Rails on Rails</title>
		<link>http://richardkmiller.com/273/amtrak-series-ruby-on-rails-on-rails</link>
		<comments>http://richardkmiller.com/273/amtrak-series-ruby-on-rails-on-rails#comments</comments>
		<pubDate>Thu, 07 Jun 2007 17:00:50 +0000</pubDate>
		<dc:creator>Richard K Miller</dc:creator>
				<category><![CDATA[Amtrak]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Entrepreneurship]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.richardkmiller.com/blog/archives/2007/06/amtrak-series-ruby-on-rails-on-rails</guid>
		<description><![CDATA[This will be the most technical of my posts in the Amtrak series, but it&#8217;s not just for computer geeks so stay with me. Here we go. Ruby on Rails is a &#8220;web application framework&#8221;, a way for programmers to &#8230; <a href="http://richardkmiller.com/273/amtrak-series-ruby-on-rails-on-rails">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='microid-25ab5b4d4da0e906b96ef5184bc029a41a0bb498'><p>This will be the most technical of my posts in the Amtrak series, but it&#8217;s not just for computer geeks so stay with me. Here we go.</p>
<p><a href="http://www.rubyonrails.org/">Ruby on Rails</a> is a &#8220;web application framework&#8221;, a way for programmers to make web applications more easily and more quickly (and more enjoyably, as its creators would be quick to point out.) It was created by <a href="http://37signals.com/">37signals</a>, the makers of Basecamp and other fine web apps, and has been one of the fastest growing programming environments of the last couple years. &#8220;Ruby&#8221; is the programming language and &#8220;Rails&#8221; is the set of additions that make it &#8220;fast&#8221; and &#8220;easy,&#8221; like a high-speed train. (Not a <a href="http://www.richardkmiller.com/blog/archives/2007/06/amtrak-series-pictures">sight-seeing Amtrak</a>.)</p>
<p><a href='http://www.richardkmiller.com/blog/wp-content/uploads/2007/06/img_0088.jpg' title='img_0088.jpg' rel='lightbox'><img src='http://www.richardkmiller.com/blog/wp-content/uploads/2007/06/img_0088.thumbnail.jpg' alt='img_0088.jpg' style='float:right; margin:1em;' /></a></p>
<p>You probably see where this is going. As an exercise in literalness, I though it would be interesting to do a little Ruby on Rails programming while on the train, or in other words, Ruby on Rails on Rails. (Mitch Hedberg said &#8220;I&#8217;d like to see a forklift lift a crate of forks. It&#8217;d be so&#8230;literal. &#8216;Hey, you&#8217;re using that machine for its exact purpose!&#8217;&#8221;) See the pictures.</p>
<p>I have not delved into Rails as much as my local colleagues, but with the little I&#8217;ve used it, I&#8217;ve been impressed. By taking away the tedious parts of programming, it really does make programming more enjoyable. I know <a href="http://www.johntaber.com/">several</a> <a href="http://www.griffio.com/">good</a> <a href="http://www.apriux.com/">developers</a> who prefer it.</p>
<p>Ruby on Rails enforces an architecture called &#8220;Model-View-Controller&#8221; (MVC), which is used heavily in Mac applications and well written web applications. Though not built on Rails, <a href="http://wordpress.org/">WordPress</a> also uses an MVC architecture. If you have a WordPress blog, you know you can easily change the theme of your blog. This is thanks to the modular MVC architecture with which it was written.</p>
<p><a href='http://www.richardkmiller.com/blog/wp-content/uploads/2007/06/img_0096.jpg' title='img_0096.jpg' rel='lightbox'><img src='http://www.richardkmiller.com/blog/wp-content/uploads/2007/06/img_0096.thumbnail.jpg' alt='img_0096.jpg' style='float:right; margin:1em;' /></a></p>
<p>Here&#8217;s where this applies to everyone: 37signals hasn&#8217;t only extracted Rails from their best programming practices, they&#8217;ve also extracted a book from their best business practices. I highly recommend <a href="http://gettingreal.37signals.com/">Getting Real</a> by 37signals, availably entirely for free on their <a href="http://gettingreal.37signals.com/toc.php">website</a>. They&#8217;ve <a href="http://www.37signals.com/svn/posts/451-whats-your-cookbook">given away their &#8220;cookbook&#8221;</a> &#8212; what they&#8217;ve learned about marketing, project management, time management, hiring, agility, task prioritization, and more. I finished the book believing that small teams can do great things.</p>
<p style='clear:both;'>
</div>]]></content:encoded>
			<wfw:commentRss>http://richardkmiller.com/273/amtrak-series-ruby-on-rails-on-rails/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

