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.
-
#salt_attribute_name ⇒ Object
change default salt attribute.
-
#salt_join_token ⇒ Object
what pattern to use to join the password with the salt.
-
#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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sorcery/model/config.rb', line 48 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, :@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.
35 36 37 |
# File 'lib/sorcery/model/config.rb', line 35 def after_config @after_config end |
#before_authenticate ⇒ Object
an array of method names to call before authentication completes. used internally.
28 29 30 |
# File 'lib/sorcery/model/config.rb', line 28 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.
44 45 46 |
# File 'lib/sorcery/model/config.rb', line 44 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
33 34 35 |
# File 'lib/sorcery/model/config.rb', line 33 def email_delivery_method @email_delivery_method end |
#encryption_algorithm ⇒ Object
encryption algorithm name. See ‘encryption_algorithm=’ below for available options.
46 47 48 |
# File 'lib/sorcery/model/config.rb', line 46 def encryption_algorithm @encryption_algorithm end |
#encryption_key ⇒ Object
encryption key used to encrypt reversible encryptions such as AES256.
22 23 24 |
# File 'lib/sorcery/model/config.rb', line 22 def encryption_key @encryption_key end |
#encryption_provider ⇒ Object (readonly)
change default encryption_provider.
42 43 44 |
# File 'lib/sorcery/model/config.rb', line 42 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 |
#salt_attribute_name ⇒ Object
change default salt attribute.
18 19 20 |
# File 'lib/sorcery/model/config.rb', line 18 def salt_attribute_name @salt_attribute_name end |
#salt_join_token ⇒ Object
what pattern to use to join the password with the salt
16 17 18 |
# File 'lib/sorcery/model/config.rb', line 16 def salt_join_token @salt_join_token end |
#stretches ⇒ Object
how many times to apply encryption to the password.
20 21 22 |
# File 'lib/sorcery/model/config.rb', line 20 def stretches @stretches end |
#subclasses_inherit_config ⇒ Object
make this configuration inheritable for subclasses. Useful for ActiveRecord’s STI.
24 25 26 |
# File 'lib/sorcery/model/config.rb', line 24 def subclasses_inherit_config @subclasses_inherit_config end |
#submodules ⇒ Object
configured in config/application.rb
26 27 28 |
# File 'lib/sorcery/model/config.rb', line 26 def submodules @submodules end |
#token_randomness ⇒ Object
Set token randomness
37 38 39 |
# File 'lib/sorcery/model/config.rb', line 37 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.
40 41 42 |
# File 'lib/sorcery/model/config.rb', line 40 def username_attribute_names @username_attribute_names end |
Instance Method Details
#reset! ⇒ Object
Resets all configuration options to their default values.
73 74 75 76 77 |
# File 'lib/sorcery/model/config.rb', line 73 def reset! @defaults.each do |k, v| instance_variable_set(k, v) end end |