Module: Authlogic::ActsAsAuthentic::Password::Config

Defined in:
lib/authlogic/acts_as_authentic/password.rb

Overview

All configuration for the password aspect of acts_as_authentic.

Instance Method Summary collapse

Instance Method Details

#crypted_password_field(value = nil) ⇒ Object Also known as: crypted_password_field=

The name of the crypted_password field in the database.

  • Default: :crypted_password, :encrypted_password, :password_hash, or :pw_hash

  • Accepts: Symbol



20
21
22
# File 'lib/authlogic/acts_as_authentic/password.rb', line 20

def crypted_password_field(value = nil)
  config(:crypted_password_field, value, first_column_to_exist(:crypted_password, :encrypted_password, :password_hash, :pw_hash))
end

#crypto_provider(value = nil) ⇒ Object Also known as: crypto_provider=

The class you want to use to encrypt and verify your encrypted passwords. See the Authlogic::CryptoProviders module for more info on the available methods and how to create your own.

  • Default: CryptoProviders::Sha512

  • Accepts: Class



75
76
77
# File 'lib/authlogic/acts_as_authentic/password.rb', line 75

def crypto_provider(value = nil)
  config(:crypto_provider, value, CryptoProviders::Sha512)
end

#password_salt_field(value = nil) ⇒ Object Also known as: password_salt_field=

The name of the password_salt field in the database.

  • Default: :password_salt, :pw_salt, :salt, nil if none exist

  • Accepts: Symbol



29
30
31
# File 'lib/authlogic/acts_as_authentic/password.rb', line 29

def password_salt_field(value = nil)
  config(:password_salt_field, value, first_column_to_exist(nil, :password_salt, :pw_salt, :salt))
end

#transition_from_crypto_providers(value = nil) ⇒ Object Also known as: transition_from_crypto_providers=

Let’s say you originally encrypted your passwords with Sha1. Sha1 is starting to join the party with MD5 and you want to switch to something stronger. No problem, just specify your new and improved algorithm with the crypt_provider option and then let Authlogic know you are transitioning from Sha1 using this option. Authlogic will take care of everything, including transitioning your users to the new algorithm. The next time a user logs in, they will be granted access using the old algorithm and their password will be resaved with the new algorithm. All new users will obviously use the new algorithm as well.

Lastly, if you want to transition again, you can pass an array of crypto providers. So you can transition from as many algorithms as you want.

  • Default: nil

  • Accepts: Class or Array



91
92
93
# File 'lib/authlogic/acts_as_authentic/password.rb', line 91

def transition_from_crypto_providers(value = nil)
  config(:transition_from_crypto_providers, (!value.nil? && [value].flatten.compact) || value, [])
end

#validate_password_field(value = nil) ⇒ Object Also known as: validate_password_field=

Whether or not to validate the password field.

  • Default: true

  • Accepts: Boolean



38
39
40
# File 'lib/authlogic/acts_as_authentic/password.rb', line 38

def validate_password_field(value = nil)
  config(:validate_password_field, value, true)
end

#validates_confirmation_of_password_field_options(value = nil) ⇒ Object Also known as: validates_confirmation_of_password_field_options=

A hash of options for the validates_confirmation_of call for the password field. Allows you to change this however you want.

  • Default: => 4, :if => “#{password_salt_field_changed?”.to_sym}

  • Accepts: Hash of options accepted by validates_confirmation_of



56
57
58
# File 'lib/authlogic/acts_as_authentic/password.rb', line 56

def validates_confirmation_of_password_field_options(value = nil)
  config(:validates_confirmation_of_password_field_options, value, {:minimum => 4, :if => (password_salt_field ? "#{password_salt_field}_changed?".to_sym : nil)})
end

#validates_length_of_password_confirmation_field_options(value = nil) ⇒ Object Also known as: validates_length_of_password_confirmation_field_options=

A hash of options for the validates_length_of call for the password_confirmation field. Allows you to change this however you want.

  • Default: => 4, :if => :require_password_?

  • Accepts: Hash of options accepted by validates_length_of



65
66
67
# File 'lib/authlogic/acts_as_authentic/password.rb', line 65

def validates_length_of_password_confirmation_field_options(value = nil)
  config(:validates_length_of_password_confirmation_field_options, value, {:minimum => 4, :if => :require_password?})
end

#validates_length_of_password_field_options(value = nil) ⇒ Object Also known as: validates_length_of_password_field_options=

A hash of options for the validates_length_of call for the password field. Allows you to change this however you want.

  • Default: => 4, :if => :require_password?

  • Accepts: Hash of options accepted by validates_length_of



47
48
49
# File 'lib/authlogic/acts_as_authentic/password.rb', line 47

def validates_length_of_password_field_options(value = nil)
  config(:validates_length_of_password_field_options, value, {:minimum => 4, :if => :require_password?})
end