class Capsium::Reactor::Htpasswd
Apache htpasswd verification (05x-authentication). Supported hash formats:
-
bcrypt ($2a$/$2b$/$2y$, ‘htpasswd -B`) via the bcrypt gem
-
Apache apr1 MD5 ($apr1$, ‘htpasswd -m`) and md5-crypt ($1$), pure-Ruby md5-crypt
-
unsalted SHA-1 ({SHA}, ‘htpasswd -s`)
-
anything else (DES, $5$/$6$) via the platform’s crypt(3) —support depends on the OS
Attributes
path
[R]
String
Public Class Methods
(String path) → void
Source
# File lib/capsium/reactor/htpasswd.rb, line 91 def initialize(path) raise Error, "htpasswd file not found: #{path}" unless File.file?(path) @path = path @entries = parse(path) end
Public Instance Methods
() → Array[String]
Source
# File lib/capsium/reactor/htpasswd.rb, line 98 def usernames @entries.keys end
(String username, String password) → bool
Source
# File lib/capsium/reactor/htpasswd.rb, line 102 def verify?(username, password) hash = @entries[username] return false unless hash verify_hash(hash, password) end