Class: SSHScan::Api::Authenticator
- Inherits:
-
Object
- Object
- SSHScan::Api::Authenticator
- Defined in:
- lib/ssh_scan_api/authenticator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Authenticator
constructor
A new instance of Authenticator.
- #valid_token?(token) ⇒ Boolean
Constructor Details
#initialize(config = {}) ⇒ Authenticator
Returns a new instance of Authenticator.
6 7 8 |
# File 'lib/ssh_scan_api/authenticator.rb', line 6 def initialize(config = {}) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/ssh_scan_api/authenticator.rb', line 4 def config @config end |
Class Method Details
.from_config_file(config_file) ⇒ Object
10 11 12 13 |
# File 'lib/ssh_scan_api/authenticator.rb', line 10 def self.from_config_file(config_file) opts = YAML.load_file(config_file) SSHScan::Api::Authenticator.new(opts) end |
Instance Method Details
#valid_token?(token) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ssh_scan_api/authenticator.rb', line 15 def valid_token?(token) if @config["users"] @config["users"].each do |user| return true if user["token"] == token end end if @config["workers"] @config["workers"].each do |worker| return true if worker["token"] == token end end if ENV['sshscan.worker.token'] == token return true end return false end |