API Reference 0.7.0rikulo_securityAuthenticator

Authenticator abstract class

The authenticator.

abstract class Authenticator {
 /** Authenticates the given username and password.
  * The returned `Future` object shall carry the user object if successful.
  * If failed, throw an instance of [AuthenticationException]:
  *
  *     Future login(HttpConnect connect, String username, String password) {
  *       //...
  *       if (failed)
  *         throw new AuthenticationException("the cause");
  *       return new Future.value(new User(username, roles)); //any non-null object
  *     });
  */
 Future login(HttpConnect connect, String username, String password);
 /** Logout.
  *
  * The default implementation does nothing but returns `new Future.value()`.
  * You can override it for housekeeping if necessary.
  *
  * * [user] - the current user being logged out.
  * * Returns a [Future] instance carrying the data you'd like to preserve
  * in the new session after logout. If it carries null, nothing is preserved.
  */
 Future<Map> logout(HttpConnect connect, user) => new Future.value();
}

Subclasses

DummyAuthenticator

Methods

abstract Future login(HttpConnect connect, String username, String password) #

Authenticates the given username and password. The returned Future object shall carry the user object if successful. If failed, throw an instance of AuthenticationException:

Future login(HttpConnect connect, String username, String password) {
  //...
  if (failed)
    throw new AuthenticationException("the cause");
  return new Future.value(new User(username, roles)); //any non-null object
});

Future<Map> logout(HttpConnect connect, user) #

Logout.

The default implementation does nothing but returns new Future.value(). You can override it for housekeeping if necessary.

  • user - the current user being logged out.
  • Returns a Future instance carrying the data you'd like to preserve in the new session after logout. If it carries null, nothing is preserved.

Future<Map> logout(HttpConnect connect, user) => new Future.value();