Module: HealthMode::Authentication

Defined in:
lib/authentication.rb

Constant Summary collapse

@@authorized_host =
"127.0.0.1"
@@public_access =
false

Class Method Summary collapse

Class Method Details

.from_authorized_host?(req) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/authentication.rb', line 16

def self.from_authorized_host?(req)
  req.ip == "127.0.0.1" ||
    @@public_access ||
    Socket.getaddrinfo(@@authorized_host, nil)[0][2] == req.ip
end

.set_authorized_host(hostname) ⇒ Object



8
9
10
# File 'lib/authentication.rb', line 8

def self.set_authorized_host(hostname)
  @@authorized_host = hostname
end

.set_public_accessObject



12
13
14
# File 'lib/authentication.rb', line 12

def self.set_public_access
  @@public_access = true
end