class Strelka::AuthProvider::HostAccess
HostAccess
AuthProvider class – restricts access to requests coming from a list of netblocks.
You can configure which ones from the auth
section of the config:
auth: allowed_netblocks: - 127.0.0.0/8 - 10.5.3.0/22
Constants
- DEFAULT_ALLOWED_NETBLOCKS
The default list of netblocks to allow
Attributes
allowed_netblocks[R]
An Array of IPAddr objects that represent the netblocks that will be allowed access to the protected resources
Public Class Methods
new( * )
click to toggle source
Create a new Default AuthProvider.
Calls superclass method
Strelka::AuthProvider::new
# File lib/strelka/authprovider/hostaccess.rb, line 42 def initialize( * ) super self.allowed_netblocks = DEFAULT_ALLOWED_NETBLOCKS # Register this instance with Configurability config_key :hostaccess end
Public Instance Methods
allowed_netblocks=( newblocks )
click to toggle source
Set the list of allowed netblocks to newblocks
.
# File lib/strelka/authprovider/hostaccess.rb, line 62 def allowed_netblocks=( newblocks ) @allowed_netblocks = Array( newblocks ).map {|addr| IPAddr.new(addr) } end
configure( config=nil )
click to toggle source
Configurability API – configure the auth provider instance.
# File lib/strelka/authprovider/hostaccess.rb, line 68 def configure( config=nil ) self.log.debug "Configuring %p with config: %p" % [ self, config ] if config && config['allowed_netblocks'] self.allowed_netblocks = config['allowed_netblocks'] else self.allowed_netblocks = DEFAULT_ALLOWED_NETBLOCKS end end
in_allowed_netblocks?( ipaddr )
click to toggle source
Returns true
if the given ipaddr
is in the allowed_netblocks
.
# File lib/strelka/authprovider/hostaccess.rb, line 92 def in_allowed_netblocks?( ipaddr ) return self.allowed_netblocks.any? {|nb| nb.include?(ipaddr) } end