auth0-deploy-cli 7.6.0 → 7.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/.eslintrc +7 -41
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +3 -1
- package/.prettierignore +10 -0
- package/.prettierrc.json +4 -0
- package/CHANGELOG.md +222 -7
- package/CONTRIBUTING.md +2 -2
- package/README.md +3 -0
- package/lib/args.d.ts +29 -0
- package/lib/args.js +16 -15
- package/lib/commands/export.d.ts +2 -0
- package/lib/commands/export.js +3 -3
- package/lib/commands/import.d.ts +2 -0
- package/lib/commands/import.js +6 -6
- package/lib/commands/index.d.ts +9 -0
- package/lib/commands/index.js +1 -1
- package/lib/configFactory.d.ts +7 -0
- package/lib/configFactory.js +5 -1
- package/lib/context/defaults.d.ts +1 -0
- package/lib/context/defaults.js +4 -3
- package/lib/context/directory/handlers/actions.d.ts +6 -0
- package/lib/context/directory/handlers/actions.js +3 -3
- package/lib/context/directory/handlers/attackProtection.d.ts +10 -0
- package/lib/context/directory/handlers/attackProtection.js +7 -7
- package/lib/context/directory/handlers/branding.d.ts +6 -0
- package/lib/context/directory/handlers/branding.js +6 -5
- package/lib/context/directory/handlers/clientGrants.d.ts +6 -0
- package/lib/context/directory/handlers/clientGrants.js +3 -2
- package/lib/context/directory/handlers/clients.d.ts +6 -0
- package/lib/context/directory/handlers/clients.js +1 -1
- package/lib/context/directory/handlers/connections.d.ts +6 -0
- package/lib/context/directory/handlers/connections.js +4 -2
- package/lib/context/directory/handlers/databases.d.ts +6 -0
- package/lib/context/directory/handlers/databases.js +13 -7
- package/lib/context/directory/handlers/emailProvider.d.ts +6 -0
- package/lib/context/directory/handlers/emailProvider.js +3 -2
- package/lib/context/directory/handlers/emailTemplates.d.ts +6 -0
- package/lib/context/directory/handlers/emailTemplates.js +2 -2
- package/lib/context/directory/handlers/guardianFactorProviders.d.ts +6 -0
- package/lib/context/directory/handlers/guardianFactorProviders.js +3 -2
- package/lib/context/directory/handlers/guardianFactorTemplates.d.ts +6 -0
- package/lib/context/directory/handlers/guardianFactorTemplates.js +3 -2
- package/lib/context/directory/handlers/guardianFactors.d.ts +6 -0
- package/lib/context/directory/handlers/guardianFactors.js +3 -2
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.d.ts +6 -0
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +1 -1
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.d.ts +6 -0
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
- package/lib/context/directory/handlers/guardianPolicies.d.ts +6 -0
- package/lib/context/directory/handlers/guardianPolicies.js +1 -1
- package/lib/context/directory/handlers/hooks.d.ts +6 -0
- package/lib/context/directory/handlers/hooks.js +2 -2
- package/lib/context/directory/handlers/index.d.ts +12 -0
- package/lib/context/directory/handlers/index.js +3 -2
- package/lib/context/directory/handlers/migrations.d.ts +6 -0
- package/lib/context/directory/handlers/organizations.d.ts +6 -0
- package/lib/context/directory/handlers/organizations.js +1 -1
- package/lib/context/directory/handlers/pages.d.ts +6 -0
- package/lib/context/directory/handlers/pages.js +2 -2
- package/lib/context/directory/handlers/resourceServers.d.ts +6 -0
- package/lib/context/directory/handlers/resourceServers.js +3 -2
- package/lib/context/directory/handlers/roles.d.ts +6 -0
- package/lib/context/directory/handlers/roles.js +1 -1
- package/lib/context/directory/handlers/rules.d.ts +6 -0
- package/lib/context/directory/handlers/rules.js +2 -2
- package/lib/context/directory/handlers/rulesConfigs.d.ts +6 -0
- package/lib/context/directory/handlers/rulesConfigs.js +3 -2
- package/lib/context/directory/handlers/tenant.d.ts +10 -0
- package/lib/context/directory/handlers/tenant.js +3 -2
- package/lib/context/directory/handlers/triggers.d.ts +6 -0
- package/lib/context/directory/index.d.ts +17 -0
- package/lib/context/directory/index.js +21 -18
- package/lib/context/index.d.ts +4 -0
- package/lib/context/index.js +83 -61
- package/lib/context/yaml/handlers/actions.d.ts +6 -0
- package/lib/context/yaml/handlers/actions.js +9 -6
- package/lib/context/yaml/handlers/attackProtection.d.ts +6 -0
- package/lib/context/yaml/handlers/attackProtection.js +1 -1
- package/lib/context/yaml/handlers/branding.d.ts +6 -0
- package/lib/context/yaml/handlers/branding.js +5 -4
- package/lib/context/yaml/handlers/clientGrants.d.ts +6 -0
- package/lib/context/yaml/handlers/clientGrants.js +2 -2
- package/lib/context/yaml/handlers/clients.d.ts +6 -0
- package/lib/context/yaml/handlers/clients.js +6 -4
- package/lib/context/yaml/handlers/connections.d.ts +6 -0
- package/lib/context/yaml/handlers/connections.js +7 -5
- package/lib/context/yaml/handlers/databases.d.ts +6 -0
- package/lib/context/yaml/handlers/databases.js +12 -8
- package/lib/context/yaml/handlers/emailProvider.d.ts +6 -0
- package/lib/context/yaml/handlers/emailProvider.js +4 -3
- package/lib/context/yaml/handlers/emailTemplates.d.ts +6 -0
- package/lib/context/yaml/handlers/emailTemplates.js +3 -3
- package/lib/context/yaml/handlers/guardianFactorProviders.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianFactorProviders.js +1 -1
- package/lib/context/yaml/handlers/guardianFactorTemplates.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +1 -1
- package/lib/context/yaml/handlers/guardianFactors.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianFactors.js +1 -1
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +1 -1
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +1 -1
- package/lib/context/yaml/handlers/guardianPolicies.d.ts +6 -0
- package/lib/context/yaml/handlers/guardianPolicies.js +1 -1
- package/lib/context/yaml/handlers/hooks.d.ts +6 -0
- package/lib/context/yaml/handlers/hooks.js +4 -3
- package/lib/context/yaml/handlers/index.d.ts +12 -0
- package/lib/context/yaml/handlers/index.js +3 -2
- package/lib/context/yaml/handlers/migrations.d.ts +6 -0
- package/lib/context/yaml/handlers/organizations.d.ts +6 -0
- package/lib/context/yaml/handlers/organizations.js +3 -3
- package/lib/context/yaml/handlers/pages.d.ts +6 -0
- package/lib/context/yaml/handlers/pages.js +3 -3
- package/lib/context/yaml/handlers/resourceServers.d.ts +6 -0
- package/lib/context/yaml/handlers/resourceServers.js +2 -2
- package/lib/context/yaml/handlers/roles.d.ts +6 -0
- package/lib/context/yaml/handlers/roles.js +3 -3
- package/lib/context/yaml/handlers/rules.d.ts +6 -0
- package/lib/context/yaml/handlers/rules.js +3 -3
- package/lib/context/yaml/handlers/rulesConfigs.d.ts +6 -0
- package/lib/context/yaml/handlers/rulesConfigs.js +2 -2
- package/lib/context/yaml/handlers/tenant.d.ts +6 -0
- package/lib/context/yaml/handlers/tenant.js +4 -3
- package/lib/context/yaml/handlers/triggers.d.ts +6 -0
- package/lib/context/yaml/handlers/triggers.js +2 -2
- package/lib/context/yaml/index.d.ts +13 -0
- package/lib/context/yaml/index.js +31 -23
- package/lib/index.d.ts +88 -0
- package/lib/index.js +25 -17
- package/lib/logger.d.ts +2 -0
- package/lib/logger.js +8 -17
- package/lib/readonly.d.ts +2 -0
- package/lib/readonly.js +11 -16
- package/lib/sessionDurationsToMinutes.d.ts +7 -0
- package/lib/sessionDurationsToMinutes.js +15 -0
- package/lib/tools/auth0/client.d.ts +2 -0
- package/lib/tools/auth0/client.js +12 -12
- package/lib/tools/auth0/handlers/actions.d.ts +95 -0
- package/lib/tools/auth0/handlers/actions.js +22 -24
- package/lib/tools/auth0/handlers/attackProtection.d.ts +28 -0
- package/lib/tools/auth0/handlers/attackProtection.js +14 -17
- package/lib/tools/auth0/handlers/branding.d.ts +27 -0
- package/lib/tools/auth0/handlers/branding.js +13 -9
- package/lib/tools/auth0/handlers/clientGrants.d.ts +32 -0
- package/lib/tools/auth0/handlers/clientGrants.js +17 -10
- package/lib/tools/auth0/handlers/clients.d.ts +23 -0
- package/lib/tools/auth0/handlers/clients.js +15 -8
- package/lib/tools/auth0/handlers/connections.d.ts +54 -0
- package/lib/tools/auth0/handlers/connections.js +30 -10
- package/lib/tools/auth0/handlers/databases.d.ts +36 -0
- package/lib/tools/auth0/handlers/databases.js +25 -13
- package/lib/tools/auth0/handlers/default.d.ts +54 -0
- package/lib/tools/auth0/handlers/default.js +62 -36
- package/lib/tools/auth0/handlers/emailProvider.d.ts +11 -0
- package/lib/tools/auth0/handlers/emailTemplates.d.ts +26 -0
- package/lib/tools/auth0/handlers/emailTemplates.js +8 -10
- package/lib/tools/auth0/handlers/guardianFactorProviders.d.ts +25 -0
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactorTemplates.d.ts +21 -0
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +3 -3
- package/lib/tools/auth0/handlers/guardianFactors.d.ts +21 -0
- package/lib/tools/auth0/handlers/guardianFactors.js +3 -3
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.d.ts +21 -0
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +11 -10
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.d.ts +18 -0
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +10 -9
- package/lib/tools/auth0/handlers/guardianPolicies.d.ts +23 -0
- package/lib/tools/auth0/handlers/guardianPolicies.js +5 -4
- package/lib/tools/auth0/handlers/hooks.d.ts +58 -0
- package/lib/tools/auth0/handlers/hooks.js +34 -21
- package/lib/tools/auth0/handlers/index.d.ts +129 -0
- package/lib/tools/auth0/handlers/index.js +31 -27
- package/lib/tools/auth0/handlers/migrations.d.ts +15 -0
- package/lib/tools/auth0/handlers/migrations.js +3 -2
- package/lib/tools/auth0/handlers/organizations.d.ts +51 -0
- package/lib/tools/auth0/handlers/organizations.js +62 -32
- package/lib/tools/auth0/handlers/pages.d.ts +42 -0
- package/lib/tools/auth0/handlers/pages.js +20 -14
- package/lib/tools/auth0/handlers/prompts.d.ts +11 -0
- package/lib/tools/auth0/handlers/prompts.js +1 -0
- package/lib/tools/auth0/handlers/resourceServers.d.ts +51 -0
- package/lib/tools/auth0/handlers/resourceServers.js +22 -14
- package/lib/tools/auth0/handlers/roles.d.ts +48 -0
- package/lib/tools/auth0/handlers/roles.js +56 -32
- package/lib/tools/auth0/handlers/rules.d.ts +55 -0
- package/lib/tools/auth0/handlers/rules.js +53 -36
- package/lib/tools/auth0/handlers/rulesConfigs.d.ts +25 -0
- package/lib/tools/auth0/handlers/rulesConfigs.js +12 -6
- package/lib/tools/auth0/handlers/tenant.d.ts +11 -0
- package/lib/tools/auth0/handlers/tenant.js +8 -4
- package/lib/tools/auth0/handlers/triggers.d.ts +35 -0
- package/lib/tools/auth0/handlers/triggers.js +12 -13
- package/lib/tools/auth0/index.d.ts +15 -0
- package/lib/tools/auth0/index.js +15 -31
- package/lib/tools/auth0/schema.d.ts +15 -0
- package/lib/tools/auth0/schema.js +7 -27
- package/lib/tools/calculateChanges.d.ts +26 -0
- package/lib/tools/calculateChanges.js +12 -7
- package/lib/tools/constants.d.ts +71 -0
- package/lib/tools/constants.js +164 -161
- package/lib/tools/deploy.d.ts +3 -0
- package/lib/tools/deploy.js +3 -3
- package/lib/tools/index.d.ts +82 -0
- package/lib/tools/index.js +1 -1
- package/lib/tools/utils.d.ts +18 -0
- package/lib/tools/utils.js +68 -10
- package/lib/tools/validationError.d.ts +5 -0
- package/lib/tools/{ValidationError.js → validationError.js} +3 -1
- package/lib/types.d.ts +255 -0
- package/lib/types.js +2 -0
- package/lib/utils.d.ts +66 -0
- package/lib/utils.js +18 -25
- package/package.json +16 -7
- package/tsconfig.json +3 -4
- package/typescript-migration-progress.sh +1 -1
- package/lib/tools/logger.js +0 -15
|
@@ -45,7 +45,7 @@ exports.schema = void 0;
|
|
|
45
45
|
const lodash_1 = __importDefault(require("lodash"));
|
|
46
46
|
const default_1 = __importStar(require("./default"));
|
|
47
47
|
const calculateChanges_1 = require("../../calculateChanges");
|
|
48
|
-
const logger_1 = __importDefault(require("
|
|
48
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
49
49
|
exports.schema = {
|
|
50
50
|
type: 'array',
|
|
51
51
|
items: {
|
|
@@ -61,13 +61,13 @@ exports.schema = {
|
|
|
61
61
|
type: 'object',
|
|
62
62
|
properties: {
|
|
63
63
|
connection_id: { type: 'string' },
|
|
64
|
-
assign_membership_on_login: { type: 'boolean' }
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
64
|
+
assign_membership_on_login: { type: 'boolean' },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
68
|
},
|
|
69
|
-
required: ['name']
|
|
70
|
-
}
|
|
69
|
+
required: ['name'],
|
|
70
|
+
},
|
|
71
71
|
};
|
|
72
72
|
class OrganizationsHandler extends default_1.default {
|
|
73
73
|
constructor(config) {
|
|
@@ -80,16 +80,21 @@ class OrganizationsHandler extends default_1.default {
|
|
|
80
80
|
}
|
|
81
81
|
deleteOrganizations(data) {
|
|
82
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
84
|
-
|
|
83
|
+
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
84
|
+
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
85
|
+
yield this.client.pool
|
|
86
|
+
.addEachTask({
|
|
85
87
|
data: data || [],
|
|
86
|
-
generator: (item) => this.deleteOrganization(item)
|
|
88
|
+
generator: (item) => this.deleteOrganization(item)
|
|
89
|
+
.then(() => {
|
|
87
90
|
this.didDelete(item);
|
|
88
91
|
this.deleted += 1;
|
|
89
|
-
}).catch((err) => {
|
|
90
|
-
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
91
92
|
})
|
|
92
|
-
|
|
93
|
+
.catch((err) => {
|
|
94
|
+
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
95
|
+
}),
|
|
96
|
+
})
|
|
97
|
+
.promise();
|
|
93
98
|
}
|
|
94
99
|
else {
|
|
95
100
|
logger_1.default.warn(`Detected the following organizations should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
@@ -110,15 +115,19 @@ class OrganizationsHandler extends default_1.default {
|
|
|
110
115
|
}
|
|
111
116
|
createOrganizations(creates) {
|
|
112
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
yield this.client.pool
|
|
118
|
+
yield this.client.pool
|
|
119
|
+
.addEachTask({
|
|
114
120
|
data: creates || [],
|
|
115
|
-
generator: (item) => this.createOrganization(item)
|
|
121
|
+
generator: (item) => this.createOrganization(item)
|
|
122
|
+
.then((data) => {
|
|
116
123
|
this.didCreate(data);
|
|
117
124
|
this.created += 1;
|
|
118
|
-
}).catch((err) => {
|
|
119
|
-
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
120
125
|
})
|
|
121
|
-
|
|
126
|
+
.catch((err) => {
|
|
127
|
+
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
128
|
+
}),
|
|
129
|
+
})
|
|
130
|
+
.promise();
|
|
122
131
|
});
|
|
123
132
|
}
|
|
124
133
|
updateOrganization(org, organizations) {
|
|
@@ -132,7 +141,8 @@ class OrganizationsHandler extends default_1.default {
|
|
|
132
141
|
yield this.client.organizations.update(params, org);
|
|
133
142
|
const connectionsToRemove = existingConnections.filter((c) => !connections.find((x) => x.connection_id === c.connection_id));
|
|
134
143
|
const connectionsToAdd = connections.filter((c) => !existingConnections.find((x) => x.connection_id === c.connection_id));
|
|
135
|
-
const connectionsToUpdate = connections.filter((c) => existingConnections.find((x) => x.connection_id === c.connection_id &&
|
|
144
|
+
const connectionsToUpdate = connections.filter((c) => existingConnections.find((x) => x.connection_id === c.connection_id &&
|
|
145
|
+
x.assign_membership_on_login !== c.assign_membership_on_login));
|
|
136
146
|
// Handle updates first
|
|
137
147
|
yield Promise.all(connectionsToUpdate.map((conn) => this.client.organizations
|
|
138
148
|
.updateEnabledConnection(Object.assign({ connection_id: conn.connection_id }, params), { assign_membership_on_login: conn.assign_membership_on_login })
|
|
@@ -154,15 +164,19 @@ class OrganizationsHandler extends default_1.default {
|
|
|
154
164
|
}
|
|
155
165
|
updateOrganizations(updates, orgs) {
|
|
156
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
yield this.client.pool
|
|
167
|
+
yield this.client.pool
|
|
168
|
+
.addEachTask({
|
|
158
169
|
data: updates || [],
|
|
159
|
-
generator: (item) => this.updateOrganization(item, orgs)
|
|
170
|
+
generator: (item) => this.updateOrganization(item, orgs)
|
|
171
|
+
.then((data) => {
|
|
160
172
|
this.didUpdate(data);
|
|
161
173
|
this.updated += 1;
|
|
162
|
-
}).catch((err) => {
|
|
163
|
-
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
164
174
|
})
|
|
165
|
-
|
|
175
|
+
.catch((err) => {
|
|
176
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
177
|
+
}),
|
|
178
|
+
})
|
|
179
|
+
.promise();
|
|
166
180
|
});
|
|
167
181
|
}
|
|
168
182
|
getType() {
|
|
@@ -174,9 +188,14 @@ class OrganizationsHandler extends default_1.default {
|
|
|
174
188
|
return [];
|
|
175
189
|
}
|
|
176
190
|
try {
|
|
177
|
-
const organizations = yield this.client.organizations.getAll({
|
|
191
|
+
const organizations = yield this.client.organizations.getAll({
|
|
192
|
+
checkpoint: true,
|
|
193
|
+
include_totals: true,
|
|
194
|
+
});
|
|
178
195
|
for (let index = 0; index < organizations.length; index++) {
|
|
179
|
-
const connections = yield this.client.organizations.connections.get({
|
|
196
|
+
const connections = yield this.client.organizations.connections.get({
|
|
197
|
+
id: organizations[index].id,
|
|
198
|
+
});
|
|
180
199
|
organizations[index].connections = connections;
|
|
181
200
|
}
|
|
182
201
|
this.existing = organizations;
|
|
@@ -199,23 +218,33 @@ class OrganizationsHandler extends default_1.default {
|
|
|
199
218
|
return;
|
|
200
219
|
// Gets organizations from destination tenant
|
|
201
220
|
const existing = yield this.getType();
|
|
202
|
-
const existingConnections = yield this.client.connections.getAll({
|
|
221
|
+
const existingConnections = yield this.client.connections.getAll({
|
|
222
|
+
paginate: true,
|
|
223
|
+
include_totals: true,
|
|
224
|
+
});
|
|
203
225
|
// We need to get the connection ids for the names configured so we can link them together
|
|
204
226
|
organizations.forEach((org) => {
|
|
205
|
-
org.connections = (org.connections || [])
|
|
227
|
+
org.connections = (org.connections || [])
|
|
228
|
+
.map((connection) => {
|
|
206
229
|
const { name } = connection;
|
|
207
230
|
delete connection.name;
|
|
208
231
|
return Object.assign(Object.assign({}, connection), { connection_id: (existingConnections.find((c) => c.name === name) || {}).id });
|
|
209
|
-
})
|
|
232
|
+
})
|
|
233
|
+
.filter((connection) => !!connection.connection_id);
|
|
210
234
|
});
|
|
211
235
|
const changes = (0, calculateChanges_1.calculateChanges)({
|
|
212
236
|
handler: this,
|
|
213
237
|
assets: organizations,
|
|
214
238
|
existing,
|
|
215
|
-
identifiers: ['id', 'name']
|
|
239
|
+
identifiers: ['id', 'name'],
|
|
240
|
+
allowDelete: false, //TODO: actually pass in correct allowDelete value
|
|
216
241
|
});
|
|
217
242
|
logger_1.default.debug(`Start processChanges for organizations [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
|
|
218
|
-
const myChanges = [
|
|
243
|
+
const myChanges = [
|
|
244
|
+
{ del: changes.del },
|
|
245
|
+
{ create: changes.create },
|
|
246
|
+
{ update: changes.update },
|
|
247
|
+
];
|
|
219
248
|
yield Promise.all(myChanges.map((change) => __awaiter(this, void 0, void 0, function* () {
|
|
220
249
|
switch (true) {
|
|
221
250
|
case change.del && change.del.length > 0:
|
|
@@ -225,7 +254,8 @@ class OrganizationsHandler extends default_1.default {
|
|
|
225
254
|
yield this.createOrganizations(changes.create);
|
|
226
255
|
break;
|
|
227
256
|
case change.update && change.update.length > 0:
|
|
228
|
-
|
|
257
|
+
if (change.update)
|
|
258
|
+
yield this.updateOrganizations(change.update, existing);
|
|
229
259
|
break;
|
|
230
260
|
default:
|
|
231
261
|
break;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset, Assets } from '../../../types';
|
|
3
|
+
export declare const supportedPages: string[];
|
|
4
|
+
export declare const pageNameMap: {
|
|
5
|
+
guardian_multifactor: string;
|
|
6
|
+
password_reset: string;
|
|
7
|
+
error_page: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const schema: {
|
|
10
|
+
type: string;
|
|
11
|
+
items: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
name: {
|
|
15
|
+
type: string;
|
|
16
|
+
enum: string[];
|
|
17
|
+
};
|
|
18
|
+
html: {
|
|
19
|
+
type: string;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
url: {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
show_log_link: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
enabled: {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export default class PagesHandler extends DefaultHandler {
|
|
36
|
+
constructor(options: DefaultHandler);
|
|
37
|
+
objString(page: any): string;
|
|
38
|
+
updateLoginPage(page: any): Promise<void>;
|
|
39
|
+
updatePages(pages: Asset[]): Promise<void>;
|
|
40
|
+
getType(): Promise<Asset[]>;
|
|
41
|
+
processChanges(assets: Assets): Promise<void>;
|
|
42
|
+
}
|
|
@@ -15,13 +15,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.schema = exports.pageNameMap = exports.supportedPages = void 0;
|
|
16
16
|
const default_1 = __importDefault(require("./default"));
|
|
17
17
|
const constants_1 = __importDefault(require("../../constants"));
|
|
18
|
-
exports.supportedPages = constants_1.default.PAGE_NAMES
|
|
19
|
-
.filter((p) => p.includes('.json'))
|
|
20
|
-
.map((p) => p.replace('.json', ''));
|
|
18
|
+
exports.supportedPages = constants_1.default.PAGE_NAMES.filter((p) => p.includes('.json')).map((p) => p.replace('.json', ''));
|
|
21
19
|
exports.pageNameMap = {
|
|
22
20
|
guardian_multifactor: 'guardian_mfa_page',
|
|
23
21
|
password_reset: 'change_password',
|
|
24
|
-
error_page: 'error_page'
|
|
22
|
+
error_page: 'error_page',
|
|
25
23
|
};
|
|
26
24
|
// With this schema, we can only validate property types but not valid properties on per type basis
|
|
27
25
|
exports.schema = {
|
|
@@ -33,12 +31,12 @@ exports.schema = {
|
|
|
33
31
|
html: { type: 'string', default: '' },
|
|
34
32
|
url: { type: 'string' },
|
|
35
33
|
show_log_link: { type: 'boolean' },
|
|
36
|
-
enabled: { type: 'boolean' }
|
|
34
|
+
enabled: { type: 'boolean' },
|
|
37
35
|
},
|
|
38
|
-
required: ['name']
|
|
39
|
-
}
|
|
36
|
+
required: ['name'],
|
|
37
|
+
},
|
|
40
38
|
};
|
|
41
|
-
class
|
|
39
|
+
class PagesHandler extends default_1.default {
|
|
42
40
|
constructor(options) {
|
|
43
41
|
super(Object.assign(Object.assign({}, options), { type: 'pages' }));
|
|
44
42
|
}
|
|
@@ -47,13 +45,17 @@ class PageHandler extends default_1.default {
|
|
|
47
45
|
}
|
|
48
46
|
updateLoginPage(page) {
|
|
49
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const globalClient = yield this.client.clients.getAll({
|
|
48
|
+
const globalClient = yield this.client.clients.getAll({
|
|
49
|
+
is_global: true,
|
|
50
|
+
paginate: true,
|
|
51
|
+
include_totals: true,
|
|
52
|
+
});
|
|
51
53
|
if (!globalClient[0]) {
|
|
52
54
|
throw new Error('Unable to find global client id when trying to update the login page');
|
|
53
55
|
}
|
|
54
56
|
yield this.client.clients.update({ client_id: globalClient[0].client_id }, {
|
|
55
57
|
custom_login_page: page.html,
|
|
56
|
-
custom_login_page_on: page.enabled
|
|
58
|
+
custom_login_page_on: page.enabled,
|
|
57
59
|
});
|
|
58
60
|
this.updated += 1;
|
|
59
61
|
this.didUpdate(page);
|
|
@@ -86,7 +88,11 @@ class PageHandler extends default_1.default {
|
|
|
86
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
89
|
const pages = [];
|
|
88
90
|
// Login page is handled via the global client
|
|
89
|
-
const globalClient = yield this.client.clients.getAll({
|
|
91
|
+
const globalClient = yield this.client.clients.getAll({
|
|
92
|
+
is_global: true,
|
|
93
|
+
paginate: true,
|
|
94
|
+
include_totals: true,
|
|
95
|
+
});
|
|
90
96
|
if (!globalClient[0]) {
|
|
91
97
|
throw new Error('Unable to find global client id when trying to dump the login page');
|
|
92
98
|
}
|
|
@@ -94,7 +100,7 @@ class PageHandler extends default_1.default {
|
|
|
94
100
|
pages.push({
|
|
95
101
|
name: 'login',
|
|
96
102
|
enabled: globalClient[0].custom_login_page_on,
|
|
97
|
-
html: globalClient[0].custom_login_page
|
|
103
|
+
html: globalClient[0].custom_login_page,
|
|
98
104
|
});
|
|
99
105
|
}
|
|
100
106
|
const tenantSettings = yield this.client.tenant.getSettings();
|
|
@@ -115,7 +121,7 @@ class PageHandler extends default_1.default {
|
|
|
115
121
|
return;
|
|
116
122
|
// Login page is handled via the global client
|
|
117
123
|
const loginPage = pages.find((p) => p.name === 'login');
|
|
118
|
-
if (loginPage) {
|
|
124
|
+
if (loginPage !== undefined) {
|
|
119
125
|
yield this.updateLoginPage(loginPage);
|
|
120
126
|
}
|
|
121
127
|
// Rest of pages are on tenant level settings
|
|
@@ -123,4 +129,4 @@ class PageHandler extends default_1.default {
|
|
|
123
129
|
});
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
|
-
exports.default =
|
|
132
|
+
exports.default = PagesHandler;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset, Assets } from '../../../types';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
};
|
|
6
|
+
export default class PromptsHandler extends DefaultHandler {
|
|
7
|
+
existing: Asset[];
|
|
8
|
+
constructor(options: DefaultHandler);
|
|
9
|
+
getType(): Promise<Asset[]>;
|
|
10
|
+
processChanges(assets: Assets): Promise<void>;
|
|
11
|
+
}
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.schema = void 0;
|
|
16
|
+
//@ts-nocheck because prompts haven't been fully implemented in this codebase yet
|
|
16
17
|
const default_1 = __importDefault(require("./default"));
|
|
17
18
|
exports.schema = { type: 'object' };
|
|
18
19
|
class PromptsHandler extends default_1.default {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset, Assets, CalculatedChanges } from '../../../types';
|
|
3
|
+
export declare const excludeSchema: {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const schema: {
|
|
10
|
+
type: string;
|
|
11
|
+
items: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
name: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
identifier: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
scopes: {
|
|
21
|
+
type: string;
|
|
22
|
+
items: {
|
|
23
|
+
type: string;
|
|
24
|
+
properties: {
|
|
25
|
+
name: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
description: {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
enforce_policies: {
|
|
35
|
+
type: string;
|
|
36
|
+
};
|
|
37
|
+
token_dialect: {
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
required: string[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export default class ResourceServersHandler extends DefaultHandler {
|
|
45
|
+
existing: Asset[];
|
|
46
|
+
constructor(options: DefaultHandler);
|
|
47
|
+
objString(resourceServer: any): string;
|
|
48
|
+
getType(): Promise<Asset[]>;
|
|
49
|
+
calcChanges(assets: Assets): Promise<CalculatedChanges>;
|
|
50
|
+
validate(assets: Assets): Promise<void>;
|
|
51
|
+
}
|
|
@@ -13,13 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.schema = exports.excludeSchema = void 0;
|
|
16
|
-
const
|
|
16
|
+
const validationError_1 = __importDefault(require("../../validationError"));
|
|
17
17
|
const constants_1 = __importDefault(require("../../constants"));
|
|
18
18
|
const default_1 = __importDefault(require("./default"));
|
|
19
19
|
const calculateChanges_1 = require("../../calculateChanges");
|
|
20
20
|
exports.excludeSchema = {
|
|
21
21
|
type: 'array',
|
|
22
|
-
items: { type: 'string' }
|
|
22
|
+
items: { type: 'string' },
|
|
23
23
|
};
|
|
24
24
|
exports.schema = {
|
|
25
25
|
type: 'array',
|
|
@@ -34,20 +34,19 @@ exports.schema = {
|
|
|
34
34
|
type: 'object',
|
|
35
35
|
properties: {
|
|
36
36
|
name: { type: 'string' },
|
|
37
|
-
description: { type: 'string' }
|
|
38
|
-
}
|
|
39
|
-
}
|
|
37
|
+
description: { type: 'string' },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
40
|
},
|
|
41
41
|
enforce_policies: { type: 'boolean' },
|
|
42
|
-
token_dialect: { type: 'string' }
|
|
42
|
+
token_dialect: { type: 'string' },
|
|
43
43
|
},
|
|
44
|
-
required: ['name', 'identifier']
|
|
45
|
-
}
|
|
44
|
+
required: ['name', 'identifier'],
|
|
45
|
+
},
|
|
46
46
|
};
|
|
47
47
|
class ResourceServersHandler extends default_1.default {
|
|
48
48
|
constructor(options) {
|
|
49
|
-
super(Object.assign(Object.assign({}, options), { type: 'resourceServers', stripUpdateFields: ['identifier']
|
|
50
|
-
}));
|
|
49
|
+
super(Object.assign(Object.assign({}, options), { type: 'resourceServers', stripUpdateFields: ['identifier'] }));
|
|
51
50
|
}
|
|
52
51
|
objString(resourceServer) {
|
|
53
52
|
return super.objString({ name: resourceServer.name, identifier: resourceServer.identifier });
|
|
@@ -56,7 +55,10 @@ class ResourceServersHandler extends default_1.default {
|
|
|
56
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
56
|
if (this.existing)
|
|
58
57
|
return this.existing;
|
|
59
|
-
const resourceServers = yield this.client.resourceServers.getAll({
|
|
58
|
+
const resourceServers = yield this.client.resourceServers.getAll({
|
|
59
|
+
paginate: true,
|
|
60
|
+
include_totals: true,
|
|
61
|
+
});
|
|
60
62
|
return resourceServers.filter((rs) => rs.name !== constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
|
|
61
63
|
});
|
|
62
64
|
}
|
|
@@ -65,7 +67,12 @@ class ResourceServersHandler extends default_1.default {
|
|
|
65
67
|
let { resourceServers } = assets;
|
|
66
68
|
// Do nothing if not set
|
|
67
69
|
if (!resourceServers)
|
|
68
|
-
return {
|
|
70
|
+
return {
|
|
71
|
+
del: [],
|
|
72
|
+
create: [],
|
|
73
|
+
conflicts: [],
|
|
74
|
+
update: [],
|
|
75
|
+
};
|
|
69
76
|
const excluded = (assets.exclude && assets.exclude.resourceServers) || [];
|
|
70
77
|
let existing = yield this.getType();
|
|
71
78
|
// Filter excluded
|
|
@@ -75,7 +82,8 @@ class ResourceServersHandler extends default_1.default {
|
|
|
75
82
|
handler: this,
|
|
76
83
|
assets: resourceServers,
|
|
77
84
|
existing,
|
|
78
|
-
identifiers: ['id', 'identifier']
|
|
85
|
+
identifiers: ['id', 'identifier'],
|
|
86
|
+
allowDelete: false, //TODO: actually pass in correct allowDelete value
|
|
79
87
|
});
|
|
80
88
|
});
|
|
81
89
|
}
|
|
@@ -90,7 +98,7 @@ class ResourceServersHandler extends default_1.default {
|
|
|
90
98
|
return;
|
|
91
99
|
const mgmtAPIResource = resourceServers.find((r) => r.name === constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
|
|
92
100
|
if (mgmtAPIResource) {
|
|
93
|
-
throw new
|
|
101
|
+
throw new validationError_1.default(`You can not configure the '${constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME}'.`);
|
|
94
102
|
}
|
|
95
103
|
yield _super.validate.call(this, assets);
|
|
96
104
|
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset, Assets, CalculatedChanges } from '../../../types';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
name: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
id: {
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
description: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
permissions: {
|
|
18
|
+
type: string;
|
|
19
|
+
items: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {
|
|
22
|
+
permission_name: {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
resource_server_identifier: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export default class RolesHandler extends DefaultHandler {
|
|
36
|
+
existing: Asset[];
|
|
37
|
+
constructor(config: DefaultHandler);
|
|
38
|
+
createRole(data: any): Promise<Asset>;
|
|
39
|
+
createRoles(creates: CalculatedChanges['create']): Promise<void>;
|
|
40
|
+
deleteRole(data: any): Promise<void>;
|
|
41
|
+
deleteRoles(dels: CalculatedChanges['del']): Promise<void>;
|
|
42
|
+
updateRole(data: any, roles: any): Promise<{
|
|
43
|
+
id: any;
|
|
44
|
+
}>;
|
|
45
|
+
updateRoles(updates: CalculatedChanges['update'], roles: any): Promise<void>;
|
|
46
|
+
getType(): Promise<Asset[]>;
|
|
47
|
+
processChanges(assets: Assets): Promise<void>;
|
|
48
|
+
}
|