Skip to content

class Athena::Security::User::Provider::Chain
inherits Reference #

Delegates to each of its providers in turn, until one of them is able to handle the request.

provider = ASEC::User::Provider::Chain.new [
  ASEC::User::Provider::InMemory.new([ASEC::User::InMemory.new("admin", "$2y$13$...", ["ROLE_ADMIN"])]),
  DatabaseUserProvider.new,
] of ASEC::User::Provider::Interface

Included modules

Athena::Security::User::PasswordUpgraderInterface Athena::Security::User::Provider::Interface

Constructors#

Methods#

#load_user_by_identifier(identifier : String) : ASEC::User::Interface#

Returns the user with the provided identifier, e.g. its username or email address.

Raises an ASEC::Exception::UserNotFound if no user has that identifier.

View source

#providers : Array(ASEC::User::Provider::Interface)#

Returns the providers this provider delegates to.

View source

#refresh_user(user : ASEC::User::Interface) : ASEC::User::Interface#

Returns an up to date instance of the provided user, e.g. reloaded from the database.

Raises an ASEC::Exception::UnsupportedUser if the user is not supported, or an ASEC::Exception::UserNotFound if it no longer exists.

View source

#supports_class?(klass : ASEC::User::Interface.class) : Bool#

Returns true if this provider supports users of the provided klass, otherwise false.

View source

#upgrade_password(user : APH::PasswordAuthenticatedUserInterface, new_hashed_password : String) : Nil#

Persists the provided new_hashed_password of the provided user, and updates the user accordingly.

Upgrades should be opportunistic, as users must still be able to log in when they fail. It is fine for this method to do nothing, or to fail without raising.

Raises an ASEC::Exception::UnsupportedUser if the user is not supported.

Upgrades the password via each provider that includes ASEC::User::PasswordUpgraderInterface.

View source