Skip to content

class Athena::Security::FirewallMap
inherits Reference #

Maps requests to the listeners of the firewall they belong to, via request matchers.

A request belongs to the firewall of the first request matcher matching it.

firewall_map = ASEC::FirewallMap.new
firewall_map.add AHTTP::RequestMatcher::Path.new(%r(^/api)), api_listeners, api_exception_listener
firewall_map.add nil, main_listeners, main_exception_listener

Included modules

Athena::Security::FirewallMapInterface

Methods#

#add(request_matcher : AHTTP::RequestMatcher::Interface | Nil = nil, listeners : Enumerable(ASEC::Firewall::ListenerInterface) = [] of ASEC::Firewall::ListenerInterface, exception_listener : ASEC::Firewall::ExceptionListener | Nil = nil) : Nil#

Adds a firewall for the requests matching the provided request_matcher, or every request if it is nil, made of the provided listeners and exception_listener.

The listeners are called in order of their ASEC::Firewall::ListenerInterface#priority, then in the provided order.

View source

#listeners(request : AHTTP::Request) : Tuple(Array(ASEC::Firewall::ListenerInterface), ASEC::Firewall::ExceptionListener | Nil)#

Returns the listeners and the exception listener of the firewall the provided request belongs to.

Returns no listeners and no exception listener if the request belongs to no firewall.

View source