Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
devise_security_extension
Advanced tools
An enterprise security extension for Devise, trying to meet industrial standard security demands for web applications.
It is composed of 7 additional Devise modules:
:password_expirable
- passwords will expire after a configured time (and will need an update):secure_validatable
- better way to validate a model (email, stronger password validation). Don't use with Devise :validatable
module!:password_archivable
- save used passwords in an old_passwords
table for history checks (don't be able to use a formerly used password):session_limitable
- ensures, that there is only one session usable per account at once:expirable
- expires a user account after x days of inactivity (default 90 days):security_questionable
- as accessible substitution for captchas (security question with captcha fallback):paranoid_verification
- admin can generate verification code that user needs to fill in otherwise he wont be able to use the application.Configuration and database schema for each module below.
sign_up
, sign_in
, recover
and unlock
(to make automated mass creation and brute forcing of accounts harder)Devise Security Extension works with Devise on Rails 3.2 onwards. You can add it to your Gemfile after you successfully set up Devise (see Devise documentation) with:
gem 'devise_security_extension'
Run the bundle command to install it.
After you installed Devise Security Extension you need to run the generator:
rails generate devise_security_extension:install
The generator adds optional configurations to config/initializers/devise.rb
. Enable
the modules you wish to use in the initializer you are ready to add Devise Security Extension modules on top of Devise modules to any of your Devise models:
devise :password_expirable, :secure_validatable, :password_archivable, :session_limitable, :expirable
for :secure_validatable
you need to add
gem 'rails_email_validator'
Devise.setup do |config|
# ==> Security Extension
# Configure security extension for devise
# 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])/
# Number of 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
# security_question integration for recover form
# this automatically enables captchas (captcha_for_recover, as fallback)
# config.security_question_for_recover = false
# security_question integration for unlock form
# this automatically enables captchas (captcha_for_unlock, as fallback)
# config.security_question_for_unlock = false
# security_question integration for confirmation form
# this automatically enables captchas (captcha_for_confirmation, as fallback)
# config.security_question_for_confirmation = false
# ==> Configuration for :expirable
# Time period for account expiry from last_activity_at
# config.expire_after = 90.days
end
The captcha support depends on EasyCaptcha. See further documention there.
Gemfile
withgem 'easy_captcha'
rails generate easy_captcha:install
<p><%= captcha_tag %></p>
<p><%= text_field_tag :captcha %></p>
create_table :the_resources do |t|
# other devise fields
t.datetime :password_changed_at
end
add_index :the_resources, :password_changed_at
create_table :old_passwords do |t|
t.string :encrypted_password, :null => false
t.string :password_archivable_type, :null => false
t.integer :password_archivable_id, :null => false
t.datetime :created_at
end
add_index :old_passwords, [:password_archivable_type, :password_archivable_id], :name => :index_password_archivable
create_table :the_resources do |t|
# other devise fields
t.string :unique_session_id, :limit => 20
end
create_table :the_resources do |t|
# other devise fields
t.datetime :last_activity_at
t.datetime :expired_at
end
add_index :the_resources, :last_activity_at
add_index :the_resources, :expired_at
create_table :the_resources do |t|
# other devise fields
t.string :paranoid_verification_code
t.integer :paranoid_verification_attempt, default: 0
t.datetime :paranoid_verified_at
end
add_index :the_resources, :paranoid_verification_code
add_index :the_resources, :paranoid_verified_at
Documentation for Paranoid Verifiable module
# app/models/security_question.rb
class SecurityQuestion < ActiveRecord::Base
validates :locale, presence: true
validates :name, presence: true, uniqueness: true
end
create_table :security_questions do |t|
t.string :locale, :null => false
t.string :name, :null => false
end
SecurityQuestion.create! locale: :de, name: 'Wie lautet der Geburstname Ihrer Mutter?'
SecurityQuestion.create! locale: :de, name: 'Wo sind sie geboren?'
SecurityQuestion.create! locale: :de, name: 'Wie lautet der Name Ihres ersten Haustieres?'
SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblingsfilm?'
SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblingsbuch?'
SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblingstier?'
SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblings-Reiseland?'
add_column :the_resources, :security_question_id, :integer
add_column :the_resources, :security_question_answer, :string
or
create_table :the_resources do |t|
# other devise fields
t.integer :security_question_id
t.string :security_question_answer
end
autocomplete-off
(http://github.com/phatworx/autocomplete-off)easy_captcha
(http://github.com/phatworx/easy_captcha)rails_email_validator
(http://github.com/phatworx/rails_email_validator)Copyright (c) 2011-2015 Marco Scholl. See LICENSE.txt for further details.
FAQs
Unknown package
We found that devise_security_extension demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.