Class: Pasaporte::Auth::YamlTable

Inherits:
Object
  • Object
show all
Defined in:
lib/pasaporte/auth/yaml_table.rb

Overview

Authenticate agains a simple YAML table of logins-passwords per domain. Don’t forget the dash to begin a new entry!

google.com: 
- :login: george
  :pass: foo
- :login: james
  :pass: trinkle

Place the table in ‘pasaporte/users_per_domain.yml’

Direct Known Subclasses

YamlDigestTable

Constant Summary collapse

YAML_TABLE =
File.dirname(Pasaporte::PATH) + '/pasaporte/users_per_domain.yml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeYamlTable

Returns a new instance of YamlTable.



19
20
21
# File 'lib/pasaporte/auth/yaml_table.rb', line 19

def initialize
  refresh
end

Instance Attribute Details

#table_pathObject

Returns the value of attribute table_path.



13
14
15
# File 'lib/pasaporte/auth/yaml_table.rb', line 13

def table_path
  @table_path
end

Instance Method Details

#call(login, pass, domain) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/pasaporte/auth/yaml_table.rb', line 23

def call(, pass, domain)
  refresh
  d = @table[domain]
  return false unless d.is_a?(Array)
  u = d.find do | user |
    (user["login"] == ) && (user["pass"] == pass)
  end
  !!u
end