-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
81 lines (79 loc) · 2.1 KB
/
cli.ts
File metadata and controls
81 lines (79 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env node
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
import { convert } from './lib/report.js';
import { getConvertConfig, getKeycloakConfig } from './lib/utils.js';
import { configTest, listUsers, listClients } from './index.js';
import config from './src/config.js';
yargs(hideBin(process.argv))
.env()
.command(
'listUsers [url] [clientId] [clientSecret]',
'fetches all users in the realms.',
() => {},
async (argv) => {
const users = await listUsers(getKeycloakConfig(config, argv));
convert(getConvertConfig(config, argv, 'user_listing', 'User Listing', users));
}
)
.command(
'listClients [url] [clientId] [clientSecret]',
'fetches all clients in the realms.',
() => {},
async (argv) => {
const clients = await listClients(getKeycloakConfig(config, argv));
convert(getConvertConfig(config, argv, 'client_listing', 'Client Listing', clients));
}
)
.option('format', {
alias: 'f',
type: 'string',
default: 'json',
description: 'output format, e.g. JSON|CSV',
})
.option('output', {
alias: 'o',
type: 'string',
default: 'stdout',
description: 'output channel',
})
.option('webhookType', {
alias: 'w',
type: 'string',
default: 'slack',
description: 'Webhook Type',
})
.option('webhookMessage', {
alias: 'm',
type: 'string',
description: 'Webhook Message',
})
.option('webhookUrl', {
alias: 't',
type: 'string',
description: 'Webhook URL',
})
.option('reports', {
alias: 'r',
type: 'string',
description: 'Reports directory',
})
.option('useAuditingEndpoint', {
alias: 'a',
type: 'boolean',
default: false,
description: 'use auditor rest endpoint',
})
.option('jsonLogFormat', {
alias: 'a',
type: 'boolean',
default: false,
description: 'use JSON log format',
})
.command(
'configTest [url] [clientId] [clientSecret]',
'validates keycloak configuration by reading data via REST API',
() => {},
async (argv) => configTest(getKeycloakConfig(config, argv))
)
.parse();