title: What's the most secure possible Devise configuration?
body: <p>I'm about to start setting up an employees-only Rails application at our company for working with sensitive information. There will be a firewall, physical security measures, etc. My concern right now is the login process for the application.</p>
  
  <p>I'd like to use Devise for authentication. <strong>What is the most secure possible configuration for Devise?</strong></p>
  
  <p>I'm thinking I wil do the following:</p>
  
  <ul>
  <li>Lock accounts after a small number of failed login attempts</li>
  <li>Use <code>config.paranoid</code> so an attacker can't tell if they've guessed a valid email address</li>
  <li>Maybe disable password resets by email?</li>
  </ul>
  
  <p>Some of the specific things I'm unsure of, with quotes from <code>devise.rb</code> in italics:</p>
  
  <ul>
  <li><strong>Peppers.</strong> Devise has an option to <em>"Setup a pepper to generate the encrypted password."</em> My understanding is that this is a single, app-specific value that transforms a stupid password like "password123" into something like "password123K#(!@akdlwekdf" or "*%!kd39gpassword123" or whatever before hashing. This is meant to thwart rainbow table attacks, but my understanding from <a href="http://barkingiguana.com/2009/08/03/securing-passwords-with-salt-pepper-and-rainbows/" rel="noreferrer">this article</a> is that it's not as good as a per-password unique salt. Then again, <a href="http://codahale.com/how-to-safely-store-a-password/" rel="noreferrer">this article</a> and <a href="http://www.usenix.org/events/usenix99/provos/provos_html/node6.html#SECTION00051000000000000000" rel="noreferrer">this paper</a> say that bcrypt has salts built in. Does using a pepper with bcrypt really add anything? Can I, and is there any need to, also have a salt column?</li>
  <li><strong>Stretches</strong>. <em>"For bcrypt, this is the cost for hashing the password and defaults to 10."</em>  Based on <a href="https://stackoverflow.com/questions/4443476/optimal-bcrypt-work-factor">this question</a>, I'm thinking of using a work factor of 12. Does that seem reasonable?</li>
  <li><strong>Password length</strong>. A longer password seems more secure in general, but I don't want it to be so hard that the user writes it on a piece of paper somewhere. Does password length matter much if we're using bcrypt?</li>
  <li><strong>SSL cookies</strong>. For public apps with SSL enabled, marking cookies as "this can only be transmitted over HTTPS" protects against <a href="http://codebutler.com/firesheep" rel="noreferrer">Firesheep</a>-style attacks. But I'm not sure how much sense it makes to have a security certificate for an internal app. Is that silly?</li>
  </ul>
  
  <p>What else am I missing?</p>