You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,44 +6,38 @@ Command-line interface for UnityAuth administration.
6
6
7
7
The UnityAuth CLI is a cross-platform command-line tool that enables system and tenant administrators to manage users, roles, and permissions in UnityAuth without using the web interface. It's designed for automation, batch operations, and scriptable workflows.
8
8
9
-
## Features
10
-
11
-
-**User Management**: Create, update, and list users
12
-
-**Authentication**: Secure login with OS-native token storage
13
-
-**Role & Tenant Discovery**: List available tenants and roles
14
-
-**Permission Verification**: Check user permissions for debugging
15
-
-**Batch Operations**: Create hundreds of users from CSV files
16
-
-**Multiple Output Formats**: Table, JSON, and CSV output
17
-
-**Automation-Friendly**: Non-interactive mode for scripts and CI/CD
Download from [python.org](https://www.python.org/downloads/) and run the installer. Check "Add Python to PATH" during installation.
77
52
78
-
# Install pip
79
-
python3 get-pip.py
80
-
81
-
# Clean up
82
-
rm get-pip.py
83
-
```
84
-
85
-
### Install from PyPI (Production)
86
-
87
-
Once Python and pip are configured:
53
+
### Install from Source (Development)
88
54
89
55
```bash
90
-
python3 -m pip install unityauth-cli
91
-
```
92
-
93
-
### Install for Development
94
-
95
-
For local development and testing:
56
+
cd unityauth-cli
96
57
97
-
```bash
98
-
# Clone the repository (if needed)
99
-
cd /path/to/UnityAuth/unityauth-cli
58
+
# Create and activate virtual environment
59
+
python3 -m venv venv
60
+
source venv/bin/activate # On Windows: venv\Scripts\activate
100
61
101
-
# Install in editable mode with development dependencies
62
+
# Install in editable mode
102
63
python3 -m pip install -e .
103
-
104
-
# Or install with dev dependencies
105
-
python3 -m pip install -e ".[dev]"
106
64
```
107
65
108
66
### Verify Installation
109
67
110
-
Confirm the CLI is installed correctly:
111
-
112
68
```bash
113
69
unityauth --version
114
70
```
115
71
116
-
You should see output like `unityauth-cli version 1.0.0`.
117
-
118
72
## Quick Start
119
73
120
74
### 1. Configure API Endpoint
@@ -127,14 +81,22 @@ unityauth config set api_url https://auth.example.com
127
81
128
82
```bash
129
83
unityauth login
84
+
# Enter email and password when prompted
130
85
```
131
86
132
-
You'll be prompted for your email and password. Your authentication token will be securely stored in your OS credential manager.
87
+
Your authentication token is securely stored in your OS credential manager (Keychain on macOS, Credential Manager on Windows, Secret Service on Linux).
133
88
134
-
### 3. List Tenants
89
+
### 3. Explore the System
135
90
136
91
```bash
92
+
# List accessible tenants
137
93
unityauth tenant list
94
+
95
+
# List available roles
96
+
unityauth role list
97
+
98
+
# List users in a tenant
99
+
unityauth tenant users 1
138
100
```
139
101
140
102
### 4. Create a User
@@ -149,140 +111,137 @@ unityauth user create \
149
111
--role-ids 2,3
150
112
```
151
113
152
-
## Common Commands
153
-
154
-
### Authentication
114
+
## Command Structure
155
115
156
-
```bash
157
-
unityauth login # Login with credentials
158
-
unityauth logout# Remove stored token
159
-
unityauth token-info # Display current session info
160
116
```
161
-
162
-
### User Management
163
-
164
-
```bash
165
-
unityauth user create ... # Create a new user
166
-
unityauth user list --tenant-id 1 # List users in a tenant
167
-
unityauth user update USER_ID ... # Update user roles
117
+
unityauth
118
+
├── login # Authenticate with UnityAuth
119
+
├── logout # Remove stored credentials
120
+
├── token-info # Display session information
121
+
├── config # Configuration management
122
+
│ ├── show # Display current config
123
+
│ ├── set # Set a config value
124
+
│ └── edit # Open config in editor
125
+
├── user # User management
126
+
│ ├── create # Create a new user
127
+
│ ├── list # List users in a tenant
128
+
│ └── update # Update user roles
129
+
├── tenant # Tenant discovery
130
+
│ ├── list # List accessible tenants
131
+
│ └── users # List users in a tenant
132
+
└── role # Role discovery
133
+
└── list # List available roles
168
134
```
169
135
170
-
### Discovery
136
+
##Global Options
171
137
172
-
```bash
173
-
unityauth tenant list # List accessible tenants
174
-
unityauth role list # List available roles
175
-
unityauth permission get ... # Get user permissions
176
-
```
138
+
All commands support these global options:
177
139
178
-
### Batch Operations
179
-
180
-
```bash
181
-
unityauth batch create-users users.csv # Create users from CSV
182
-
unityauth batch create-users users.csv --dry-run # Preview without creating
183
-
```
140
+
| Option | Description |
141
+
|--------|-------------|
142
+
|`--api-url TEXT`| Override API URL from config |
143
+
|`--format [table\|json\|csv]`| Output format (default: table) |
144
+
|`--verbose`| Enable debug output |
145
+
|`--version`| Show version and exit |
146
+
|`--help`| Show help message |
184
147
185
148
## Output Formats
186
149
187
-
The CLI supports three output formats:
150
+
```bash
151
+
# Human-readable table (default)
152
+
unityauth tenant list
188
153
189
-
-**table** (default): Human-readable ASCII tables
190
-
-**json**: Machine-readable JSON for scripting
191
-
-**csv**: Spreadsheet-compatible CSV
154
+
# Machine-readable JSON
155
+
unityauth tenant list --format json
192
156
193
-
Example:
157
+
# Spreadsheet-compatible CSV
158
+
unityauth tenant list --format csv
194
159
195
-
```bash
160
+
# Pipe JSON to jq for processing
196
161
unityauth tenant list --format json | jq '.[0].name'
-[UnityAuth API](../CLAUDE.md) - Backend API reference
232
211
233
212
## Development
234
213
235
-
### Setting Up Development Environment
214
+
### Setup
236
215
237
216
```bash
238
-
# Navigate to the CLI directory
239
217
cd unityauth-cli
240
-
241
-
# Install development dependencies
242
-
python3 -m pip install -r requirements-dev.txt
243
-
244
-
# Or install in editable mode with dev extras
218
+
python3 -m venv venv
219
+
source venv/bin/activate
245
220
python3 -m pip install -e ".[dev]"
246
221
```
247
222
248
223
### Running Tests
249
224
250
225
```bash
251
-
# Run unit tests
252
226
pytest tests/unit/
253
-
254
-
# Run integration tests
255
-
pytest tests/integration/
256
-
257
-
# Run all tests with coverage
258
227
pytest --cov=unityauth_cli
259
228
```
260
229
261
230
### Code Quality
262
231
263
232
```bash
264
-
# Format code
265
-
black src/
266
-
267
-
# Lint code
268
-
flake8 src/
269
-
270
-
# Type checking
271
-
mypy src/
233
+
black src/ # Format code
234
+
flake8 src/ # Lint
235
+
mypy src/ # Type checking
272
236
```
273
237
274
238
## Security
275
239
276
-
-**Token Storage**: JWT tokens are encrypted at rest using OS-native credential stores (Keychain on macOS, Credential Manager on Windows, Secret Service on Linux)
277
-
-**HTTPS Required**: API communication requires HTTPS
278
-
-**No Password Storage**: Passwords are never stored; only JWT tokens
279
-
-**Secure CSV Handling**: CSV files containing passwords should be deleted after batch operations
0 commit comments