Skip to content

class Athena::Security::Authenticator::Passport
inherits Reference #

Holds what must be checked about an authentication before its user is authenticated, as badges.

An ASEC::Authenticator::Interface creates a passport from the request, with the user being authenticated and its credentials. The listeners of the ASEC::Events::CheckPassport event then check it, e.g. by verifying the password, resolving its badges. The authentication fails if any of its badges is not resolved once it was checked.

ASEC::Authenticator::Passport.new(
  ASEC::Authenticator::Passport::Badge::User.new(email),
  ASEC::Authenticator::Passport::Credentials::Password.new(password),
)

Use an ASEC::Authenticator::Passport::SelfValidating if there are no credentials to check, e.g. if the authenticator verified them itself.

Direct known subclasses

Athena::Security::Authenticator::Passport::SelfValidating

Constructors#

.new(user_badge : ASEC::Authenticator::Passport::Badge::User, credentials : ASEC::Authenticator::Passport::Credentials::Interface, badges : Enumerable(ASEC::Authenticator::Passport::Badge::Interface) = [] of ASEC::Authenticator::Passport::Badge::Interface)#

Creates a passport for the user of the provided user_badge, whose credentials must be checked, with the provided additional badges.

View source

Methods#

#add_badge(badge : ASEC::Authenticator::Passport::Badge::Interface, badge_class : ASEC::Authenticator::Passport::Badge::Interface.class = badge.class) : self#

Adds the provided badge to this passport, replacing the badge of the same type, if any.

The badge may be added as another badge_class, e.g. to replace a built-in badge with a subclass of it.

View source

#badge(badge_class : T.class) : T | Nil forall T#

Returns the badge of the provided badge_class, or nil if this passport has none.

View source

#badges : Array(ASEC::Authenticator::Passport::Badge::Interface)#

Returns the badges of this passport.

View source

#has_badge?(badge_class : ASEC::Authenticator::Passport::Badge::Interface.class) : Bool#

Returns true if this passport has a badge of the provided badge_class, otherwise false.

View source

#user : ASEC::User::Interface#

Returns the user being authenticated, loaded by the ASEC::Authenticator::Passport::Badge::User of this passport.

Raises an ASEC::Exception::Logic if this passport has no user badge.

View source