Class: Kankri::PasswordCheck
- Inherits:
-
Object
- Object
- Kankri::PasswordCheck
- Defined in:
- lib/kankri/password_check.rb
Overview
A method object that represents a check on username/password pairs
This is a basic check based on string comparison, failing if either username or password are empty or nil. If used with a hashing authenticator, the hashing must be done before the password checking. Similarly, PasswordCheck does not convert to or from symbols; the authenticator must do this itself.
Class Method Summary collapse
-
.check(*args) ⇒ Boolean
Creates and runs a password check.
Instance Method Summary collapse
-
#initialize(username, password, passwords) ⇒ PasswordCheck
constructor
Creates a password check instance.
-
#ok? ⇒ Boolean
Checks to see if the authentication credentials are correct.
Constructor Details
#initialize(username, password, passwords) ⇒ PasswordCheck
Creates a password check instance
Passwords may be literal passwords, hashes or any other secret that can be compared by ==. Any hashing or other processing (such as type conversion) must be done by the Authenticator.
25 26 27 28 29 |
# File 'lib/kankri/password_check.rb', line 25 def initialize(username, password, passwords) @username = username @password = password @passwords = passwords end |
Class Method Details
.check(*args) ⇒ Boolean
Creates and runs a password check
59 60 61 |
# File 'lib/kankri/password_check.rb', line 59 def self.check(*args) PasswordCheck.new(*args).ok? end |
Instance Method Details
#ok? ⇒ Boolean
Checks to see if the authentication credentials are correct
42 43 44 |
# File 'lib/kankri/password_check.rb', line 42 def ok? auth_present? && user_known? && password_match? end |