Land Auth service module on develop (#163, re-target)#177
Merged
Conversation
Adds a high-level Auth module over Crypto (password hashing, #162), JWT (access tokens), and Repo (persistence), so an email/password login flow is a few lines instead of hand-wiring all three. Part of the authentication epic (#161). - register/2: hashes via Crypto.hash_password and inserts a user; returns the user without the password hash; {error, email_taken} on duplicate. - login/2: verifies the password and returns %{user, access_token} with a signed short-lived JWT. Wrong password and unknown email both return invalid_credentials in similar time (no user enumeration). - current_user/1: resolves the user from the verified JWT claims the [:auth] middleware attaches to the conn. - Conventions configurable via Config (auth.secret, auth.user_schema, auth.access_token_ttl); Auth -> winn_auth added to winn_codegen_resolve. - Tests run against an in-memory fake repo (winn_auth_fake_repo) injected via Config, exercising the real code paths (incl. an end-to-end Winn-source flow through codegen) without a database. docs/modules.md (+ stdlib.md) and CHANGELOG updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 11, 2026
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.
Why this exists
PR #171 (the
Authservice module, #163) was stacked onfeature/auth-password-hashingand got merged into that branch instead ofdevelop— and 28s after #169 had already merged that branch to develop. Net result: #163's Auth module never reacheddevelop(Auth.registerand the'Auth'codegen-resolve clause are absent there).This re-lands it by cherry-picking the original #163 commit (
ff43215) cleanly onto currentdevelop(which now also has #162, #172, #170).Contents (unchanged from #171)
Auth.register/2,Auth.login/2,Auth.current_user/1inwinn_auth.erl;Auth→winn_authinwinn_codegen_resolve.winn_auth_fake_repo.erl+ 9 tests inwinn_auth_tests.erl(incl. an end-to-end Winn-source flow).docs/modules.mdAuth guide +docs/stdlib.mdentry + CHANGELOG.Verification
rebar3 eunit --module=winn_auth_tests: 12/12 pass.winn_sqlite_testsesqlite-NIF environmental failure.Re-lands #163. Coexists with the merged #172 ORM fix, so the flow now works against real Postgres.
🤖 Generated with Claude Code