crates.io ↗

iet-auth-basic-timescale

integration implementation official

Persists identifiers and password hashes for the password-auth contracts.

CoreFeaturesIntegrationsStacksTooling
Used byno framework crate yetexamples/htmx-starterexamples/skills-only-appexamples/skills-only-app-task-tracker
iet-auth-basic-timescaleimplementationTimescaleDB credential store
Depends oniet-telemetrycontractiet-corecontractiet-authcontractiet-db-timescalecontractiet-db-macroscontract

How to use it

Owns fw_auth_credentials and fw_auth_identifiers and implements iet_auth::CredentialStore by resolving a login to a password account. Register it after iet_auth_identity_timescale, then feed CredentialStore::new(db) into iet_auth_basic::BasicAuth.

rust
// examples/skills-only-app-task-tracker/servers/web/src/providers.rs
let auth = Arc::new(
    BasicAuth::configured(
        iet_auth_basic_timescale::CredentialStore::new(database.clone()),
        BcryptConfig::default(),
    )
    .await?,
);
rust
// Registration: examples/skills-only-app-task-tracker/servers/web/src/database.rs
let mut registry = EntityRegistry::default();
iet_auth_identity_timescale::register(&mut registry)?;
iet_auth_basic_timescale::register(&mut registry)?;
  • The crate does not own the identity table; registration fails unless iet_auth_identity_timescale was registered first.
  • Unknown/illegal logins return Ok(None) rather than an error.

How it works

CredentialStore::account bounds the login with valid_identifier, then repository::account runs one query that joins fw_auth_identifiers to fw_auth_credentials and fw_auth_identities, returning a PasswordAccount only for enabled identities.

flowchart LR
  Auth["BasicAuth authenticate"] --> Store["CredentialStore"]
  Store --> Valid["valid_identifier"]
  Valid --> Repo["repository account"]
  Repo --> Ident["fw_auth_identifiers"]
  Repo --> Cred["fw_auth_credentials"]
  Repo --> Idn["fw_auth_identities"]
  Repo --> Acct["PasswordAccount"]

What it implements

  • Implements iet_auth::CredentialStore from iet-auth.

Database schema

fw_auth_credentialsentity Credential · hard delete
PKsubjectuuid::Uuid
password_hashString
subject→fw_auth_identities.id
fw_auth_identifiersentity Identifier · hard delete
PKidentifierString
subjectuuid::Uuid
subject→fw_auth_credentials.subject
Tables are derived from entity metadata; arrows are foreign keys. Dashed names are tables owned by another crate.

The details below come from #[derive(Persistent)] entity metadata:

fw_auth_credentials

Entity Credential (hard delete).

ColumnRust typeAttributes
subjectuuid::Uuidprimary key
password_hashString

Foreign key auth_credential_subject: (subject) → fw_auth_identities (id)

fw_auth_identifiers

Entity Identifier (hard delete).

ColumnRust typeAttributes
identifierStringprimary key
subjectuuid::Uuid

Foreign key auth_identifier_subject: (subject) → fw_auth_credentials (subject)

Entities register into an EntityRegistry; EntityRegistry::initial emits a reviewed migration pair, and Migrations applies reviewed files. See iet-db-timescale and iet-db.

What's inside

Modules

  • src/entity.rs
  • src/lib.rs
  • src/repository.rs
  • src/stores.rs

Public API

(root)

  • pub fn register(registry: &mut EntityRegistry) -> AppResult<()> — Register owned tables; register identity tables separately before generating SQL.

entity

  • struct Credential
  • struct Identifier

stores

  • struct CredentialStore
  • pub fn new(database: TimescaleDatabase) -> Self

Impl map

  • iet_auth::CredentialStore for CredentialStore

Depends on

External crates: sqlx, uuid

Used by

  • No other framework crate depends on it directly.

In this repository

  • examples/htmx-starter
  • examples/skills-only-app
  • examples/skills-only-app-task-tracker

Source: crates/integrations/iet-auth-basic-timescale