18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/htpasswd/class_methods.rb', line 18
def htpasswd(options={})
options = options.dup
options[:user] ||= options[:username]
options[:pass] ||= options[:password]
options[:acl] ||= options[:type]
if options[:exclusive]
write_inheritable_array(:htpasswd_acls, [])
write_inheritable_hash(:htpasswd_options, {})
end
(htpasswd_options[:schemes] ||= Set.new) << (options[:scheme] || :basic)
options[:acl] ||= (options[:class] && :active_record)
options[:acl] ||= (options[:file] && :htpasswd)
options[:acl] ||= (options[:user] && options[:pass] && :plain)
htpasswd_acls << Acls::Base[options[:acl]].new(options) if options[:acl]
htpasswd_options.merge!(:realm=>options[:realm]) if options[:realm]
skip_before_filter :htpasswd_authorize rescue nil
delegate :htpasswd_options, :htpasswd_acls, :to=>"self.class" unless instance_methods.include?("htpasswd_options")
before_filter :htpasswd_authorize
end
|