Increment 2 - Step 2: Auth module - #13
Merged
Merged
Conversation
…r not found instead of a query error, flattened touch/revoke result handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Increment 2 – Step 2: Auth module
The cryptographic and data-access layer for authentication: password hashing, session tokens, the role catalogue, and the repositories that persist users and sessions - built on a new libpqxx connection pool.
What's new
server/modules/auth(modulo_server_auth):PasswordHasher- Argon2id via libsodium (crypto_pwhash_str): hash, constant-time verify, rehash detection. Cost profile is libsodium's INTERACTIVE (64 MiB, 2 passes) - above the OWASP Argon2id minimum at ~0.1 s per hash.token- opaque session tokens: 32 CSPRNG bytes (libsodium) as unpadded base64url, and the SHA-256 digest (QCryptographicHash) that is the only form ever stored or compared.Role- the fixed admin/user catalogue pinned to the schema ids, with name and id conversions.UserRepositoryandSessionRepository- every method runs one transaction on a pooled connection and returnsResult, never throws. A module-privatepg.howns the Qt-to-libpqxx boundary: string and bytea conversion, ISO-8601-in / epoch-milliseconds-out timestamps, and the mapping of libpqxx exceptions to stabledb.*codes (auth.email_taken,auth.session_not_foundlayered on top).ConnectionPoolinserver/modules/db(Qt-free): lazy connection opening, RAII leases, blocks when exhausted, discards broken connections.core::validatePassword- the shared password rule (10 to 128 characters) the client will reuse for form validation.Tests (5 new binaries)
modulo_auth_repositories_tests, opt-in viaMODULO_TEST_DB_URL): pool reuse, case-insensitive email lookup,auth.email_takenwith rollback, full session lifecycle, expiry, revoke-all scoping.Notes
result[i]is arow_ref(useone_row()),pqxx::bytesisstd::vector<std::byte>.pg.hstays private to the auth module by design; it becomes a sharedpersistencemodule when the transactions module needs it in Increment 3.Verified:
ctest --preset all12/12 with the database (integration suites report Skipped without it), clean-Werrorbuild,format.sh --checkgreen.