Class: Veri::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/veri/configuration.rb

Constant Summary collapse

HASHERS =
{
  argon2: Veri::Password::Argon2,
  bcrypt: Veri::Password::BCrypt,
  pbkdf2: Veri::Password::Pbkdf2,
  scrypt: Veri::Password::SCrypt
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
# File 'lib/veri/configuration.rb', line 10

def initialize
  reset_to_defaults!
end

Instance Attribute Details

#hashing_algorithmObject

Returns the value of attribute hashing_algorithm.



8
9
10
# File 'lib/veri/configuration.rb', line 8

def hashing_algorithm
  @hashing_algorithm
end

#inactive_session_lifetimeObject

Returns the value of attribute inactive_session_lifetime.



8
9
10
# File 'lib/veri/configuration.rb', line 8

def inactive_session_lifetime
  @inactive_session_lifetime
end

#total_session_lifetimeObject

Returns the value of attribute total_session_lifetime.



8
9
10
# File 'lib/veri/configuration.rb', line 8

def total_session_lifetime
  @total_session_lifetime
end

#user_model_nameObject

Returns the value of attribute user_model_name.



8
9
10
# File 'lib/veri/configuration.rb', line 8

def user_model_name
  @user_model_name
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



73
74
75
# File 'lib/veri/configuration.rb', line 73

def configure
  yield self
end

#hasherObject



61
62
63
# File 'lib/veri/configuration.rb', line 61

def hasher
  HASHERS.fetch(hashing_algorithm)
end

#reset_to_defaults!Object



54
55
56
57
58
59
# File 'lib/veri/configuration.rb', line 54

def reset_to_defaults!
  self.hashing_algorithm = :argon2
  self.inactive_session_lifetime = nil
  self.total_session_lifetime = 14.days
  self.user_model_name = "User"
end

#user_modelObject



65
66
67
68
69
70
71
# File 'lib/veri/configuration.rb', line 65

def user_model
  Veri::Inputs::Model.new(
    user_model_name,
    error: Veri::ConfigurationError,
    message: "Invalid user model name `#{user_model_name}`, model does not exist"
  ).process
end