@portaidentity/cli 0.1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +324 -0
- package/dist/commands/version.d.ts +1 -1
- package/dist/commands/version.js +1 -1
- package/package.json +6 -1
package/README.md
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# @portaidentity/cli
|
|
2
|
+
|
|
3
|
+
The official command-line interface for the [Porta Identity Platform](https://github.com/blendsdk/porta-identity) — manage organizations, applications, clients, users, RBAC, and more from your terminal.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **26 command modules** — Full admin coverage: orgs, apps, clients, users, roles, permissions, claims, secrets, sessions, audit, and more
|
|
8
|
+
- **OIDC authentication** — Secure login via Authorization Code + PKCE (opens your browser, no passwords stored)
|
|
9
|
+
- **Declarative provisioning** — Set up entire environments from a single YAML/JSON file
|
|
10
|
+
- **Built on `@portaidentity/sdk`** — Type-safe API calls with automatic error handling
|
|
11
|
+
- **JSON output mode** — Machine-readable output for scripting and CI/CD (`--json`)
|
|
12
|
+
- **Shell completions** — Tab completion for Bash, Zsh, and Fish
|
|
13
|
+
- **Doctor diagnostics** — Built-in connectivity and configuration troubleshooting
|
|
14
|
+
- **Docker-friendly** — Headless/manual login mode auto-detected in containers
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install globally
|
|
20
|
+
npm install -g @portaidentity/cli
|
|
21
|
+
|
|
22
|
+
# Or use npx (no install)
|
|
23
|
+
npx @portaidentity/cli <command>
|
|
24
|
+
|
|
25
|
+
# Verify installation
|
|
26
|
+
porta version
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 1. Log in to your Porta server (opens browser for OIDC login)
|
|
33
|
+
porta login --server https://your-porta-server.example.com
|
|
34
|
+
|
|
35
|
+
# 2. Check your identity
|
|
36
|
+
porta whoami
|
|
37
|
+
|
|
38
|
+
# 3. List organizations
|
|
39
|
+
porta org list
|
|
40
|
+
|
|
41
|
+
# 4. Create a user
|
|
42
|
+
porta user create <org-id> --email alice@example.com --given-name Alice --family-name Smith
|
|
43
|
+
|
|
44
|
+
# 5. Check server health
|
|
45
|
+
porta health --server https://your-porta-server.example.com
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Global Options
|
|
49
|
+
|
|
50
|
+
Every command supports these flags:
|
|
51
|
+
|
|
52
|
+
| Flag | Description | Default |
|
|
53
|
+
|------|-------------|---------|
|
|
54
|
+
| `--server` | Porta server URL | `https://porta.local:3443` |
|
|
55
|
+
| `--json` | Output as JSON (for scripting / CI) | `false` |
|
|
56
|
+
| `--force` | Skip confirmation prompts | `false` |
|
|
57
|
+
| `--insecure` | Disable TLS certificate verification | `false` |
|
|
58
|
+
|
|
59
|
+
## Command Reference
|
|
60
|
+
|
|
61
|
+
### Authentication
|
|
62
|
+
|
|
63
|
+
| Command | Description |
|
|
64
|
+
|---------|-------------|
|
|
65
|
+
| `porta login` | Authenticate via OIDC (Auth Code + PKCE) — opens browser |
|
|
66
|
+
| `porta logout` | Clear stored credentials |
|
|
67
|
+
| `porta whoami` | Display current identity (no network call) |
|
|
68
|
+
|
|
69
|
+
### Organizations
|
|
70
|
+
|
|
71
|
+
| Command | Description |
|
|
72
|
+
|---------|-------------|
|
|
73
|
+
| `porta org list` | List all organizations |
|
|
74
|
+
| `porta org create` | Create a new organization |
|
|
75
|
+
| `porta org show <id>` | Show organization details |
|
|
76
|
+
| `porta org update <id>` | Update organization properties |
|
|
77
|
+
| `porta org activate <id>` | Activate an organization |
|
|
78
|
+
| `porta org suspend <id>` | Suspend an organization |
|
|
79
|
+
| `porta org archive <id>` | Archive an organization |
|
|
80
|
+
| `porta org destroy <slug>` | Permanently delete an organization and all child entities |
|
|
81
|
+
|
|
82
|
+
### Applications
|
|
83
|
+
|
|
84
|
+
| Command | Description |
|
|
85
|
+
|---------|-------------|
|
|
86
|
+
| `porta app list` | List applications |
|
|
87
|
+
| `porta app create` | Create a new application |
|
|
88
|
+
| `porta app show <id>` | Show application details |
|
|
89
|
+
| `porta app update <id>` | Update application properties |
|
|
90
|
+
| `porta app activate <id>` | Activate an application |
|
|
91
|
+
| `porta app suspend <id>` | Suspend an application |
|
|
92
|
+
| `porta app archive <id>` | Archive an application |
|
|
93
|
+
|
|
94
|
+
**Nested: Roles** (`porta app role ...`)
|
|
95
|
+
|
|
96
|
+
| Command | Description |
|
|
97
|
+
|---------|-------------|
|
|
98
|
+
| `porta app role create <app-id>` | Create a role |
|
|
99
|
+
| `porta app role list <app-id>` | List roles |
|
|
100
|
+
| `porta app role show <app-id> <role-id>` | Show role details |
|
|
101
|
+
| `porta app role update <app-id> <role-id>` | Update a role |
|
|
102
|
+
| `porta app role archive <app-id> <role-id>` | Archive a role |
|
|
103
|
+
| `porta app role assign-perm <app-id> <role-id> <perm-id>` | Assign permission to role |
|
|
104
|
+
| `porta app role remove-perm <app-id> <role-id> <perm-id>` | Remove permission from role |
|
|
105
|
+
|
|
106
|
+
**Nested: Permissions** (`porta app permission ...`)
|
|
107
|
+
|
|
108
|
+
| Command | Description |
|
|
109
|
+
|---------|-------------|
|
|
110
|
+
| `porta app permission create <app-id>` | Create a permission |
|
|
111
|
+
| `porta app permission list <app-id>` | List permissions |
|
|
112
|
+
| `porta app permission show <app-id> <perm-id>` | Show permission details |
|
|
113
|
+
| `porta app permission archive <app-id> <perm-id>` | Archive a permission |
|
|
114
|
+
|
|
115
|
+
**Nested: Claims** (`porta app claim ...`)
|
|
116
|
+
|
|
117
|
+
| Command | Description |
|
|
118
|
+
|---------|-------------|
|
|
119
|
+
| `porta app claim create <app-id>` | Create a claim definition |
|
|
120
|
+
| `porta app claim list <app-id>` | List claim definitions |
|
|
121
|
+
| `porta app claim show <app-id> <claim-id>` | Show claim details |
|
|
122
|
+
| `porta app claim update <app-id> <claim-id>` | Update a claim definition |
|
|
123
|
+
| `porta app claim archive <app-id> <claim-id>` | Archive a claim definition |
|
|
124
|
+
|
|
125
|
+
**Nested: Modules** (`porta app module ...`)
|
|
126
|
+
|
|
127
|
+
| Command | Description |
|
|
128
|
+
|---------|-------------|
|
|
129
|
+
| `porta app module list <app-id>` | List application modules |
|
|
130
|
+
| `porta app module enable <app-id>` | Enable a module |
|
|
131
|
+
| `porta app module disable <app-id>` | Disable a module |
|
|
132
|
+
|
|
133
|
+
### Clients
|
|
134
|
+
|
|
135
|
+
| Command | Description |
|
|
136
|
+
|---------|-------------|
|
|
137
|
+
| `porta client list` | List clients |
|
|
138
|
+
| `porta client create` | Create a new client |
|
|
139
|
+
| `porta client show <id>` | Show client details |
|
|
140
|
+
| `porta client update <id>` | Update client properties |
|
|
141
|
+
| `porta client activate <id>` | Activate a client |
|
|
142
|
+
| `porta client suspend <id>` | Suspend a client |
|
|
143
|
+
| `porta client archive <id>` | Archive a client |
|
|
144
|
+
|
|
145
|
+
**Nested: Secrets** (`porta client secret ...`)
|
|
146
|
+
|
|
147
|
+
| Command | Description |
|
|
148
|
+
|---------|-------------|
|
|
149
|
+
| `porta client secret create <client-id>` | Generate a new client secret |
|
|
150
|
+
| `porta client secret list <client-id>` | List client secrets |
|
|
151
|
+
| `porta client secret revoke <client-id> <secret-id>` | Revoke a client secret |
|
|
152
|
+
|
|
153
|
+
### Users
|
|
154
|
+
|
|
155
|
+
| Command | Description |
|
|
156
|
+
|---------|-------------|
|
|
157
|
+
| `porta user list <org-id>` | List users in an organization |
|
|
158
|
+
| `porta user create <org-id>` | Create a new user |
|
|
159
|
+
| `porta user show <org-id> <user-id>` | Show user details |
|
|
160
|
+
| `porta user update <org-id> <user-id>` | Update user properties |
|
|
161
|
+
| `porta user invite <org-id>` | Send a user invitation |
|
|
162
|
+
| `porta user activate <org-id> <user-id>` | Activate a user |
|
|
163
|
+
| `porta user suspend <org-id> <user-id>` | Suspend a user |
|
|
164
|
+
| `porta user archive <org-id> <user-id>` | Archive a user |
|
|
165
|
+
|
|
166
|
+
**Nested: Roles** (`porta user role ...`)
|
|
167
|
+
|
|
168
|
+
| Command | Description |
|
|
169
|
+
|---------|-------------|
|
|
170
|
+
| `porta user role list <org-id> <user-id>` | List user's role assignments |
|
|
171
|
+
| `porta user role assign <org-id> <user-id> <role-id>` | Assign a role to a user |
|
|
172
|
+
| `porta user role remove <org-id> <user-id> <role-id>` | Remove a role from a user |
|
|
173
|
+
|
|
174
|
+
**Nested: Claims** (`porta user claim ...`)
|
|
175
|
+
|
|
176
|
+
| Command | Description |
|
|
177
|
+
|---------|-------------|
|
|
178
|
+
| `porta user claim list <org-id> <user-id>` | List user's claim values |
|
|
179
|
+
| `porta user claim set <org-id> <user-id>` | Set a claim value |
|
|
180
|
+
| `porta user claim remove <org-id> <user-id> <claim-id>` | Remove a claim value |
|
|
181
|
+
|
|
182
|
+
### Infrastructure
|
|
183
|
+
|
|
184
|
+
| Command | Description |
|
|
185
|
+
|---------|-------------|
|
|
186
|
+
| `porta config list` | List system configuration |
|
|
187
|
+
| `porta config get <key>` | Get a configuration value |
|
|
188
|
+
| `porta config set <key> <value>` | Set a configuration value |
|
|
189
|
+
| `porta keys list` | List signing keys |
|
|
190
|
+
| `porta keys generate` | Generate a new signing key |
|
|
191
|
+
| `porta keys rotate` | Rotate the active signing key |
|
|
192
|
+
| `porta audit list` | View audit logs (with filters) |
|
|
193
|
+
| `porta sessions list` | List active sessions |
|
|
194
|
+
| `porta sessions revoke <session-id>` | Revoke a session |
|
|
195
|
+
| `porta stats` | Display dashboard statistics |
|
|
196
|
+
| `porta health` | Check server connectivity (no auth required) |
|
|
197
|
+
| `porta bulk <action>` | Bulk status operations on orgs/users |
|
|
198
|
+
| `porta exports <entity-type>` | Export data as CSV or JSON |
|
|
199
|
+
|
|
200
|
+
### Provisioning
|
|
201
|
+
|
|
202
|
+
| Command | Description |
|
|
203
|
+
|---------|-------------|
|
|
204
|
+
| `porta provision --file <path>` | Apply a declarative YAML/JSON environment file |
|
|
205
|
+
|
|
206
|
+
Supports `--mode merge|overwrite`, `--dry-run`, and `--json` flags.
|
|
207
|
+
|
|
208
|
+
### Utilities
|
|
209
|
+
|
|
210
|
+
| Command | Description |
|
|
211
|
+
|---------|-------------|
|
|
212
|
+
| `porta version` | Show CLI and SDK versions |
|
|
213
|
+
| `porta doctor` | Run diagnostic checks (connectivity, auth, server compatibility) |
|
|
214
|
+
| `porta completion` | Generate shell completion scripts (Bash, Zsh, Fish) |
|
|
215
|
+
|
|
216
|
+
## Authentication
|
|
217
|
+
|
|
218
|
+
The CLI authenticates using **OIDC Authorization Code + PKCE** — the same secure flow used by SPAs:
|
|
219
|
+
|
|
220
|
+
1. `porta login` opens your default browser to the Porta login page
|
|
221
|
+
2. You authenticate (password, magic link, or 2FA)
|
|
222
|
+
3. The CLI receives the authorization code via a temporary localhost callback
|
|
223
|
+
4. Tokens are exchanged and stored at `~/.porta/credentials.json` (file permissions `0600`)
|
|
224
|
+
|
|
225
|
+
**In Docker or headless environments**, the CLI auto-detects containerization and switches to manual mode — it prints the authorization URL for you to open and paste the callback URL back.
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Standard login (opens browser)
|
|
229
|
+
porta login --server https://porta.example.com
|
|
230
|
+
|
|
231
|
+
# Explicit headless mode
|
|
232
|
+
porta login --server https://porta.example.com --no-browser
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Declarative Provisioning
|
|
236
|
+
|
|
237
|
+
Set up entire environments from a single YAML file:
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
# provision.yaml
|
|
241
|
+
organizations:
|
|
242
|
+
- name: Acme Corp
|
|
243
|
+
slug: acme
|
|
244
|
+
status: active
|
|
245
|
+
applications:
|
|
246
|
+
- name: Web Portal
|
|
247
|
+
slug: web-portal
|
|
248
|
+
clients:
|
|
249
|
+
- name: web-app
|
|
250
|
+
grant_types: [authorization_code]
|
|
251
|
+
redirect_uris: [https://app.acme.com/callback]
|
|
252
|
+
roles:
|
|
253
|
+
- name: Admin
|
|
254
|
+
permissions: [read, write, delete]
|
|
255
|
+
- name: Viewer
|
|
256
|
+
permissions: [read]
|
|
257
|
+
users:
|
|
258
|
+
- email: admin@acme.com
|
|
259
|
+
given_name: Admin
|
|
260
|
+
family_name: User
|
|
261
|
+
roles: [Admin]
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Preview changes without applying
|
|
266
|
+
porta provision --file provision.yaml --dry-run
|
|
267
|
+
|
|
268
|
+
# Apply with merge mode (default)
|
|
269
|
+
porta provision --file provision.yaml
|
|
270
|
+
|
|
271
|
+
# Full overwrite mode
|
|
272
|
+
porta provision --file provision.yaml --mode overwrite
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## JSON Output
|
|
276
|
+
|
|
277
|
+
All commands support `--json` for machine-readable output, making it easy to integrate with scripts and CI pipelines:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Pipe to jq
|
|
281
|
+
porta org list --json | jq '.[].slug'
|
|
282
|
+
|
|
283
|
+
# Use in scripts
|
|
284
|
+
ORG_ID=$(porta org show my-org --json | jq -r '.id')
|
|
285
|
+
porta user list "$ORG_ID" --json
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Shell Completions
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# Bash
|
|
292
|
+
porta completion >> ~/.bashrc
|
|
293
|
+
|
|
294
|
+
# Zsh
|
|
295
|
+
porta completion >> ~/.zshrc
|
|
296
|
+
|
|
297
|
+
# Fish
|
|
298
|
+
porta completion > ~/.config/fish/completions/porta.fish
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Documentation
|
|
302
|
+
|
|
303
|
+
📖 **Full documentation:** [blendsdk.github.io/porta-identity](https://blendsdk.github.io/porta-identity/)
|
|
304
|
+
|
|
305
|
+
- [CLI Overview](https://blendsdk.github.io/porta-identity/cli/overview) — Architecture, installation, and authentication
|
|
306
|
+
- [CLI Commands Reference](https://blendsdk.github.io/porta-identity/cli/organizations) — Detailed command documentation
|
|
307
|
+
- [Provisioning Guide](https://blendsdk.github.io/porta-identity/cli/provisioning) — Declarative environment setup
|
|
308
|
+
- [Bootstrap Guide](https://blendsdk.github.io/porta-identity/cli/bootstrap) — Initial server setup with `porta init`
|
|
309
|
+
|
|
310
|
+
## Related Packages
|
|
311
|
+
|
|
312
|
+
| Package | Description |
|
|
313
|
+
|---------|-------------|
|
|
314
|
+
| [`@portaidentity/sdk`](https://www.npmjs.com/package/@portaidentity/sdk) | TypeScript SDK for the Porta Admin API |
|
|
315
|
+
| [`porta`](https://github.com/blendsdk/porta-identity) | Porta Identity Platform (OIDC server) |
|
|
316
|
+
|
|
317
|
+
## Requirements
|
|
318
|
+
|
|
319
|
+
- **Node.js** ≥ 22.0.0
|
|
320
|
+
- A running **Porta** server to connect to
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
MIT — See [LICENSE](../../LICENSE) for details.
|
|
@@ -17,7 +17,7 @@ import type { GlobalOptions } from '../global-options.js';
|
|
|
17
17
|
* CLI version — read from package.json at build time.
|
|
18
18
|
* This must be kept in sync with package.json version.
|
|
19
19
|
*/
|
|
20
|
-
export declare const CLI_VERSION = "
|
|
20
|
+
export declare const CLI_VERSION = "1.0.0";
|
|
21
21
|
/**
|
|
22
22
|
* The version command module — shows version info for CLI, SDK, and server.
|
|
23
23
|
*/
|
package/dist/commands/version.js
CHANGED
|
@@ -22,7 +22,7 @@ import { fetchHealthStatus } from '../auth/metadata.js';
|
|
|
22
22
|
* CLI version — read from package.json at build time.
|
|
23
23
|
* This must be kept in sync with package.json version.
|
|
24
24
|
*/
|
|
25
|
-
export const CLI_VERSION = '
|
|
25
|
+
export const CLI_VERSION = '1.0.0';
|
|
26
26
|
// ---------------------------------------------------------------------------
|
|
27
27
|
// Command Definition
|
|
28
28
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portaidentity/cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Standalone CLI for the Porta Identity Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
"typescript-eslint": "^8.59.2",
|
|
38
38
|
"vitest": "^4.0.0"
|
|
39
39
|
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/blendsdk/porta-identity.git",
|
|
43
|
+
"directory": "packages/porta-cli"
|
|
44
|
+
},
|
|
40
45
|
"publishConfig": {
|
|
41
46
|
"access": "public"
|
|
42
47
|
},
|