BasicAuthAuthenticator constructor

BasicAuthAuthenticator(
  1. Map<String, String> credentials, {
  2. Set<String> roles(
    1. String username
    )?,
})

Authenticates against a fixed credentials map (username → password). The resulting principal is granted the roles from roles (if provided).

Implementation

BasicAuthAuthenticator(
  Map<String, String> credentials, {
  Set<String> Function(String username)? roles,
}) : _resolve = ((username, password) async {
       if (credentials[username] != password) return null;
       return Principal(
         id: username,
         displayName: username,
         roles: roles?.call(username) ?? const {},
       );
     });