Expand description
§wabot-addon-auth-pg
Postgres storage for auth. Port of ApiKeyPgQueries and
JwtRefreshTokenPgQueries in wabot-ts,
on top of PgJsonbStore — so an API key is a document in the
same table shape every other stored entity uses, and the two stacks
can share it.
ⓘ
let repository = Arc::new(PgApiKeyRepository::new(pool));
register_api_key_repository(&container, repository);
register_singletons!(&container, ApiKeyGuard);Both API keys and refresh tokens live here, because they are the same problem twice: a stored credential looked up by the hash of a secret nobody else holds.
§The lookup is by hash, and it is indexed
Only the SHA-256 hash of a secret is stored, and authentication looks a key up by that hash — database read access alone doesn’t let anyone in. That makes the hash the hot column, so it is promoted out of the JSON document and indexed; a sequential scan over every key on every request would be a denial-of-service waiting for the key table to grow.
Structs§
- PgApi
KeyRepository - API keys in a Postgres table.
- PgRefresh
Token Repository - Refresh tokens in a Postgres table.
Functions§
- register_
pg_ api_ key_ repository - Register a Postgres-backed API-key repository.
- register_
pg_ refresh_ token_ repository - Register Postgres-backed refresh-token storage.