devise_security_extension

an security extension for devise

Features

  • expire passwords (update password with current password)

  • strong password validation

  • save old passwords for check new passwords

  • captcha support for sign_up, sign_in, recover and unlock

Installation

add to Gemfile

gem 'devise_security_extension'

after bundle execute

rails g devise_security_extension:install

for :secure_validatable you need to add

gem 'rails_email_validator'

Configuration

Devise.setup do |config|
  # Should the password expire (e.g 3.months)
  # config.expire_password_after = 3.months

  # Need 1 char of A-Z, a-z and 0-9
  # config.password_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/

  # How often save old passwords in archive
  # config.password_archiving_count = 5

  # Deny old password (true, false, count)
  # config.deny_old_passwords = true

  # captcha integration for recover form 
  # config.captcha_for_recover = true

  # captcha integration for sign up form
  # config.captcha_for_sign_up = true

  # captcha integration for sign in form
  # config.captcha_for_sign_in = true

  # captcha integration for unlock form
  # config.captcha_for_unlock = true
end

Captcha-Support

Installation

  1. add to Gemfile “gem ‘easy_captcha’”

  2. install easy_captcha “rails g easy_captcha:install”

  3. enable captcha - see “Configuration”

  4. add captcha source in views of devise for each controller you have activate

<p><%= captcha_tag %></p>
<p><%= text_field_tag :captcha %></p>

That’s all!

Model modules

  • :password_expirable - activate that passwords will expire

  • :secure_validatable - better way to validate model. don’t use with :validatable!!!

  • :password_archivable - save password in old_passwords for history checks

Schema

Password expirable

create_table :the_resources do |t|
  t.password_expirable
end

Password archive

create_table :old_passwords do |t|
  t.password_archivable
end
add_index :old_passwords, [:password_archivable_type, :password_archivable_id], :name => :index_password_archivable

Requirements

Todo

  • disable inactive users after time

History

  • 0.1 expire passwords

  • 0.2 strong password validation

  • 0.3 password archivable with validation

  • 0.4 captcha support for sign_up, sign_in, recover and unlock

Maintainers

Contributing to devise_security_extension

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Marco Scholl. See LICENSE.txt for further details.