Class: Git::Lighttp::Htpasswd
Overview
:nodoc:
Instance Method Summary collapse
- #authenticated?(username, password) ⇒ Boolean
- #create(username, password) ⇒ Object (also: #update)
- #destroy(username) ⇒ Object
-
#find(username) ⇒ Object
:yield: password, salt.
- #include?(username) ⇒ Boolean
-
#initialize(file) {|_self| ... } ⇒ Htpasswd
constructor
A new instance of Htpasswd.
- #size ⇒ Object
- #write! ⇒ Object
Constructor Details
#initialize(file) {|_self| ... } ⇒ Htpasswd
Returns a new instance of Htpasswd.
173 174 175 176 177 |
# File 'lib/git/lighttp.rb', line 173 def initialize(file) require "webrick/httpauth/htpasswd" @handler = WEBrick::HTTPAuth::Htpasswd.new(file) yield self if block_given? end |
Instance Method Details
#authenticated?(username, password) ⇒ Boolean
188 189 190 191 192 |
# File 'lib/git/lighttp.rb', line 188 def authenticated?(username, password) self.find username do |crypted, salt| crypted && salt && crypted == password.crypt(salt) end end |
#create(username, password) ⇒ Object Also known as: update
194 195 196 |
# File 'lib/git/lighttp.rb', line 194 def create(username, password) @handler.set_passwd(nil, username, password) end |
#destroy(username) ⇒ Object
199 200 201 |
# File 'lib/git/lighttp.rb', line 199 def destroy(username) @handler.delete_passwd(nil, username) end |
#find(username) ⇒ Object
:yield: password, salt
179 180 181 182 183 184 185 186 |
# File 'lib/git/lighttp.rb', line 179 def find(username) #:yield: password, salt password = @handler.get_passwd(nil, username, false) if block_given? yield password ? [password, password[0,2]] : [nil, nil] else password end end |
#include?(username) ⇒ Boolean
203 204 205 |
# File 'lib/git/lighttp.rb', line 203 def include?(username) users.include? username end |
#size ⇒ Object
207 208 209 |
# File 'lib/git/lighttp.rb', line 207 def size users.size end |
#write! ⇒ Object
211 212 213 |
# File 'lib/git/lighttp.rb', line 211 def write! @handler.flush end |