Expand description
Password accounts with Argon2id password hashes, kept in any [Table].
Build one in code with PasswordAccounts::builder; the default table is in memory. The
provider authenticates accounts, resolves the same records as a directory, and manages
them through [Accounts].
§coqui-access-password
Password accounts: names and Argon2id password hashes, groups, and the account-management
kind to make, change and remove them. An authenticator, a directory and an Accounts provider
over one Table of account records. The table is any source you give it (memory by default,
a file, a SQL database, an HTTP API) and is read again whenever it reports a change.
§Features
- Code first -
PasswordAccounts::builder()works out of the box with an in-memory table. - Any source - hand it an
Arc<dyn Table<AccountRecord>>fromcoqui-access-kit. - Argon2id hashes only, with the costs configurable; a name that is not kept costs the same time as a wrong password.
- Account management -
putmakes an account (a password is required for a new one), changes groups or the disabled flag, or replaces the password.
§Installation
cargo add coqui-access-password --git https://github.com/Boriken-Dev/coqui-accessBuild coqui-access-password-plugin for the loadable library.
§Quick start
use coqui_access::{AccountPut, Accounts, Attempt, Authenticator, Verdict};
use coqui_access_password::PasswordAccounts;
let accounts = PasswordAccounts::builder().build().unwrap();
accounts
.put(AccountPut {
name: "alice".into(),
secret: Some("correct horse".into()),
..AccountPut::default()
})
.unwrap();
let verdict = accounts
.authenticate(Attempt {
name: Some("alice".into()),
secret: Some("correct horse".into()),
..Attempt::default()
})
.unwrap();
assert!(matches!(verdict, Verdict::Valid(_)));Records of your own come from a table:
PasswordAccounts::builder().table(table).max_accounts(500).argon2(params).build()?, where
table is a MemoryTable::from_records([AccountRecord::new(id, name, hash).groups(["staff"])])
or your own Table<AccountRecord>. Hashes come from coqui_access_kit::PasswordHasher, which
you can use with your own data too. AccountRecord derives guatiao’s value traits, so any
table keeps it.
The loadable plugin (provider id coqui_access_password) is configured with a source, for
example { "source": { "file": { "path": "accounts.toml", "format": "toml" } } } (format is
toml or json), max_accounts, argon2, record_limits and max_password_bytes; with no source the accounts live in memory.
§API overview
| Item | Purpose |
|---|---|
PasswordAccounts | The provider, and the Authenticator, Directory and Accounts kinds. builder() makes one. |
PasswordAccountsBuilder | Options: table, max_accounts, argon2, record_limits, max_password_bytes; build. |
AccountRecord | One account as a table keeps it; guatiao value traits. |
DEFAULT_MAX_ACCOUNTS | 10 000. |
§Development
cargo test -p coqui-access-password --all-features
cargo clippy -p coqui-access-password --all-targets --all-features -- -D warnings§Releasing
This project follows Semantic Versioning and keeps a
CHANGELOG.md.
Pushing a tag matching v* triggers the release workflow of the repository.
§License
MPL-2.0 — see LICENSE.
Structs§
- Account
Record - One password account as a [
Table] keeps it, keyed byname. - Password
Accounts - Password accounts as an Authenticator, Directory and Accounts implementation.
- Password
Accounts Builder - Options for
PasswordAccounts; every one has a default.
Constants§
- DEFAULT_
MAX_ ACCOUNTS - The most accounts a table may hold unless the builder says otherwise.