|
| 1 | +# fbadmin |
| 2 | + |
| 3 | +A command-line tool for managing Firebase Authentication — users, custom claims, auth action links, and emulator utilities. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +Requires Rust 1.94+. |
| 8 | + |
| 9 | +```bash |
| 10 | +cargo install --path . |
| 11 | +``` |
| 12 | + |
| 13 | +## Quick start |
| 14 | + |
| 15 | +```bash |
| 16 | +# Interactive setup — creates a named profile |
| 17 | +fbadmin config init |
| 18 | + |
| 19 | +# Or connect directly with flags / env vars |
| 20 | +fbadmin --credentials ~/sa-key.json users list |
| 21 | +fbadmin -e localhost:9099 emulator clear-users |
| 22 | +export FBADMIN_PROJECT=my-project |
| 23 | +fbadmin users count |
| 24 | +``` |
| 25 | + |
| 26 | +## Authentication |
| 27 | + |
| 28 | +fbadmin resolves credentials in this order: |
| 29 | + |
| 30 | +1. `--credentials` / `FBADMIN_CREDENTIALS` — path to a service account JSON file |
| 31 | +2. `--project` / `FBADMIN_PROJECT` — project ID using Application Default Credentials |
| 32 | +3. `--emulator-host` / `FBADMIN_EMULATOR_HOST` — connect to the Firebase Auth emulator |
| 33 | +4. Profile settings from config (see below) |
| 34 | + |
| 35 | +## Configuration |
| 36 | + |
| 37 | +Profiles store connection settings so you don't need to pass flags every time. |
| 38 | + |
| 39 | +```bash |
| 40 | +fbadmin config init # Guided wizard |
| 41 | +fbadmin config add prod --credentials ~/keys/prod-sa.json |
| 42 | +fbadmin config add local --emulator-host localhost:9099 |
| 43 | +fbadmin config default prod # Set the default profile |
| 44 | +fbadmin config list # Show all profiles |
| 45 | +fbadmin config which # Show resolved connection chain |
| 46 | +fbadmin config path # Print config file locations |
| 47 | +``` |
| 48 | + |
| 49 | +Global config is stored by `confy` in the OS-appropriate location. A local `.fbadmin.toml` in the working directory is merged on top (field-level override). |
| 50 | + |
| 51 | +## Commands |
| 52 | + |
| 53 | +### Users |
| 54 | + |
| 55 | +```bash |
| 56 | +fbadmin users get --email user@example.com |
| 57 | +fbadmin users get --uid abc123 |
| 58 | +fbadmin users create --email new@example.com |
| 59 | +fbadmin users create --email new@example.com --password s3cret --display-name "Jane Doe" |
| 60 | +fbadmin users disable --email user@example.com |
| 61 | +fbadmin users enable --email user@example.com |
| 62 | +fbadmin users remove --csv uids.csv # Bulk delete from CSV |
| 63 | +fbadmin users list --limit 50 |
| 64 | +fbadmin users list-inactive --days 90 |
| 65 | +fbadmin users count |
| 66 | +``` |
| 67 | + |
| 68 | +Missing required arguments are prompted interactively when running in a terminal. Passwords are auto-generated if omitted. |
| 69 | + |
| 70 | +### Custom claims |
| 71 | + |
| 72 | +```bash |
| 73 | +fbadmin claims get --email user@example.com |
| 74 | +fbadmin claims merge role admin --email user@example.com |
| 75 | +fbadmin claims merge tier 2 --email user@example.com # Auto-detects int |
| 76 | +fbadmin claims merge prefs '{"dark":true}' --email user@example.com # JSON |
| 77 | +fbadmin claims remove role --email user@example.com |
| 78 | +fbadmin claims clear --email user@example.com |
| 79 | +fbadmin claims find admin # Find all users with "admin" claim |
| 80 | +fbadmin claims find role admin --exclusive # Only where role is the sole claim |
| 81 | +``` |
| 82 | + |
| 83 | +Use `--dry-run` with `merge`, `remove`, and `clear` to preview changes without writing. |
| 84 | + |
| 85 | +### Auth action links |
| 86 | + |
| 87 | +```bash |
| 88 | +fbadmin links password-reset --email user@example.com |
| 89 | +fbadmin links email-verify --email user@example.com |
| 90 | +fbadmin links sign-in --email user@example.com |
| 91 | +``` |
| 92 | + |
| 93 | +### Emulator |
| 94 | + |
| 95 | +These commands only work when connected to an emulator. |
| 96 | + |
| 97 | +```bash |
| 98 | +fbadmin -e localhost:9099 emulator clear-users |
| 99 | +fbadmin -e localhost:9099 emulator config |
| 100 | +``` |
| 101 | + |
| 102 | +### Connection info |
| 103 | + |
| 104 | +```bash |
| 105 | +fbadmin info # Shows resolved profile, project, credentials, and verifies connectivity |
| 106 | +``` |
| 107 | + |
| 108 | +## Global flags |
| 109 | + |
| 110 | +| Flag | Short | Env var | Description | |
| 111 | +|---|---|---|---| |
| 112 | +| `--profile` | `-p` | `FBADMIN_PROFILE` | Named profile from config | |
| 113 | +| `--project` | | `FBADMIN_PROJECT` | Firebase project ID | |
| 114 | +| `--credentials` | `-c` | `FBADMIN_CREDENTIALS` | Path to service account JSON | |
| 115 | +| `--emulator-host` | `-e` | `FBADMIN_EMULATOR_HOST` | Emulator host:port | |
| 116 | +| `--format` | `-f` | | Output format: `table`, `json`, `csv` | |
| 117 | +| `--dry-run` | | | Preview destructive operations | |
| 118 | +| `--yes` | `-y` | | Skip confirmation prompts | |
| 119 | +| `--verbose` | `-v` | | Increase verbosity (`-vv`, `-vvv`) | |
| 120 | + |
| 121 | +## Output formats |
| 122 | + |
| 123 | +```bash |
| 124 | +fbadmin users list -f table # Human-readable table (default) |
| 125 | +fbadmin users list -f json # NDJSON — one JSON object per line |
| 126 | +fbadmin users list -f csv # CSV with headers |
| 127 | +fbadmin claims get --email user@example.com -f json # Single record as JSON |
| 128 | +``` |
| 129 | + |
| 130 | +## License |
| 131 | + |
| 132 | +MIT |
0 commit comments