Skip to content

Land Auth service module on develop (#163, re-target)#177

Merged
gregwinn merged 1 commit into
developfrom
fix/auth-service-module-to-develop
Jun 11, 2026
Merged

Land Auth service module on develop (#163, re-target)#177
gregwinn merged 1 commit into
developfrom
fix/auth-service-module-to-develop

Conversation

@gregwinn

Copy link
Copy Markdown
Owner

Why this exists

PR #171 (the Auth service module, #163) was stacked on feature/auth-password-hashing and got merged into that branch instead of develop — and 28s after #169 had already merged that branch to develop. Net result: #163's Auth module never reached develop (Auth.register and the 'Auth' codegen-resolve clause are absent there).

This re-lands it by cherry-picking the original #163 commit (ff43215) cleanly onto current develop (which now also has #162, #172, #170).

Contents (unchanged from #171)

  • Auth.register/2, Auth.login/2, Auth.current_user/1 in winn_auth.erl; Authwinn_auth in winn_codegen_resolve.
  • winn_auth_fake_repo.erl + 9 tests in winn_auth_tests.erl (incl. an end-to-end Winn-source flow).
  • docs/modules.md Auth guide + docs/stdlib.md entry + CHANGELOG.

Verification

  • Cherry-pick applied cleanly (CHANGELOG auto-merged).
  • rebar3 eunit --module=winn_auth_tests: 12/12 pass.
  • Full suite: 734 tests, only the pre-existing winn_sqlite_tests esqlite-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

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>
@gregwinn gregwinn added enhancement New feature or request area/runtime Runtime modules (winn_runtime.erl, stdlib) labels Jun 11, 2026
@gregwinn gregwinn merged commit 53344c7 into develop Jun 11, 2026
1 of 2 checks passed
@gregwinn gregwinn deleted the fix/auth-service-module-to-develop branch June 11, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Runtime modules (winn_runtime.erl, stdlib) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant