Class: Sorcery::Model::Config
- Inherits:
-
Object
- Object
- Sorcery::Model::Config
- Defined in:
- lib/sorcery/model/config.rb
Instance Attribute Summary collapse
-
#after_config ⇒ Object
an array of method names to call after configuration by user.
-
#before_authenticate ⇒ Object
an array of method names to call before authentication completes.
-
#crypted_password_attribute_name ⇒ Object
change default crypted_password attribute.
-
#custom_encryption_provider ⇒ Object
use an external encryption class.
-
#downcase_username_before_authenticating ⇒ Object
downcase the username before trying to authenticate, default is false.
-
#email_attribute_name ⇒ Object
change default email attribute.
-
#email_delivery_method ⇒ Object
method to send email related options: ‘:deliver_later`, `:deliver_now`, `:deliver` Default: :deliver (Rails version < 4.2) or :deliver_now (Rails version 4.2+) method to send email related.
-
#encryption_algorithm ⇒ Object
encryption algorithm name.
-
#encryption_key ⇒ Object
encryption key used to encrypt reversible encryptions such as AES256.
-
#encryption_provider ⇒ Object
readonly
change default encryption_provider.
-
#password_attribute_name ⇒ Object
change virtual password attribute, the one which is used until an encrypted one is generated.
-
#pepper ⇒ Object
application-specific secret token that is joined with the password and its salt.
-
#salt_attribute_name ⇒ Object
change default salt attribute.
-
#salt_join_token ⇒ Object
what pattern to use to join the password with the salt APPLICABLE TO MD5, SHA1, SHA256, SHA512.
-
#stretches ⇒ Object
how many times to apply encryption to the password.
-
#subclasses_inherit_config ⇒ Object
make this configuration inheritable for subclasses.
-
#submodules ⇒ Object
configured in config/application.rb.
-
#token_randomness ⇒ Object
Set token randomness.
-
#username_attribute_names ⇒ Object
change default username attribute, for example, to use :email as the login.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#reset! ⇒ Object
Resets all configuration options to their default values.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/sorcery/model/config.rb', line 52 def initialize @defaults = { :@submodules => [], :@username_attribute_names => [:email], :@password_attribute_name => :password, :@downcase_username_before_authenticating => false, :@email_attribute_name => :email, :@crypted_password_attribute_name => :crypted_password, :@encryption_algorithm => :bcrypt, :@encryption_provider => CryptoProviders::BCrypt, :@custom_encryption_provider => nil, :@encryption_key => nil, :@pepper => '', :@salt_join_token => '', :@salt_attribute_name => :salt, :@stretches => nil, :@subclasses_inherit_config => false, :@before_authenticate => [], :@after_config => [], :@email_delivery_method => default_email_delivery_method, :@token_randomness => 15 } reset! end |
Instance Attribute Details
#after_config ⇒ Object
an array of method names to call after configuration by user. used internally.
39 40 41 |
# File 'lib/sorcery/model/config.rb', line 39 def after_config @after_config end |
#before_authenticate ⇒ Object
an array of method names to call before authentication completes. used internally.
32 33 34 |
# File 'lib/sorcery/model/config.rb', line 32 def before_authenticate @before_authenticate end |
#crypted_password_attribute_name ⇒ Object
change default crypted_password attribute.
14 15 16 |
# File 'lib/sorcery/model/config.rb', line 14 def crypted_password_attribute_name @crypted_password_attribute_name end |
#custom_encryption_provider ⇒ Object
use an external encryption class.
48 49 50 |
# File 'lib/sorcery/model/config.rb', line 48 def custom_encryption_provider @custom_encryption_provider end |
#downcase_username_before_authenticating ⇒ Object
downcase the username before trying to authenticate, default is false
12 13 14 |
# File 'lib/sorcery/model/config.rb', line 12 def downcase_username_before_authenticating @downcase_username_before_authenticating end |
#email_attribute_name ⇒ Object
change default email attribute.
10 11 12 |
# File 'lib/sorcery/model/config.rb', line 10 def email_attribute_name @email_attribute_name end |
#email_delivery_method ⇒ Object
method to send email related options: ‘:deliver_later`, `:deliver_now`, `:deliver` Default: :deliver (Rails version < 4.2) or :deliver_now (Rails version 4.2+) method to send email related
37 38 39 |
# File 'lib/sorcery/model/config.rb', line 37 def email_delivery_method @email_delivery_method end |
#encryption_algorithm ⇒ Object
encryption algorithm name. See ‘encryption_algorithm=’ below for available options.
50 51 52 |
# File 'lib/sorcery/model/config.rb', line 50 def encryption_algorithm @encryption_algorithm end |
#encryption_key ⇒ Object
encryption key used to encrypt reversible encryptions such as AES256.
26 27 28 |
# File 'lib/sorcery/model/config.rb', line 26 def encryption_key @encryption_key end |
#encryption_provider ⇒ Object (readonly)
change default encryption_provider.
46 47 48 |
# File 'lib/sorcery/model/config.rb', line 46 def encryption_provider @encryption_provider end |
#password_attribute_name ⇒ Object
change virtual password attribute, the one which is used until an encrypted one is generated.
8 9 10 |
# File 'lib/sorcery/model/config.rb', line 8 def password_attribute_name @password_attribute_name end |
#pepper ⇒ Object
application-specific secret token that is joined with the password and its salt. Currently available with BCrypt (default crypt provider) only.
17 18 19 |
# File 'lib/sorcery/model/config.rb', line 17 def pepper @pepper end |
#salt_attribute_name ⇒ Object
change default salt attribute.
22 23 24 |
# File 'lib/sorcery/model/config.rb', line 22 def salt_attribute_name @salt_attribute_name end |
#salt_join_token ⇒ Object
what pattern to use to join the password with the salt APPLICABLE TO MD5, SHA1, SHA256, SHA512. Other crypt providers (incl. BCrypt) ignore this parameter.
20 21 22 |
# File 'lib/sorcery/model/config.rb', line 20 def salt_join_token @salt_join_token end |
#stretches ⇒ Object
how many times to apply encryption to the password.
24 25 26 |
# File 'lib/sorcery/model/config.rb', line 24 def stretches @stretches end |
#subclasses_inherit_config ⇒ Object
make this configuration inheritable for subclasses. Useful for ActiveRecord’s STI.
28 29 30 |
# File 'lib/sorcery/model/config.rb', line 28 def subclasses_inherit_config @subclasses_inherit_config end |
#submodules ⇒ Object
configured in config/application.rb
30 31 32 |
# File 'lib/sorcery/model/config.rb', line 30 def submodules @submodules end |
#token_randomness ⇒ Object
Set token randomness
41 42 43 |
# File 'lib/sorcery/model/config.rb', line 41 def token_randomness @token_randomness end |
#username_attribute_names ⇒ Object
change default username attribute, for example, to use :email as the login. See ‘username_attribute_names=’ below.
44 45 46 |
# File 'lib/sorcery/model/config.rb', line 44 def username_attribute_names @username_attribute_names end |
Instance Method Details
#reset! ⇒ Object
Resets all configuration options to their default values.
78 79 80 81 82 |
# File 'lib/sorcery/model/config.rb', line 78 def reset! @defaults.each do |k, v| instance_variable_set(k, v) end end |