class Athena::Security::Authorization::AccessDecisionManager
inherits Reference
#
Decides whether a token is granted an attribute, optionally on a subject, by asking its voters and turning their votes into a decision via its ASEC::Authorization::Strategy::Interface.
access_decision_manager = ASEC::Authorization::AccessDecisionManager.new(
[ASEC::Authorization::Voter::Role.new, PostVoter.new] of ASEC::Authorization::Voter,
ASEC::Authorization::Strategy::Unanimous.new
)
access_decision_manager.decide token, "EDIT", post # => true
Only the voters handling the type of the subject vote on it, see ASEC::Authorization::Voter.
Constructors#
.new(voters : Array(ASEC::Authorization::Voter) = [] of ASEC::Authorization::Voter, strategy : ASEC::Authorization::Strategy::Interface = ASEC::Authorization::Strategy::Affirmative.new)#
Methods#
#decide(token : ASEC::Authentication::Token::Interface, attribute : String, subject = nil, access_decision : ASEC::Authorization::AccessDecision | Nil = nil) : Bool#
Returns true if the provided token is granted the provided attribute, optionally on the provided subject, otherwise false.
The decision and the votes it was based on are stored in the provided access_decision, if any. A decision made while another one is ongoing, e.g. by a voter, defaults to storing them in the ongoing access_decision.