Skip to content

class Athena::Security::AccessMap
inherits Reference #

Maps requests to the attribute they require, e.g. a role, via request matchers, see ASEC::Firewall::AccessListener.

A request requires the attribute of the first request matcher matching it.

access_map = ASEC::AccessMap.new
access_map.add AHTTP::RequestMatcher::Path.new(%r(^/admin/login)), ASEC::Authorization::Voter::Authenticated::PUBLIC_ACCESS
access_map.add AHTTP::RequestMatcher::Path.new(%r(^/admin)), "ROLE_ADMIN"

Methods#

#add(request_matcher : AHTTP::RequestMatcher::Interface, attribute : String | Nil = nil) : Nil#

Adds a rule for the requests matching the provided request_matcher, which require the provided attribute.

A nil attribute requires nothing, e.g. to exclude some requests from a later rule.

View source

#attribute(request : AHTTP::Request) : String | Nil#

Returns the attribute required by the first rule matching the provided request, or nil if it requires none.

View source