@continuoussecuritytooling/keycloak-reporter 0.6.0 → 0.8.0
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/.docs/realm-config.json +0 -0
- package/.eslintrc.cjs +4 -3
- package/.github/FUNDING.yml +2 -1
- package/.github/workflows/pipeline.yml +61 -16
- package/.github/workflows/release.yml +6 -6
- package/.prettierrc +2 -2
- package/CHANGELOG.md +92 -11
- package/Dockerfile +16 -2
- package/README.md +8 -4
- package/artifacthub-repo.yml +6 -0
- package/charts/keycloak-reporter/Chart.yaml +10 -4
- package/charts/keycloak-reporter/README.md +7 -16
- package/charts/keycloak-reporter/ci.values.yaml +13 -0
- package/charts/keycloak-reporter/templates/cronjob.yaml +4 -5
- package/charts/keycloak-reporter/templates/tests/test-connection.yaml +57 -0
- package/charts/keycloak-reporter/values.yaml +2 -1
- package/cli.ts +59 -87
- package/config/schema.json +6 -1
- package/dist/cli.js +38 -37
- package/dist/cli.js.map +1 -1
- package/dist/config/schema.json +6 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/client.js +7 -24
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/convert.js +0 -0
- package/dist/lib/convert.js.map +0 -0
- package/dist/lib/output.js +2 -2
- package/dist/lib/output.js.map +1 -1
- package/dist/lib/user.js +79 -44
- package/dist/lib/user.js.map +1 -1
- package/dist/src/commands.js +30 -0
- package/dist/src/commands.js.map +1 -0
- package/dist/src/config.js +0 -9
- package/dist/src/config.js.map +1 -1
- package/e2e/spec/clients.js +1 -1
- package/e2e/spec/config.js +25 -1
- package/e2e/spec/users.js +1 -1
- package/index.ts +2 -2
- package/keycloak-reporter-1.2.1.tgz +0 -0
- package/lib/client.ts +10 -37
- package/lib/output.ts +2 -2
- package/lib/user.ts +86 -49
- package/package.json +5 -4
- package/renovate.json +12 -5
- package/src/commands.ts +37 -0
- package/src/config.ts +6 -17
- package/dist/src/cli.js +0 -19
- package/dist/src/cli.js.map +0 -1
- package/src/cli.ts +0 -26
package/src/commands.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import KcAdminClient from '@keycloak/keycloak-admin-client';
|
|
2
|
+
import {
|
|
3
|
+
AuditClient,
|
|
4
|
+
AuditedClientRepresentation,
|
|
5
|
+
AuditedUserRepresentation,
|
|
6
|
+
} from '@continuoussecuritytooling/keycloak-auditor';
|
|
7
|
+
import { Options, createClient } from '../lib/client.js';
|
|
8
|
+
import { User, userListing, clientListing, Client } from '../lib/user.js';
|
|
9
|
+
|
|
10
|
+
function kcClient(options: Options): Promise<KcAdminClient | AuditClient> {
|
|
11
|
+
return createClient({
|
|
12
|
+
clientId: options.clientId,
|
|
13
|
+
clientSecret: options.clientSecret,
|
|
14
|
+
rootUrl: options.rootUrl,
|
|
15
|
+
useAuditingEndpoint: options.useAuditingEndpoint,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function listUsers(options: Options): Promise<Array<User | AuditedUserRepresentation>> {
|
|
20
|
+
const users = await userListing(await kcClient(options));
|
|
21
|
+
return new Promise((resolve) => resolve(users));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function listClients(options: Options): Promise<Array<Client | AuditedClientRepresentation>> {
|
|
25
|
+
const clients = await clientListing(await kcClient(options));
|
|
26
|
+
return new Promise((resolve) => resolve(clients));
|
|
27
|
+
}
|
|
28
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
29
|
+
export async function configTest(options: Options): Promise<any> {
|
|
30
|
+
try {
|
|
31
|
+
await userListing(await kcClient(options));
|
|
32
|
+
console.log(`Connection to ${options.rootUrl} was successfull`);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error(`Connection to ${options.rootUrl} was not: successfull`, e.response);
|
|
35
|
+
return Promise.reject(e.response.statusText);
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assoc, pick, mergeAll, mergeDeepRight } from 'ramda';
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
2
|
import path from 'path';
|
|
4
3
|
import { fileURLToPath } from 'url';
|
|
5
4
|
import fs from 'fs';
|
|
@@ -8,16 +7,15 @@ const schema = JSON.parse(
|
|
|
8
7
|
fs.readFileSync(fileURLToPath(path.join(import.meta.url, '../../config/schema.json')), 'utf8')
|
|
9
8
|
);
|
|
10
9
|
|
|
11
|
-
const ajv = new Ajv.default();
|
|
12
|
-
const ajvValidate = ajv.compile(schema);
|
|
13
|
-
|
|
14
10
|
// import the config file
|
|
15
11
|
function buildConfigFromFile(filePath) {
|
|
16
12
|
if (!filePath) return {};
|
|
17
13
|
const isAbsolutePath = filePath.charAt(0) === '/';
|
|
18
|
-
return JSON.parse(
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
return JSON.parse(
|
|
15
|
+
isAbsolutePath
|
|
16
|
+
? fs.readFileSync(filePath, 'utf8')
|
|
17
|
+
: fs.readFileSync(fileURLToPath(path.join(import.meta.url, '../config', filePath)), 'utf8')
|
|
18
|
+
);
|
|
21
19
|
}
|
|
22
20
|
// build an object using the defaults in the schema
|
|
23
21
|
function buildDefaults(schema, definitions) {
|
|
@@ -51,18 +49,9 @@ function buildEnvironmentVariablesConfig(schema) {
|
|
|
51
49
|
}, {});
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
function validate(data) {
|
|
55
|
-
const valid = ajvValidate(data);
|
|
56
|
-
if (valid) return true;
|
|
57
|
-
throw new Error(ajv.errorsText());
|
|
58
|
-
}
|
|
59
|
-
|
|
60
52
|
// merge the environment variables, config file values, and defaults
|
|
61
53
|
const config = mergeAll(
|
|
62
|
-
mergeDeepRight(
|
|
63
|
-
buildDefaults(schema, schema.definitions),
|
|
64
|
-
buildConfigFromFile(process.env.CONFIG_FILE)
|
|
65
|
-
),
|
|
54
|
+
mergeDeepRight(buildDefaults(schema, schema.definitions), buildConfigFromFile(process.env.CONFIG_FILE)),
|
|
66
55
|
buildEnvironmentVariablesConfig(schema)
|
|
67
56
|
);
|
|
68
57
|
|
package/dist/src/cli.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createClient } from '../lib/client.js';
|
|
2
|
-
import { userListing, clientListing } from '../lib/user.js';
|
|
3
|
-
export async function listUsers(options) {
|
|
4
|
-
const users = await userListing(await createClient({
|
|
5
|
-
clientId: options.clientId,
|
|
6
|
-
clientSecret: options.clientSecret,
|
|
7
|
-
rootUrl: options.rootUrl,
|
|
8
|
-
}));
|
|
9
|
-
return new Promise((resolve) => resolve(users));
|
|
10
|
-
}
|
|
11
|
-
export async function listClients(options) {
|
|
12
|
-
const clients = await clientListing(await createClient({
|
|
13
|
-
clientId: options.clientId,
|
|
14
|
-
clientSecret: options.clientSecret,
|
|
15
|
-
rootUrl: options.rootUrl,
|
|
16
|
-
}));
|
|
17
|
-
return new Promise((resolve) => resolve(clients));
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/src/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAQ,WAAW,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAE1E,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAgB;IAC9C,MAAM,KAAK,GAAG,MAAM,WAAW,CAC7B,MAAM,YAAY,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CACH,CAAC;IAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAgB;IAChD,MAAM,OAAO,GAAG,MAAM,aAAa,CACjC,MAAM,YAAY,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CACH,CAAC;IAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
package/src/cli.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Options, createClient } from '../lib/client.js';
|
|
2
|
-
import { User, userListing, clientListing, Client } from '../lib/user.js';
|
|
3
|
-
|
|
4
|
-
export async function listUsers(options: Options): Promise<Array<User>> {
|
|
5
|
-
const users = await userListing(
|
|
6
|
-
await createClient({
|
|
7
|
-
clientId: options.clientId,
|
|
8
|
-
clientSecret: options.clientSecret,
|
|
9
|
-
rootUrl: options.rootUrl,
|
|
10
|
-
})
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
return new Promise((resolve) => resolve(users));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function listClients(options: Options): Promise<Array<Client>> {
|
|
17
|
-
const clients = await clientListing(
|
|
18
|
-
await createClient({
|
|
19
|
-
clientId: options.clientId,
|
|
20
|
-
clientSecret: options.clientSecret,
|
|
21
|
-
rootUrl: options.rootUrl,
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
return new Promise((resolve) => resolve(clients));
|
|
26
|
-
}
|