Pieter,
Personally, I think the best way to handle this situation is to break out the authentication component into a sparklepack gem which can then be versioned. Bundler supports having a Gemfile in subdirectories so, assuming you have dev, test and prod in separate directories, you could very easily roll out a version of the authentication component to whichever directory you wanted to. You could structure the directories however you want.
The other advantage of using gem versioning is that you wouldn't have to actually change any code in the templates, all you'd need to do is change the version in the Gemfile and update the stack. Much less room for error and much much less tedious than using a dynamic.
Cheers,
Scott