Module: Passwd::Base
- Included in:
- Passwd
- Defined in:
- lib/passwd/base.rb
Instance Method Summary collapse
- #auth(password_text, salt_hash, password_hash) ⇒ Object
- #configure(options = {}, &block) ⇒ Object (also: #config)
- #create(options = {}) ⇒ Object
- #hashing(plain) ⇒ Object
- #policy_check(password) ⇒ Object
- #policy_configure(&block) ⇒ Object
- #reset_config ⇒ Object
- #reset_policy ⇒ Object
Instance Method Details
#auth(password_text, salt_hash, password_hash) ⇒ Object
22 23 24 25 |
# File 'lib/passwd/base.rb', line 22 def auth(password_text, salt_hash, password_hash) enc_pass = Passwd.hashing("#{salt_hash}#{password_text}") password_hash == enc_pass end |
#configure(options = {}, &block) ⇒ Object Also known as: config
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/passwd/base.rb', line 31 def configure(={}, &block) if block_given? @config.configure &block else if .empty? @config else @config.merge end end end |
#create(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/passwd/base.rb', line 13 def create(={}) if .empty? config = @config else config = TmpConfig.new(@config, ) end Array.new(config.length){config.letters[rand(config.letters.size)]}.join end |
#hashing(plain) ⇒ Object
27 28 29 |
# File 'lib/passwd/base.rb', line 27 def hashing(plain) Digest::SHA1.hexdigest plain end |
#policy_check(password) ⇒ Object
52 53 54 |
# File 'lib/passwd/base.rb', line 52 def policy_check(password) @policy.valid?(password, @config) end |
#policy_configure(&block) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/passwd/base.rb', line 44 def policy_configure(&block) if block_given? @policy.configure &block else @policy end end |
#reset_config ⇒ Object
56 57 58 |
# File 'lib/passwd/base.rb', line 56 def reset_config @config.reset end |
#reset_policy ⇒ Object
60 61 62 |
# File 'lib/passwd/base.rb', line 60 def reset_policy @policy.reset end |