Class: ActionDispatch::HostAuthorization::Permissions

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/middleware/host_authorization.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(hosts) ⇒ Permissions

Returns a new instance of Permissions.



14
15
16
# File 'actionpack/lib/action_dispatch/middleware/host_authorization.rb', line 14

def initialize(hosts)
  @hosts = sanitize_hosts(hosts)
end

Instance Method Details

#allows?(host) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
# File 'actionpack/lib/action_dispatch/middleware/host_authorization.rb', line 22

def allows?(host)
  @hosts.any? do |allowed|
    allowed === host
  rescue
    # IPAddr#=== raises an error if you give it a hostname instead of
    # IP. Treat similar errors as blocked access.
    false
  end
end

#empty?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'actionpack/lib/action_dispatch/middleware/host_authorization.rb', line 18

def empty?
  @hosts.empty?
end