Add `nx add auth` to install a reviewed account flow

Open
#678 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
fastapi, python

Research direction

Read examples/auth/README and inspect the files under examples/auth/src/accounts/, examples/auth/src/actions/accounts.py, and the sign up, sign in, account, and not found pages and tests. Compare the file-writing behavior requested here with issue #671, then document whether the command copies the example or wraps nexy-auth before implementation. Done means the command preserves existing files, is idempotent, prints changed files, and its generated security tests and docs meet the acceptance criteria.

Written by the indexing model from the issue text.

Description

enhancement

Problem

Nexy has a working auth example in examples/auth, but a developer who wants accounts in their own project has to copy the pieces by hand and work out which ones are required for safety: signed sessions, password hashing, throttling, redirect checks, and environment settings. Copying a demo without that review can ship an unsafe login.

Proposed solution

Add nx add auth (also available as nexy add auth) that installs the account flow from the reviewed example into an existing project:

  • Turn on sessions in nexyconfig.py and keep existing config values.
  • Copy the account files from examples/auth/src/accounts/ and the form actions from examples/auth/src/actions/accounts.py into the project src/.
  • Copy the sign up, sign in, account, and not found pages, with their tests, without overwriting files the developer already owns.
  • Document the required SESSION_SECRET and SECURE_COOKIES settings and the SQLite database location.
  • Keep the security behavior of the example: scrypt hashes, signed cookies, throttle, constant time comparison, and path-only redirect targets.
  • Print every file changed and leave the project unchanged on a second run.

Before implementation, confirm whether the command should copy the example into the project or wrap the external nexy-auth package. The external project has open issues about module support, email and password sessions, and client adapters (NexyPy/nexy-auth issues 9, 2, and 6). The choice must be recorded in the docs.

Acceptance criteria:

  • A project after nx add auth passes the copied security tests, including forged cookies, open redirects, repeated wrong passwords, and HTML in query values.
  • Running the command twice produces no further changes and never overwrites an owned file.
  • A docs page explains setup, environment variables, and what the command does not provide, such as email confirmation and a shared throttle store for multiple processes.
  • Tests cover the generated files, config edit, conflict handling, and idempotency.

Alternative solutions

Point developers at examples/auth and ask them to copy files themselves, or make auth an external package only. Both avoid a new command but leave the safety review and the wiring to each developer.

Additional context

The command should follow the file writing behavior of nx add vercel (issue #671): data describing the generated files, no auth dependency added to the framework core, and no overwrite of a file the developer owns. The reference implementation is examples/auth/ and its README lists the security rules. Related work: issue #570 closed the auth example, and nexy-auth issues 1, 2, 6, and 9 track the external package API.

Validation

  • I have searched existing issues and this is not a duplicate.
  • I would be willing to help implement this feature.
Dominant language
Python
Stars
11
Forks
6
Avg merge
2h 14m
Merged PRs (30d)
265

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NexyPy/nexy

All issues in NexyPy/nexy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.