CLI¶
FastAuth ships a fastauth CLI built with Typer and Rich. Install with the cli extra.
Commands¶
fastauth version¶
Prints the installed FastAuth version:
fastauth generate-secret¶
Prints a URL-safe random string suitable for FastAuthConfig.secret. HS256 requires ≥32 bytes — the default output (64 bytes) is well above the minimum.
$ fastauth generate-secret
q5N2x8... # 64 bytes by default
$ fastauth generate-secret --length 48
q5N2x8... # custom length
$ fastauth generate-secret -l 32 # minimum acceptable for HS256
Use it to populate secret in your config or .env.
fastauth check¶
Prints a table of every extra and whether the packages it provides are importable in the current environment. Useful when debugging MissingDependencyError.
fastauth providers¶
Lists the available OAuth providers and whether they are usable (the OAuth providers depend on the oauth extra → httpx).
fastauth init [<output_dir>]¶
Scaffolds a runnable FastAuth app into output_dir (default .). Writes two files:
fastauth_config.py— aFastAuthConfigusingSQLAlchemyAdapter(engine_url="sqlite+aiosqlite:///./auth.db")+CredentialsProvider().main.py— a FastAPI app with anasynccontextmanagerlifespan that callsadapter.create_tables()andauth.mount(app).
Use --force (-f) to overwrite existing files.
$ fastauth init my_app
Created: my_app/fastauth_config.py
Created: my_app/main.py
$ cd my_app && pip install "sreekarnv-fastauth[standard]" && uvicorn main:app --reload
fastauthrequires thecliextra. If it is not installed, running the CLI prints a help message pointing topip install sreekarnv-fastauth[cli]. (Thetyperandrichpackages must be importable.)
Global¶
--helpon any command shows usage.no_args_is_help=True— runningfastauthwith no subcommand prints help.