@sasjs/api 0.18.1 → 0.19.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/build/browser.js +711 -14
- package/build/cjs/admin/service.js +209 -0
- package/build/cjs/authconfig/service.js +139 -0
- package/build/cjs/corpus/admin.js +101 -0
- package/build/cjs/corpus/authconfig.js +47 -0
- package/build/cjs/corpus/directory.js +31 -0
- package/build/cjs/corpus/runner.js +13 -0
- package/build/cjs/directory/service.js +116 -0
- package/build/cjs/host/dispatch.js +39 -0
- package/build/cjs/identity/memory-store.js +4 -1
- package/build/cjs/index.js +8 -2
- package/build/cjs/routes/generated.js +56 -0
- package/build/cjs/routes/overlay.js +86 -12
- package/build/esm/admin/service.d.ts +123 -0
- package/build/esm/admin/service.d.ts.map +1 -0
- package/build/esm/admin/service.js +201 -0
- package/build/esm/authconfig/service.d.ts +92 -0
- package/build/esm/authconfig/service.d.ts.map +1 -0
- package/build/esm/authconfig/service.js +134 -0
- package/build/esm/corpus/admin.d.ts +22 -0
- package/build/esm/corpus/admin.d.ts.map +1 -0
- package/build/esm/corpus/admin.js +98 -0
- package/build/esm/corpus/authconfig.d.ts +31 -0
- package/build/esm/corpus/authconfig.d.ts.map +1 -0
- package/build/esm/corpus/authconfig.js +44 -0
- package/build/esm/corpus/directory.d.ts +20 -0
- package/build/esm/corpus/directory.d.ts.map +1 -0
- package/build/esm/corpus/directory.js +28 -0
- package/build/esm/corpus/runner.d.ts.map +1 -1
- package/build/esm/corpus/runner.js +13 -0
- package/build/esm/directory/service.d.ts +71 -0
- package/build/esm/directory/service.d.ts.map +1 -0
- package/build/esm/directory/service.js +112 -0
- package/build/esm/host/dispatch.d.ts +18 -0
- package/build/esm/host/dispatch.d.ts.map +1 -1
- package/build/esm/host/dispatch.js +39 -0
- package/build/esm/identity/memory-store.d.ts.map +1 -1
- package/build/esm/identity/memory-store.js +4 -1
- package/build/esm/identity/types.d.ts +5 -0
- package/build/esm/identity/types.d.ts.map +1 -1
- package/build/esm/index.d.ts +3 -0
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +3 -0
- package/build/esm/routes/generated.d.ts.map +1 -1
- package/build/esm/routes/generated.js +56 -0
- package/build/esm/routes/overlay.d.ts.map +1 -1
- package/build/esm/routes/overlay.js +86 -12
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider configuration an administrator is allowed to read.
|
|
3
|
+
*
|
|
4
|
+
* `GET /SASjsApi/authConfig` exists so the administration interface can show
|
|
5
|
+
* which external providers a host was started with. The values are the host's
|
|
6
|
+
* environment; the decision this file owns is what may leave the process:
|
|
7
|
+
*
|
|
8
|
+
* - only providers that are enabled appear, so the interface cannot offer to
|
|
9
|
+
* edit a provider the host does not have;
|
|
10
|
+
* - a secret is never echoed - the answer carries `LDAP_BIND_PASSWORD_SET` and
|
|
11
|
+
* `OIDC_CLIENT_SECRET_SET` (whether one is configured) and not the value.
|
|
12
|
+
* sasjs/server reads the bind password and the client secret from the
|
|
13
|
+
* environment and reports only those booleans, because this response is
|
|
14
|
+
* rendered into the admin page, the browser's state, the cache and any
|
|
15
|
+
* proxy log in the path;
|
|
16
|
+
* - a host that hands this service something shaped like a secret is refused
|
|
17
|
+
* by name rather than served, so a host cannot leak one through the route by
|
|
18
|
+
* naming a field the interface happens to render.
|
|
19
|
+
*
|
|
20
|
+
* The keys are the environment's own names (`LDAP_URL`, `OIDC_CLIENT_SECRET_SET`)
|
|
21
|
+
* because that is what sasjs/server answers and what the admin page reads - a
|
|
22
|
+
* translation here would be a second contract.
|
|
23
|
+
*/
|
|
24
|
+
/** What a host passes for LDAP; the booleans stand in for the secrets. */
|
|
25
|
+
export interface LdapProviderConfig {
|
|
26
|
+
url: string;
|
|
27
|
+
bindDn: string;
|
|
28
|
+
usersBaseDn: string;
|
|
29
|
+
groupsBaseDn: string;
|
|
30
|
+
/** Whether a bind password is configured. The value itself must never be passed. */
|
|
31
|
+
bindPasswordSet: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface OidcProviderConfig {
|
|
34
|
+
providerName: string;
|
|
35
|
+
issuerUrl: string;
|
|
36
|
+
clientId: string;
|
|
37
|
+
redirectUri: string;
|
|
38
|
+
scope: string;
|
|
39
|
+
signingAlg: string;
|
|
40
|
+
usernameClaim: string;
|
|
41
|
+
/** The host passes the variable through, so it stays a string here. */
|
|
42
|
+
jitProvision: string;
|
|
43
|
+
/** Whether a client secret is configured. The value itself must never be passed. */
|
|
44
|
+
clientSecretSet: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface AuthConfig {
|
|
47
|
+
ldap?: LdapProviderConfig;
|
|
48
|
+
oidc?: OidcProviderConfig;
|
|
49
|
+
}
|
|
50
|
+
/** The body the route sends, with the environment's own key names. */
|
|
51
|
+
export interface AuthConfigResponse {
|
|
52
|
+
ldap?: {
|
|
53
|
+
LDAP_URL: string;
|
|
54
|
+
LDAP_BIND_DN: string;
|
|
55
|
+
LDAP_USERS_BASE_DN: string;
|
|
56
|
+
LDAP_GROUPS_BASE_DN: string;
|
|
57
|
+
LDAP_BIND_PASSWORD_SET: boolean;
|
|
58
|
+
};
|
|
59
|
+
oidc?: {
|
|
60
|
+
OIDC_PROVIDER_NAME: string;
|
|
61
|
+
OIDC_ISSUER_URL: string;
|
|
62
|
+
OIDC_CLIENT_ID: string;
|
|
63
|
+
OIDC_REDIRECT_URI: string;
|
|
64
|
+
OIDC_SCOPE: string;
|
|
65
|
+
OIDC_SIGNING_ALG: string;
|
|
66
|
+
OIDC_USERNAME_CLAIM: string;
|
|
67
|
+
OIDC_JIT_PROVISION: string;
|
|
68
|
+
OIDC_CLIENT_SECRET_SET: boolean;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface AuthConfigService {
|
|
72
|
+
authConfig(): Promise<AuthConfigResponse>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The configuration, checked and rendered in the document's key names.
|
|
76
|
+
*
|
|
77
|
+
* Refusals are `Error` rather than `ApiError`: a host that passes a secret, or a
|
|
78
|
+
* provider block with no fields, is misconfigured rather than answering a bad
|
|
79
|
+
* request, and a `500` carrying its own configuration problem would blame the
|
|
80
|
+
* caller.
|
|
81
|
+
*/
|
|
82
|
+
export declare const normaliseAuthConfig: (config: AuthConfig) => AuthConfigResponse;
|
|
83
|
+
/**
|
|
84
|
+
* The auth-config service, over the host's own environment.
|
|
85
|
+
*
|
|
86
|
+
* A getter is accepted because the values are read from the environment and a
|
|
87
|
+
* host can be reconfigured without a restart in some deployments; reading per
|
|
88
|
+
* request keeps the answer true. The values never leave the process - only the
|
|
89
|
+
* two `*_SET` booleans describe the secrets.
|
|
90
|
+
*/
|
|
91
|
+
export declare const createAuthConfigService: (config: AuthConfig | (() => AuthConfig)) => AuthConfigService;
|
|
92
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/authconfig/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,oFAAoF;IACpF,eAAe,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAA;IACpB,oFAAoF;IACpF,eAAe,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,kBAAkB,CAAA;IACzB,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAC1B;AAED,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE;QACL,QAAQ,EAAE,MAAM,CAAA;QAChB,YAAY,EAAE,MAAM,CAAA;QACpB,kBAAkB,EAAE,MAAM,CAAA;QAC1B,mBAAmB,EAAE,MAAM,CAAA;QAC3B,sBAAsB,EAAE,OAAO,CAAA;KAChC,CAAA;IACD,IAAI,CAAC,EAAE;QACL,kBAAkB,EAAE,MAAM,CAAA;QAC1B,eAAe,EAAE,MAAM,CAAA;QACvB,cAAc,EAAE,MAAM,CAAA;QACtB,iBAAiB,EAAE,MAAM,CAAA;QACzB,UAAU,EAAE,MAAM,CAAA;QAClB,gBAAgB,EAAE,MAAM,CAAA;QACxB,mBAAmB,EAAE,MAAM,CAAA;QAC3B,kBAAkB,EAAE,MAAM,CAAA;QAC1B,sBAAsB,EAAE,OAAO,CAAA;KAChC,CAAA;CACF;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAC1C;AAyED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,UAAU,KAAG,kBA4CxD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,KACtC,iBAQF,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider configuration an administrator is allowed to read.
|
|
3
|
+
*
|
|
4
|
+
* `GET /SASjsApi/authConfig` exists so the administration interface can show
|
|
5
|
+
* which external providers a host was started with. The values are the host's
|
|
6
|
+
* environment; the decision this file owns is what may leave the process:
|
|
7
|
+
*
|
|
8
|
+
* - only providers that are enabled appear, so the interface cannot offer to
|
|
9
|
+
* edit a provider the host does not have;
|
|
10
|
+
* - a secret is never echoed - the answer carries `LDAP_BIND_PASSWORD_SET` and
|
|
11
|
+
* `OIDC_CLIENT_SECRET_SET` (whether one is configured) and not the value.
|
|
12
|
+
* sasjs/server reads the bind password and the client secret from the
|
|
13
|
+
* environment and reports only those booleans, because this response is
|
|
14
|
+
* rendered into the admin page, the browser's state, the cache and any
|
|
15
|
+
* proxy log in the path;
|
|
16
|
+
* - a host that hands this service something shaped like a secret is refused
|
|
17
|
+
* by name rather than served, so a host cannot leak one through the route by
|
|
18
|
+
* naming a field the interface happens to render.
|
|
19
|
+
*
|
|
20
|
+
* The keys are the environment's own names (`LDAP_URL`, `OIDC_CLIENT_SECRET_SET`)
|
|
21
|
+
* because that is what sasjs/server answers and what the admin page reads - a
|
|
22
|
+
* translation here would be a second contract.
|
|
23
|
+
*/
|
|
24
|
+
/** The fields each provider block may carry, in the order the interface reads them. */
|
|
25
|
+
const LDAP_FIELDS = [
|
|
26
|
+
'url',
|
|
27
|
+
'bindDn',
|
|
28
|
+
'usersBaseDn',
|
|
29
|
+
'groupsBaseDn',
|
|
30
|
+
'bindPasswordSet'
|
|
31
|
+
];
|
|
32
|
+
const OIDC_FIELDS = [
|
|
33
|
+
'providerName',
|
|
34
|
+
'issuerUrl',
|
|
35
|
+
'clientId',
|
|
36
|
+
'redirectUri',
|
|
37
|
+
'scope',
|
|
38
|
+
'signingAlg',
|
|
39
|
+
'usernameClaim',
|
|
40
|
+
'jitProvision',
|
|
41
|
+
'clientSecretSet'
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Anything with one of these words in its name is a secret.
|
|
45
|
+
*
|
|
46
|
+
* The check is on the name rather than the value because the value is what a
|
|
47
|
+
* host would have to hand over, and a host that hands it over has already lost:
|
|
48
|
+
* this route is readable, logged and cached. `*Set` is the documented way to say
|
|
49
|
+
* that one exists.
|
|
50
|
+
*/
|
|
51
|
+
const SECRET = /(password|secret|passwd|token)/i;
|
|
52
|
+
const checkProvider = (name, block, fields, booleans) => {
|
|
53
|
+
if (!block || typeof block !== 'object')
|
|
54
|
+
throw new Error(`The auth configuration states \`${name}\` as ${JSON.stringify(block)}; a provider is an object, or absent when it is not enabled.`);
|
|
55
|
+
for (const key of Object.keys(block)) {
|
|
56
|
+
if (!fields.includes(key))
|
|
57
|
+
throw new Error(SECRET.test(key)
|
|
58
|
+
? `The auth configuration states \`${name}.${key}\`, which looks like a secret. Secrets are never echoed by this route: pass \`${key}Set: true\` instead, so the answer carries whether one is configured and not the value.`
|
|
59
|
+
: `The auth configuration carries \`${name}.${key}\`, which the document's example does not state. Remove it, or add it to the provider's fields here and to the document.`);
|
|
60
|
+
}
|
|
61
|
+
for (const key of fields) {
|
|
62
|
+
if (!(key in block))
|
|
63
|
+
throw new Error(`The auth configuration does not state \`${name}.${key}\`, which the administration interface reads. State the empty string when the host has no value for it.`);
|
|
64
|
+
const value = block[key];
|
|
65
|
+
if (booleans.includes(key)) {
|
|
66
|
+
if (typeof value !== 'boolean')
|
|
67
|
+
throw new Error(`The auth configuration states \`${name}.${key}\` as ${JSON.stringify(value)}; it says whether the secret is configured, so it is a boolean.`);
|
|
68
|
+
}
|
|
69
|
+
else if (typeof value !== 'string')
|
|
70
|
+
throw new Error(`The auth configuration states \`${name}.${key}\` as ${JSON.stringify(value)}; the document states a string.`);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The configuration, checked and rendered in the document's key names.
|
|
75
|
+
*
|
|
76
|
+
* Refusals are `Error` rather than `ApiError`: a host that passes a secret, or a
|
|
77
|
+
* provider block with no fields, is misconfigured rather than answering a bad
|
|
78
|
+
* request, and a `500` carrying its own configuration problem would blame the
|
|
79
|
+
* caller.
|
|
80
|
+
*/
|
|
81
|
+
export const normaliseAuthConfig = (config) => {
|
|
82
|
+
if (!config || typeof config !== 'object')
|
|
83
|
+
throw new Error('The auth configuration is not an object.');
|
|
84
|
+
for (const key of Object.keys(config))
|
|
85
|
+
if (key !== 'ldap' && key !== 'oidc')
|
|
86
|
+
throw new Error(SECRET.test(key)
|
|
87
|
+
? `The auth configuration states \`${key}\` at the top level, which looks like a secret. Secrets are never echoed by this route; put the provider under \`ldap\` or \`oidc\` and report whether the secret is set.`
|
|
88
|
+
: `The auth configuration carries \`${key}\`, which is not a provider this API has. The document states \`ldap\` and \`oidc\`.`);
|
|
89
|
+
const answer = {};
|
|
90
|
+
if (config.ldap !== undefined) {
|
|
91
|
+
checkProvider('ldap', config.ldap, LDAP_FIELDS, ['bindPasswordSet']);
|
|
92
|
+
answer.ldap = {
|
|
93
|
+
LDAP_URL: config.ldap.url,
|
|
94
|
+
LDAP_BIND_DN: config.ldap.bindDn,
|
|
95
|
+
LDAP_USERS_BASE_DN: config.ldap.usersBaseDn,
|
|
96
|
+
LDAP_GROUPS_BASE_DN: config.ldap.groupsBaseDn,
|
|
97
|
+
LDAP_BIND_PASSWORD_SET: config.ldap.bindPasswordSet
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (config.oidc !== undefined) {
|
|
101
|
+
checkProvider('oidc', config.oidc, OIDC_FIELDS, ['clientSecretSet']);
|
|
102
|
+
answer.oidc = {
|
|
103
|
+
OIDC_PROVIDER_NAME: config.oidc.providerName,
|
|
104
|
+
OIDC_ISSUER_URL: config.oidc.issuerUrl,
|
|
105
|
+
OIDC_CLIENT_ID: config.oidc.clientId,
|
|
106
|
+
OIDC_REDIRECT_URI: config.oidc.redirectUri,
|
|
107
|
+
OIDC_SCOPE: config.oidc.scope,
|
|
108
|
+
OIDC_SIGNING_ALG: config.oidc.signingAlg,
|
|
109
|
+
OIDC_USERNAME_CLAIM: config.oidc.usernameClaim,
|
|
110
|
+
OIDC_JIT_PROVISION: config.oidc.jitProvision,
|
|
111
|
+
OIDC_CLIENT_SECRET_SET: config.oidc.clientSecretSet
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// an empty object is the documented answer for a host with no external
|
|
115
|
+
// provider, so it is not an error: the login screen then offers only the
|
|
116
|
+
// local form
|
|
117
|
+
return answer;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The auth-config service, over the host's own environment.
|
|
121
|
+
*
|
|
122
|
+
* A getter is accepted because the values are read from the environment and a
|
|
123
|
+
* host can be reconfigured without a restart in some deployments; reading per
|
|
124
|
+
* request keeps the answer true. The values never leave the process - only the
|
|
125
|
+
* two `*_SET` booleans describe the secrets.
|
|
126
|
+
*/
|
|
127
|
+
export const createAuthConfigService = (config) => {
|
|
128
|
+
const read = () => (typeof config === 'function' ? config() : config);
|
|
129
|
+
return {
|
|
130
|
+
async authConfig() {
|
|
131
|
+
return normaliseAuthConfig(read());
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CorpusCase } from './drive.js';
|
|
2
|
+
import type { DiagnosticsResponse, LogFileInfo, LogTail } from '../admin/service.js';
|
|
3
|
+
/**
|
|
4
|
+
* The host reports the corpus answers with.
|
|
5
|
+
*
|
|
6
|
+
* One log file, a diagnostics body with every block the document states, and a
|
|
7
|
+
* tail for that one file. Deterministic, so a case can pin an exact body; a real
|
|
8
|
+
* host's numbers differ, which is why the server's own suite runs the same
|
|
9
|
+
* cases against its API rather than this fixture.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CORPUS_LOG: LogFileInfo;
|
|
12
|
+
export declare const CORPUS_LOG_TAIL: LogTail;
|
|
13
|
+
export declare const CORPUS_DIAGNOSTICS: DiagnosticsResponse;
|
|
14
|
+
/**
|
|
15
|
+
* The admin corpus: one case per documented status of each route.
|
|
16
|
+
*
|
|
17
|
+
* `401` and `500` are host-only (the administrator middleware and the host's own
|
|
18
|
+
* failures), so they are not cases; what is pinned is the body, the traversal
|
|
19
|
+
* refusal the package owns, and the `404` for a name the folder does not hold.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ADMIN_CORPUS: CorpusCase[];
|
|
22
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../src/corpus/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,OAAO,EACR,MAAM,qBAAqB,CAAA;AAE5B;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,EAAE,WAIxB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAM7B,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,mBAiChC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,UAAU,EAqCpC,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host reports the corpus answers with.
|
|
3
|
+
*
|
|
4
|
+
* One log file, a diagnostics body with every block the document states, and a
|
|
5
|
+
* tail for that one file. Deterministic, so a case can pin an exact body; a real
|
|
6
|
+
* host's numbers differ, which is why the server's own suite runs the same
|
|
7
|
+
* cases against its API rather than this fixture.
|
|
8
|
+
*/
|
|
9
|
+
export const CORPUS_LOG = {
|
|
10
|
+
name: '20260101000000.log',
|
|
11
|
+
sizeBytes: 118,
|
|
12
|
+
modified: '2026-01-01T00:00:00.000Z'
|
|
13
|
+
};
|
|
14
|
+
export const CORPUS_LOG_TAIL = {
|
|
15
|
+
fileName: CORPUS_LOG.name,
|
|
16
|
+
lines: 1,
|
|
17
|
+
bytesRead: 118,
|
|
18
|
+
truncated: false,
|
|
19
|
+
content: 'GET /SASjsApi/info HTTP/1.1 200 118'
|
|
20
|
+
};
|
|
21
|
+
export const CORPUS_DIAGNOSTICS = {
|
|
22
|
+
build: { version: 'v4.16.2', gitHash: 'cda6114', buildDate: null },
|
|
23
|
+
server: {
|
|
24
|
+
mode: 'desktop',
|
|
25
|
+
uptimeSeconds: 3600,
|
|
26
|
+
startedAt: '2026-01-01T00:00:00.000Z',
|
|
27
|
+
pid: 4242,
|
|
28
|
+
nodeVersion: 'v22.11.0',
|
|
29
|
+
platform: 'linux 5.14.0',
|
|
30
|
+
arch: 'x64',
|
|
31
|
+
cpuCount: 8,
|
|
32
|
+
cpuModel: 'Intel(R) Xeon(R) CPU',
|
|
33
|
+
loadAverage: [0.08, 0.11, 0.15],
|
|
34
|
+
runTimes: ['js'],
|
|
35
|
+
sasjsRoot: '/sasjs_root'
|
|
36
|
+
},
|
|
37
|
+
memory: {
|
|
38
|
+
rssBytes: 1,
|
|
39
|
+
heapTotalBytes: 2,
|
|
40
|
+
heapUsedBytes: 3,
|
|
41
|
+
externalBytes: 4,
|
|
42
|
+
systemTotalBytes: 5,
|
|
43
|
+
systemFreeBytes: 6
|
|
44
|
+
},
|
|
45
|
+
filesystem: null,
|
|
46
|
+
folders: [],
|
|
47
|
+
logs: {
|
|
48
|
+
folder: '/sasjs_root/logs',
|
|
49
|
+
fileCount: 1,
|
|
50
|
+
totalBytes: 118,
|
|
51
|
+
newestFile: CORPUS_LOG.name,
|
|
52
|
+
newestModified: CORPUS_LOG.modified
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The admin corpus: one case per documented status of each route.
|
|
57
|
+
*
|
|
58
|
+
* `401` and `500` are host-only (the administrator middleware and the host's own
|
|
59
|
+
* failures), so they are not cases; what is pinned is the body, the traversal
|
|
60
|
+
* refusal the package owns, and the `404` for a name the folder does not hold.
|
|
61
|
+
*/
|
|
62
|
+
export const ADMIN_CORPUS = [
|
|
63
|
+
{
|
|
64
|
+
id: 'admin-diagnostics-answers-the-report',
|
|
65
|
+
route: 'GET /SASjsApi/admin/diagnostics',
|
|
66
|
+
description: 'answers the host diagnostics report field for field',
|
|
67
|
+
request: {},
|
|
68
|
+
expect: { status: 200, body: CORPUS_DIAGNOSTICS }
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'admin-logs-lists-the-files',
|
|
72
|
+
route: 'GET /SASjsApi/admin/logs',
|
|
73
|
+
description: 'answers the log files the host holds, newest first',
|
|
74
|
+
request: {},
|
|
75
|
+
expect: { status: 200, body: { files: [CORPUS_LOG] } }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'admin-log-tail-answers-the-tail',
|
|
79
|
+
route: 'GET /SASjsApi/admin/logs/{fileName}',
|
|
80
|
+
description: 'answers the tail of a log the folder holds',
|
|
81
|
+
request: { params: { fileName: CORPUS_LOG.name } },
|
|
82
|
+
expect: { status: 200, body: CORPUS_LOG_TAIL }
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'admin-log-tail-refuses-a-traversal',
|
|
86
|
+
route: 'GET /SASjsApi/admin/logs/{fileName}',
|
|
87
|
+
description: 'refuses a name that could resolve outside the log folder, before the host is asked',
|
|
88
|
+
request: { params: { fileName: '../20260101000000.log' } },
|
|
89
|
+
expect: { status: 400, error: 'Invalid log file name.' }
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'admin-log-tail-answers-404',
|
|
93
|
+
route: 'GET /SASjsApi/admin/logs/{fileName}',
|
|
94
|
+
description: 'answers 404 for a name the folder does not hold',
|
|
95
|
+
request: { params: { fileName: '20250101000000.log' } },
|
|
96
|
+
expect: { status: 404, error: 'Log file not found.' }
|
|
97
|
+
}
|
|
98
|
+
];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CorpusCase } from './drive.js';
|
|
2
|
+
import type { AuthConfig } from '../authconfig/service.js';
|
|
3
|
+
/**
|
|
4
|
+
* The provider configuration the corpus host states.
|
|
5
|
+
*
|
|
6
|
+
* A fixture rather than a value read from anywhere: the case asserts that the
|
|
7
|
+
* route answers what the host holds, with the secrets reported as the two `*Set`
|
|
8
|
+
* booleans and never as values.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CORPUS_AUTH_CONFIG: AuthConfig;
|
|
11
|
+
/** The body that fixture must answer with, environment key names and all. */
|
|
12
|
+
export declare const CORPUS_AUTH_CONFIG_BODY: {
|
|
13
|
+
ldap: {
|
|
14
|
+
LDAP_URL: string;
|
|
15
|
+
LDAP_BIND_DN: string;
|
|
16
|
+
LDAP_USERS_BASE_DN: string;
|
|
17
|
+
LDAP_GROUPS_BASE_DN: string;
|
|
18
|
+
LDAP_BIND_PASSWORD_SET: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The auth-config corpus.
|
|
23
|
+
*
|
|
24
|
+
* The document states one status for this route - `200` - because the
|
|
25
|
+
* administrator check is the host's mount point, and the overlay marks the `401`
|
|
26
|
+
* and `500` it answers as host-only. What is pinned here is the body: the
|
|
27
|
+
* environment's key names, the secret as a boolean, and no provider the host
|
|
28
|
+
* did not enable.
|
|
29
|
+
*/
|
|
30
|
+
export declare const AUTH_CONFIG_CORPUS: CorpusCase[];
|
|
31
|
+
//# sourceMappingURL=authconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authconfig.d.ts","sourceRoot":"","sources":["../../../src/corpus/authconfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAQhC,CAAA;AAED,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB;;;;;;;;CAQnC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,EAS1C,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider configuration the corpus host states.
|
|
3
|
+
*
|
|
4
|
+
* A fixture rather than a value read from anywhere: the case asserts that the
|
|
5
|
+
* route answers what the host holds, with the secrets reported as the two `*Set`
|
|
6
|
+
* booleans and never as values.
|
|
7
|
+
*/
|
|
8
|
+
export const CORPUS_AUTH_CONFIG = {
|
|
9
|
+
ldap: {
|
|
10
|
+
url: 'ldaps://directory.example:636',
|
|
11
|
+
bindDn: 'cn=admin,dc=example',
|
|
12
|
+
usersBaseDn: 'ou=users,dc=example',
|
|
13
|
+
groupsBaseDn: 'ou=groups,dc=example',
|
|
14
|
+
bindPasswordSet: true
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/** The body that fixture must answer with, environment key names and all. */
|
|
18
|
+
export const CORPUS_AUTH_CONFIG_BODY = {
|
|
19
|
+
ldap: {
|
|
20
|
+
LDAP_URL: 'ldaps://directory.example:636',
|
|
21
|
+
LDAP_BIND_DN: 'cn=admin,dc=example',
|
|
22
|
+
LDAP_USERS_BASE_DN: 'ou=users,dc=example',
|
|
23
|
+
LDAP_GROUPS_BASE_DN: 'ou=groups,dc=example',
|
|
24
|
+
LDAP_BIND_PASSWORD_SET: true
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The auth-config corpus.
|
|
29
|
+
*
|
|
30
|
+
* The document states one status for this route - `200` - because the
|
|
31
|
+
* administrator check is the host's mount point, and the overlay marks the `401`
|
|
32
|
+
* and `500` it answers as host-only. What is pinned here is the body: the
|
|
33
|
+
* environment's key names, the secret as a boolean, and no provider the host
|
|
34
|
+
* did not enable.
|
|
35
|
+
*/
|
|
36
|
+
export const AUTH_CONFIG_CORPUS = [
|
|
37
|
+
{
|
|
38
|
+
id: 'authconfig-answers-the-enabled-provider',
|
|
39
|
+
route: 'GET /SASjsApi/authConfig',
|
|
40
|
+
description: 'answers the enabled provider with the secret reported as a boolean, never as a value',
|
|
41
|
+
request: {},
|
|
42
|
+
expect: { status: 200, body: CORPUS_AUTH_CONFIG_BODY }
|
|
43
|
+
}
|
|
44
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CorpusCase } from './drive.js';
|
|
2
|
+
import type { DirectorySource } from '../directory/service.js';
|
|
3
|
+
/**
|
|
4
|
+
* The directory the corpus host answers with.
|
|
5
|
+
*
|
|
6
|
+
* One user and one group that the default identity fixture does not already
|
|
7
|
+
* hold (`admin`/`user2` and `Admins`/`DCGroup` are in it), so the case pins the
|
|
8
|
+
* counts of what an import creates rather than what it found.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CORPUS_DIRECTORY: DirectorySource;
|
|
11
|
+
/**
|
|
12
|
+
* The directory corpus.
|
|
13
|
+
*
|
|
14
|
+
* `401` and `500` are host-only - the administrator middleware and the
|
|
15
|
+
* directory's own failures - so the one documented status this package answers
|
|
16
|
+
* is `200`, carrying what it created. The import's own rules (existing accounts
|
|
17
|
+
* untouched, membership, refusals) are pinned in `spec/directory.spec`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DIRECTORY_CORPUS: CorpusCase[];
|
|
20
|
+
//# sourceMappingURL=directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../../src/corpus/directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAG9B,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,UAAU,EASxC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directory the corpus host answers with.
|
|
3
|
+
*
|
|
4
|
+
* One user and one group that the default identity fixture does not already
|
|
5
|
+
* hold (`admin`/`user2` and `Admins`/`DCGroup` are in it), so the case pins the
|
|
6
|
+
* counts of what an import creates rather than what it found.
|
|
7
|
+
*/
|
|
8
|
+
export const CORPUS_DIRECTORY = {
|
|
9
|
+
users: async () => [{ username: 'alice', displayName: 'Alice' }],
|
|
10
|
+
groups: async () => [{ name: 'analysts' }]
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The directory corpus.
|
|
14
|
+
*
|
|
15
|
+
* `401` and `500` are host-only - the administrator middleware and the
|
|
16
|
+
* directory's own failures - so the one documented status this package answers
|
|
17
|
+
* is `200`, carrying what it created. The import's own rules (existing accounts
|
|
18
|
+
* untouched, membership, refusals) are pinned in `spec/directory.spec`.
|
|
19
|
+
*/
|
|
20
|
+
export const DIRECTORY_CORPUS = [
|
|
21
|
+
{
|
|
22
|
+
id: 'directory-imports-the-missing-accounts',
|
|
23
|
+
route: 'POST /SASjsApi/authConfig/synchroniseWithLDAP',
|
|
24
|
+
description: 'imports the users and groups the store does not hold, and counts them',
|
|
25
|
+
request: {},
|
|
26
|
+
expect: { status: 200, body: { userCount: 1, groupCount: 1 } }
|
|
27
|
+
}
|
|
28
|
+
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/corpus/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/corpus/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAoBnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC9B,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,UAAU,KAAG,QAyClD,CAAA;AA2BD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAClB,UAAU,UAAU,EACpB,WAAU,QAAgC,KACzC,OAAO,CAAC,UAAU,CAepB,CAAA"}
|
|
@@ -8,6 +8,12 @@ import { createSessionService } from '../session/service.js';
|
|
|
8
8
|
import { createRuntimeService } from '../runtime/service.js';
|
|
9
9
|
import { MemorySessionRunner } from '../runtime/memory-runner.js';
|
|
10
10
|
import { BROWSER_INFO, createInfoService } from '../info/service.js';
|
|
11
|
+
import { createAuthConfigService } from '../authconfig/service.js';
|
|
12
|
+
import { createAdminService } from '../admin/service.js';
|
|
13
|
+
import { createDirectoryService } from '../directory/service.js';
|
|
14
|
+
import { CORPUS_AUTH_CONFIG } from './authconfig.js';
|
|
15
|
+
import { CORPUS_DIAGNOSTICS, CORPUS_LOG, CORPUS_LOG_TAIL } from './admin.js';
|
|
16
|
+
import { CORPUS_DIRECTORY } from './directory.js';
|
|
11
17
|
import { MemoryIdentityStore } from '../identity/memory-store.js';
|
|
12
18
|
import { DEFAULT_IDENTITY } from '../identity/fixture.js';
|
|
13
19
|
import { isApiError } from '../types.js';
|
|
@@ -36,6 +42,13 @@ export const servicesFor = (testCase) => {
|
|
|
36
42
|
? new RefusingDriveStore(testCase.seed || {})
|
|
37
43
|
: new MemoryDriveStore(testCase.seed || {})),
|
|
38
44
|
info: createInfoService(BROWSER_INFO),
|
|
45
|
+
authConfig: createAuthConfigService(CORPUS_AUTH_CONFIG),
|
|
46
|
+
admin: createAdminService({
|
|
47
|
+
diagnostics: async () => CORPUS_DIAGNOSTICS,
|
|
48
|
+
logs: async () => [CORPUS_LOG],
|
|
49
|
+
logTail: async (fileName) => fileName === CORPUS_LOG.name ? CORPUS_LOG_TAIL : undefined
|
|
50
|
+
}),
|
|
51
|
+
directory: createDirectoryService(identity, CORPUS_DIRECTORY),
|
|
39
52
|
identity: createIdentityService(identity),
|
|
40
53
|
records: createRecordService(identity),
|
|
41
54
|
registry: new MemoryAppStreamRegistry(),
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directory import: what a host's LDAP answer means for its records.
|
|
3
|
+
*
|
|
4
|
+
* `POST /SASjsApi/authConfig/synchroniseWithLDAP` asks a host to pull its
|
|
5
|
+
* directory into the accounts the API knows. The directory connection is the
|
|
6
|
+
* host's - an LDAP client, a bind, a set of base DNs - and this file cannot
|
|
7
|
+
* have one. What it owns is the import:
|
|
8
|
+
*
|
|
9
|
+
* - a user or group that already exists is left untouched, matched by the
|
|
10
|
+
* name the API keys on (`username`, group `name`), which is what the
|
|
11
|
+
* document states and what makes the call repeatable: a second run imports
|
|
12
|
+
* nothing rather than duplicating the directory;
|
|
13
|
+
* - what it creates is marked with the provider (`ldap` by default), so a
|
|
14
|
+
* host can tell a directory-managed account from a local one - including
|
|
15
|
+
* the groups, which is why `NewGroup` carries the field;
|
|
16
|
+
* - membership travels both ways in a directory answer (a group lists its
|
|
17
|
+
* members, and a user lists its groups), so both are read and the union is
|
|
18
|
+
* applied to the groups this call created. An existing group is not
|
|
19
|
+
* touched: importing is not reconciling, and a caller who expects a
|
|
20
|
+
* deprovisioning sync has asked for a different operation;
|
|
21
|
+
* - a directory answer that names the same username twice, or a user with no
|
|
22
|
+
* username, is refused rather than half-imported.
|
|
23
|
+
*
|
|
24
|
+
* sasjs/server's own implementation deletes every provider-managed account and
|
|
25
|
+
* re-imports; that is its store's policy and it is deliberately not generalised
|
|
26
|
+
* here. The document's description - "Users and groups that already exist are
|
|
27
|
+
* left untouched" - is what this service implements.
|
|
28
|
+
*/
|
|
29
|
+
import type { IdentityStore } from '../identity/types.js';
|
|
30
|
+
export interface DirectoryUser {
|
|
31
|
+
username: string;
|
|
32
|
+
displayName: string;
|
|
33
|
+
/** Groups the directory says this user belongs to, by group name. */
|
|
34
|
+
groups?: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface DirectoryGroup {
|
|
37
|
+
name: string;
|
|
38
|
+
/** Members the directory says this group holds, by username. */
|
|
39
|
+
members?: string[];
|
|
40
|
+
}
|
|
41
|
+
/** One look at the directory, as the host read it. */
|
|
42
|
+
export interface DirectorySource {
|
|
43
|
+
users(): Promise<DirectoryUser[]>;
|
|
44
|
+
groups(): Promise<DirectoryGroup[]>;
|
|
45
|
+
}
|
|
46
|
+
export interface DirectorySyncResult {
|
|
47
|
+
/** How many accounts this call created; existing ones are not counted. */
|
|
48
|
+
userCount: number;
|
|
49
|
+
/** How many groups this call created. */
|
|
50
|
+
groupCount: number;
|
|
51
|
+
}
|
|
52
|
+
export interface DirectoryService {
|
|
53
|
+
synchronise(): Promise<DirectorySyncResult>;
|
|
54
|
+
}
|
|
55
|
+
export interface DirectoryServiceOptions {
|
|
56
|
+
/**
|
|
57
|
+
* The `authProvider` stamped on what the import creates. `ldap` is the
|
|
58
|
+
* provider this route names; a host with a second directory can state its own.
|
|
59
|
+
*/
|
|
60
|
+
provider?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The import, over the host's store.
|
|
64
|
+
*
|
|
65
|
+
* `IdentityStore` is the port rather than `RecordService`, because the records
|
|
66
|
+
* routes require a password (a local account has one to set) and a
|
|
67
|
+
* provider-managed account does not: the host's directory is where it
|
|
68
|
+
* authenticates, and `passwordMatches` answers for it.
|
|
69
|
+
*/
|
|
70
|
+
export declare const createDirectoryService: (store: IdentityStore, source: DirectorySource, options?: DirectoryServiceOptions) => DirectoryService;
|
|
71
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/directory/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAEV,aAAa,EAEd,MAAM,sBAAsB,CAAA;AAE7B,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,KAAK,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;IACjC,MAAM,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAA;IACjB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAC5C;AAED,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AA4DD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,EACpB,QAAQ,eAAe,EACvB,UAAS,uBAA4B,KACpC,gBAsFF,CAAA"}
|