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
|
@@ -44,7 +44,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
44
44
|
exports.schema = void 0;
|
|
45
45
|
const lodash_1 = __importDefault(require("lodash"));
|
|
46
46
|
const default_1 = __importStar(require("./default"));
|
|
47
|
-
const logger_1 = __importDefault(require("
|
|
47
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
48
48
|
const utils_1 = require("../../utils");
|
|
49
49
|
const MAX_ACTION_DEPLOY_RETRY = 60;
|
|
50
50
|
// With this schema, we can only validate property types but not valid properties on per type basis
|
|
@@ -65,9 +65,9 @@ exports.schema = {
|
|
|
65
65
|
properties: {
|
|
66
66
|
name: { type: 'string' },
|
|
67
67
|
version: { type: 'string' },
|
|
68
|
-
registry_url: { type: 'string' }
|
|
69
|
-
}
|
|
70
|
-
}
|
|
68
|
+
registry_url: { type: 'string' },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
71
|
},
|
|
72
72
|
secrets: {
|
|
73
73
|
type: 'array',
|
|
@@ -76,9 +76,9 @@ exports.schema = {
|
|
|
76
76
|
properties: {
|
|
77
77
|
name: { type: 'string' },
|
|
78
78
|
value: { type: 'string' },
|
|
79
|
-
updated_at: { type: 'string', format: 'date-time' }
|
|
80
|
-
}
|
|
81
|
-
}
|
|
79
|
+
updated_at: { type: 'string', format: 'date-time' },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
82
|
},
|
|
83
83
|
name: { type: 'string', default: '' },
|
|
84
84
|
supported_triggers: {
|
|
@@ -88,31 +88,28 @@ exports.schema = {
|
|
|
88
88
|
properties: {
|
|
89
89
|
id: { type: 'string', default: '' },
|
|
90
90
|
version: { type: 'string' },
|
|
91
|
-
url: { type: 'string' }
|
|
92
|
-
}
|
|
93
|
-
}
|
|
91
|
+
url: { type: 'string' },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
94
|
},
|
|
95
95
|
deployed: { type: 'boolean' },
|
|
96
|
-
status: { type: 'string' }
|
|
97
|
-
}
|
|
98
|
-
}
|
|
96
|
+
status: { type: 'string' },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
99
|
};
|
|
100
100
|
function sleep(ms) {
|
|
101
101
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
102
102
|
}
|
|
103
103
|
function isActionsDisabled(err) {
|
|
104
104
|
const errorBody = lodash_1.default.get(err, 'originalError.response.body') || {};
|
|
105
|
-
return
|
|
105
|
+
return err.statusCode === 403 && errorBody.errorCode === 'feature_not_enabled';
|
|
106
106
|
}
|
|
107
107
|
class ActionHandler extends default_1.default {
|
|
108
108
|
constructor(options) {
|
|
109
109
|
super(Object.assign(Object.assign({}, options), { type: 'actions', functions: {
|
|
110
110
|
create: (action) => this.createAction(action),
|
|
111
|
-
delete: (action) => this.deleteAction(action)
|
|
112
|
-
}, stripUpdateFields: [
|
|
113
|
-
'deployed',
|
|
114
|
-
'status'
|
|
115
|
-
] }));
|
|
111
|
+
delete: (action) => this.deleteAction(action),
|
|
112
|
+
}, stripUpdateFields: ['deployed', 'status'] }));
|
|
116
113
|
}
|
|
117
114
|
createAction(action) {
|
|
118
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -148,7 +145,7 @@ class ActionHandler extends default_1.default {
|
|
|
148
145
|
})
|
|
149
146
|
.catch((err) => {
|
|
150
147
|
throw new Error(`Problem Deploying ${this.type} ${this.objString(action)}\n${err}`);
|
|
151
|
-
})
|
|
148
|
+
}),
|
|
152
149
|
})
|
|
153
150
|
.promise();
|
|
154
151
|
});
|
|
@@ -160,7 +157,7 @@ class ActionHandler extends default_1.default {
|
|
|
160
157
|
}
|
|
161
158
|
catch (err) {
|
|
162
159
|
// Retry if pending build.
|
|
163
|
-
if (err.message && err.message.includes(
|
|
160
|
+
if (err.message && err.message.includes("must be in the 'built' state")) {
|
|
164
161
|
if (!action.retry_count) {
|
|
165
162
|
logger_1.default.info(`[${this.type}]: Waiting for build to complete ${this.objString(action)}`);
|
|
166
163
|
action.retry_count = 1;
|
|
@@ -237,9 +234,10 @@ class ActionHandler extends default_1.default {
|
|
|
237
234
|
const changes = yield this.calcChanges(assets);
|
|
238
235
|
yield _super.processChanges.call(this, assets, changes);
|
|
239
236
|
// Deploy actions
|
|
240
|
-
const deployActions = [
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
const deployActions = [
|
|
238
|
+
...changes.create.filter((action) => action.deployed),
|
|
239
|
+
...changes.update.filter((action) => action.deployed),
|
|
240
|
+
];
|
|
243
241
|
yield this.deployActions(deployActions);
|
|
244
242
|
});
|
|
245
243
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import DefaultAPIHandler from './default';
|
|
2
|
+
import { Asset, Assets } from '../../../types';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
properties: {
|
|
6
|
+
breachedPasswordDetection: {
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
bruteForceProtection: {
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
suspiciousIpThrottling: {
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
additionalProperties: boolean;
|
|
17
|
+
};
|
|
18
|
+
export default class AttackProtectionHandler extends DefaultAPIHandler {
|
|
19
|
+
existing: {
|
|
20
|
+
breachedPasswordDetection: any;
|
|
21
|
+
bruteForceProtection: any;
|
|
22
|
+
suspiciousIpThrottling: any;
|
|
23
|
+
} | null;
|
|
24
|
+
constructor(config: DefaultAPIHandler);
|
|
25
|
+
objString(item: Asset): string;
|
|
26
|
+
getType(): Promise<Asset>;
|
|
27
|
+
processChanges(assets: Assets): Promise<void>;
|
|
28
|
+
}
|
|
@@ -18,16 +18,16 @@ exports.schema = {
|
|
|
18
18
|
type: 'object',
|
|
19
19
|
properties: {
|
|
20
20
|
breachedPasswordDetection: {
|
|
21
|
-
type: 'object'
|
|
21
|
+
type: 'object',
|
|
22
22
|
},
|
|
23
23
|
bruteForceProtection: {
|
|
24
|
-
type: 'object'
|
|
24
|
+
type: 'object',
|
|
25
25
|
},
|
|
26
26
|
suspiciousIpThrottling: {
|
|
27
|
-
type: 'object'
|
|
28
|
-
}
|
|
27
|
+
type: 'object',
|
|
28
|
+
},
|
|
29
29
|
},
|
|
30
|
-
additionalProperties: false
|
|
30
|
+
additionalProperties: false,
|
|
31
31
|
};
|
|
32
32
|
class AttackProtectionHandler extends default_1.default {
|
|
33
33
|
constructor(config) {
|
|
@@ -36,14 +36,14 @@ class AttackProtectionHandler extends default_1.default {
|
|
|
36
36
|
objString(item) {
|
|
37
37
|
return super.objString({
|
|
38
38
|
'breached-password-protection': {
|
|
39
|
-
enabled: item.breachedPasswordDetection.enabled
|
|
39
|
+
enabled: item.breachedPasswordDetection.enabled,
|
|
40
40
|
},
|
|
41
41
|
'brute-force-protection': {
|
|
42
|
-
enabled: item.bruteForceProtection.enabled
|
|
42
|
+
enabled: item.bruteForceProtection.enabled,
|
|
43
43
|
},
|
|
44
44
|
'suspicious-ip-throttling': {
|
|
45
|
-
enabled: item.suspiciousIpThrottling.enabled
|
|
46
|
-
}
|
|
45
|
+
enabled: item.suspiciousIpThrottling.enabled,
|
|
46
|
+
},
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
getType() {
|
|
@@ -54,12 +54,12 @@ class AttackProtectionHandler extends default_1.default {
|
|
|
54
54
|
const [breachedPasswordDetection, bruteForceProtection, suspiciousIpThrottling] = yield Promise.all([
|
|
55
55
|
this.client.attackProtection.getBreachedPasswordDetectionConfig(),
|
|
56
56
|
this.client.attackProtection.getBruteForceConfig(),
|
|
57
|
-
this.client.attackProtection.getSuspiciousIpThrottlingConfig()
|
|
57
|
+
this.client.attackProtection.getSuspiciousIpThrottlingConfig(),
|
|
58
58
|
]);
|
|
59
59
|
this.existing = {
|
|
60
60
|
breachedPasswordDetection,
|
|
61
61
|
bruteForceProtection,
|
|
62
|
-
suspiciousIpThrottling
|
|
62
|
+
suspiciousIpThrottling,
|
|
63
63
|
};
|
|
64
64
|
return this.existing;
|
|
65
65
|
});
|
|
@@ -71,12 +71,9 @@ class AttackProtectionHandler extends default_1.default {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
Promise.all([
|
|
74
|
-
this.client.attackProtection
|
|
75
|
-
|
|
76
|
-
this.client.attackProtection
|
|
77
|
-
.updateSuspiciousIpThrottlingConfig({}, attackProtection.suspiciousIpThrottling),
|
|
78
|
-
this.client.attackProtection
|
|
79
|
-
.updateBruteForceConfig({}, attackProtection.bruteForceProtection)
|
|
74
|
+
this.client.attackProtection.updateBreachedPasswordDetectionConfig({}, attackProtection.breachedPasswordDetection),
|
|
75
|
+
this.client.attackProtection.updateSuspiciousIpThrottlingConfig({}, attackProtection.suspiciousIpThrottling),
|
|
76
|
+
this.client.attackProtection.updateBruteForceConfig({}, attackProtection.bruteForceProtection),
|
|
80
77
|
]);
|
|
81
78
|
this.updated += 1;
|
|
82
79
|
this.didUpdate(attackProtection);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset } from '../../../types';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
properties: {
|
|
6
|
+
templates: {
|
|
7
|
+
type: string;
|
|
8
|
+
items: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties: {
|
|
11
|
+
template: {
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
body: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default class BrandingHandler extends DefaultHandler {
|
|
23
|
+
existing: Asset;
|
|
24
|
+
constructor(options: DefaultHandler);
|
|
25
|
+
getType(): Promise<Asset>;
|
|
26
|
+
processChanges(assets: any): Promise<void>;
|
|
27
|
+
}
|
|
@@ -25,11 +25,11 @@ exports.schema = {
|
|
|
25
25
|
type: 'object',
|
|
26
26
|
properties: {
|
|
27
27
|
template: { type: 'string' },
|
|
28
|
-
body: { type: 'string' }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
28
|
+
body: { type: 'string' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
33
|
};
|
|
34
34
|
class BrandingHandler extends default_1.default {
|
|
35
35
|
constructor(options) {
|
|
@@ -52,8 +52,8 @@ class BrandingHandler extends default_1.default {
|
|
|
52
52
|
branding.templates = [
|
|
53
53
|
{
|
|
54
54
|
template: constants_1.default.UNIVERSAL_LOGIN_TEMPLATE,
|
|
55
|
-
body: payload.body
|
|
56
|
-
}
|
|
55
|
+
body: payload.body,
|
|
56
|
+
},
|
|
57
57
|
];
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -88,10 +88,14 @@ class BrandingHandler extends default_1.default {
|
|
|
88
88
|
}
|
|
89
89
|
// handle templates
|
|
90
90
|
if (branding.templates && branding.templates.length) {
|
|
91
|
-
const unknownTemplates = branding.templates
|
|
91
|
+
const unknownTemplates = branding.templates
|
|
92
|
+
.filter((t) => !constants_1.default.SUPPORTED_BRANDING_TEMPLATES.includes(t.template))
|
|
93
|
+
.map((t) => t.template);
|
|
92
94
|
if (unknownTemplates.length) {
|
|
93
95
|
// throw a helpful warning for unknown templates, the context handlers are unaware of which are supported, that's all handled here.
|
|
94
|
-
logger_1.default.warn(`Found unknown branding template(s): ${unknownTemplates
|
|
96
|
+
logger_1.default.warn(`Found unknown branding template(s): ${unknownTemplates
|
|
97
|
+
.join()
|
|
98
|
+
.toString()}. Supported branding templates are: ${constants_1.default.SUPPORTED_BRANDING_TEMPLATES.join()}.`);
|
|
95
99
|
}
|
|
96
100
|
const templateDefinition = branding.templates.find((t) => t.template === constants_1.default.UNIVERSAL_LOGIN_TEMPLATE);
|
|
97
101
|
if (templateDefinition && templateDefinition.body) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import DefaultHandler from './default';
|
|
2
|
+
import { Asset, Assets } from '../../../types';
|
|
3
|
+
import DefaultAPIHandler from './default';
|
|
4
|
+
export declare const schema: {
|
|
5
|
+
type: string;
|
|
6
|
+
items: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
client_id: {
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
audience: {
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
scope: {
|
|
16
|
+
type: string;
|
|
17
|
+
items: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
uniqueItems: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
required: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export default class ClientGrantsHandler extends DefaultHandler {
|
|
27
|
+
existing: Asset[] | null;
|
|
28
|
+
constructor(config: DefaultAPIHandler);
|
|
29
|
+
objString(item: any): string;
|
|
30
|
+
getType(): Promise<Asset>;
|
|
31
|
+
processChanges(assets: Assets): Promise<void>;
|
|
32
|
+
}
|
|
@@ -51,15 +51,17 @@ exports.schema = {
|
|
|
51
51
|
scope: {
|
|
52
52
|
type: 'array',
|
|
53
53
|
items: { type: 'string' },
|
|
54
|
-
uniqueItems: true
|
|
55
|
-
}
|
|
54
|
+
uniqueItems: true,
|
|
55
|
+
},
|
|
56
56
|
},
|
|
57
|
-
required: ['client_id', 'scope', 'audience']
|
|
58
|
-
}
|
|
57
|
+
required: ['client_id', 'scope', 'audience'],
|
|
58
|
+
},
|
|
59
59
|
};
|
|
60
|
-
class
|
|
60
|
+
class ClientGrantsHandler extends default_1.default {
|
|
61
61
|
constructor(config) {
|
|
62
|
-
super(Object.assign(Object.assign({}, config), { type: 'clientGrants', id: 'id',
|
|
62
|
+
super(Object.assign(Object.assign({}, config), { type: 'clientGrants', id: 'id',
|
|
63
|
+
//@ts-ignore because not sure why two-dimensional array passed in
|
|
64
|
+
identifiers: ['id', ['client_id', 'audience']], stripUpdateFields: ['audience', 'client_id'] }));
|
|
63
65
|
}
|
|
64
66
|
objString(item) {
|
|
65
67
|
return super.objString({ id: item.id, client_id: item.client_id, audience: item.audience });
|
|
@@ -103,15 +105,20 @@ class ClientHandler extends default_1.default {
|
|
|
103
105
|
const { del, update, create, conflicts } = yield this.calcChanges(Object.assign(Object.assign({}, assets), { clientGrants: formatted }));
|
|
104
106
|
const filterGrants = (list) => {
|
|
105
107
|
if (excludedClients.length) {
|
|
106
|
-
return list.filter((item) => item.client_id !== currentClient &&
|
|
108
|
+
return list.filter((item) => item.client_id !== currentClient &&
|
|
109
|
+
![...excludedClientsByNames, ...excludedClients].includes(item.client_id));
|
|
107
110
|
}
|
|
108
111
|
return list.filter((item) => item.client_id !== currentClient);
|
|
109
112
|
};
|
|
110
113
|
const changes = {
|
|
114
|
+
//@ts-ignore because this expects `client_id` and that's not yet typed on Asset
|
|
111
115
|
del: filterGrants(del),
|
|
116
|
+
//@ts-ignore because this expects `client_id` and that's not yet typed on Asset
|
|
112
117
|
update: filterGrants(update),
|
|
118
|
+
//@ts-ignore because this expects `client_id` and that's not yet typed on Asset
|
|
113
119
|
create: filterGrants(create),
|
|
114
|
-
|
|
120
|
+
//@ts-ignore because this expects `client_id` and that's not yet typed on Asset
|
|
121
|
+
conflicts: filterGrants(conflicts),
|
|
115
122
|
};
|
|
116
123
|
yield _super.processChanges.call(this, assets, Object.assign({}, changes));
|
|
117
124
|
});
|
|
@@ -119,5 +126,5 @@ class ClientHandler extends default_1.default {
|
|
|
119
126
|
}
|
|
120
127
|
__decorate([
|
|
121
128
|
(0, default_1.order)('60')
|
|
122
|
-
],
|
|
123
|
-
exports.default =
|
|
129
|
+
], ClientGrantsHandler.prototype, "processChanges", null);
|
|
130
|
+
exports.default = ClientGrantsHandler;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Asset, Assets } from '../../../types';
|
|
2
|
+
import DefaultAPIHandler from './default';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
name: {
|
|
9
|
+
type: string;
|
|
10
|
+
minLength: number;
|
|
11
|
+
pattern: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
required: string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default class ClientHandler extends DefaultAPIHandler {
|
|
18
|
+
existing: Asset[] | null;
|
|
19
|
+
constructor(config: DefaultAPIHandler);
|
|
20
|
+
objString(item: any): string;
|
|
21
|
+
processChanges(assets: Assets): Promise<void>;
|
|
22
|
+
getType(): Promise<Asset[]>;
|
|
23
|
+
}
|
|
@@ -19,16 +19,20 @@ exports.schema = {
|
|
|
19
19
|
items: {
|
|
20
20
|
type: 'object',
|
|
21
21
|
properties: {
|
|
22
|
-
name: { type: 'string', minLength: 1, pattern: '[^<>]+' }
|
|
22
|
+
name: { type: 'string', minLength: 1, pattern: '[^<>]+' },
|
|
23
23
|
},
|
|
24
|
-
required: ['name']
|
|
25
|
-
}
|
|
24
|
+
required: ['name'],
|
|
25
|
+
},
|
|
26
26
|
};
|
|
27
27
|
class ClientHandler extends default_1.default {
|
|
28
28
|
constructor(config) {
|
|
29
29
|
super(Object.assign(Object.assign({}, config), { type: 'clients', id: 'client_id', identifiers: ['client_id', 'name'], objectFields: ['client_metadata'], stripUpdateFields: [
|
|
30
30
|
// Fields not allowed during updates
|
|
31
|
-
'callback_url_template',
|
|
31
|
+
'callback_url_template',
|
|
32
|
+
'signing_keys',
|
|
33
|
+
'global',
|
|
34
|
+
'tenant',
|
|
35
|
+
'jwt_configuration.secret_encoded',
|
|
32
36
|
] }));
|
|
33
37
|
}
|
|
34
38
|
objString(item) {
|
|
@@ -58,17 +62,20 @@ class ClientHandler extends default_1.default {
|
|
|
58
62
|
del: filterClients(del),
|
|
59
63
|
update: filterClients(update),
|
|
60
64
|
create: filterClients(create),
|
|
61
|
-
conflicts: filterClients(conflicts)
|
|
65
|
+
conflicts: filterClients(conflicts),
|
|
62
66
|
};
|
|
63
67
|
yield _super.processChanges.call(this, assets, Object.assign({}, changes));
|
|
64
68
|
});
|
|
65
69
|
}
|
|
66
70
|
getType() {
|
|
67
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
if (this.existing)
|
|
72
|
+
if (this.existing)
|
|
69
73
|
return this.existing;
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
this.existing = yield this.client.clients.getAll({
|
|
75
|
+
paginate: true,
|
|
76
|
+
include_totals: true,
|
|
77
|
+
is_global: false,
|
|
78
|
+
});
|
|
72
79
|
return this.existing;
|
|
73
80
|
});
|
|
74
81
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import DefaultAPIHandler from './default';
|
|
2
|
+
import { CalculatedChanges, Asset, Assets } from '../../../types';
|
|
3
|
+
import { ConfigFunction } from '../../../configFactory';
|
|
4
|
+
export declare const schema: {
|
|
5
|
+
type: string;
|
|
6
|
+
items: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
name: {
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
strategy: {
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
options: {
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
enabled_clients: {
|
|
19
|
+
type: string;
|
|
20
|
+
items: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
realms: {
|
|
25
|
+
type: string;
|
|
26
|
+
items: {
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
metadata: {
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
required: string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare const addExcludedConnectionPropertiesToChanges: ({ proposedChanges, existingConnections, config, }: {
|
|
38
|
+
proposedChanges: CalculatedChanges;
|
|
39
|
+
existingConnections: Asset[];
|
|
40
|
+
config: ConfigFunction;
|
|
41
|
+
}) => CalculatedChanges;
|
|
42
|
+
export default class ConnectionsHandler extends DefaultAPIHandler {
|
|
43
|
+
existing: Asset[] | null;
|
|
44
|
+
constructor(config: DefaultAPIHandler);
|
|
45
|
+
objString(connection: any): string;
|
|
46
|
+
getFormattedOptions(connection: any, clients: any): {
|
|
47
|
+
options: any;
|
|
48
|
+
} | {
|
|
49
|
+
options?: undefined;
|
|
50
|
+
};
|
|
51
|
+
getType(): Promise<Asset[] | null>;
|
|
52
|
+
calcChanges(assets: Assets): Promise<CalculatedChanges>;
|
|
53
|
+
processChanges(assets: Assets): Promise<void>;
|
|
54
|
+
}
|
|
@@ -56,19 +56,20 @@ exports.schema = {
|
|
|
56
56
|
options: { type: 'object' },
|
|
57
57
|
enabled_clients: { type: 'array', items: { type: 'string' } },
|
|
58
58
|
realms: { type: 'array', items: { type: 'string' } },
|
|
59
|
-
metadata: { type: 'object' }
|
|
59
|
+
metadata: { type: 'object' },
|
|
60
60
|
},
|
|
61
|
-
required: ['name', 'strategy']
|
|
62
|
-
}
|
|
61
|
+
required: ['name', 'strategy'],
|
|
62
|
+
},
|
|
63
63
|
};
|
|
64
64
|
// addExcludedConnectionPropertiesToChanges superimposes excluded properties on the `options` object. The Auth0 API
|
|
65
65
|
// will overwrite the options property when updating connections, so it is necessary to add excluded properties back in to prevent those excluded properties from being deleted.
|
|
66
66
|
// This use case is common because organizations may not want to expose sensitive connection details, but want to preserve them in the tenant.
|
|
67
67
|
// exported only for unit testing purposes
|
|
68
|
-
const addExcludedConnectionPropertiesToChanges = ({ proposedChanges, existingConnections, config }) => {
|
|
68
|
+
const addExcludedConnectionPropertiesToChanges = ({ proposedChanges, existingConnections, config, }) => {
|
|
69
69
|
var _a, _b;
|
|
70
70
|
if (proposedChanges.update.length === 0)
|
|
71
71
|
return proposedChanges;
|
|
72
|
+
//@ts-ignore because this expects a parameter to be passed
|
|
72
73
|
const excludedFields = ((_b = (_a = config()) === null || _a === void 0 ? void 0 : _a.EXCLUDED_PROPS) === null || _b === void 0 ? void 0 : _b.connections) || [];
|
|
73
74
|
if (excludedFields.length === 0)
|
|
74
75
|
return proposedChanges;
|
|
@@ -84,7 +85,9 @@ const addExcludedConnectionPropertiesToChanges = ({ proposedChanges, existingCon
|
|
|
84
85
|
const currentExcludedFieldValue = dot_prop_1.default.get(currConnection, excludedField);
|
|
85
86
|
dot_prop_1.default.set(agg, excludedField, currentExcludedFieldValue);
|
|
86
87
|
return agg;
|
|
87
|
-
}, {
|
|
88
|
+
}, {
|
|
89
|
+
options: {},
|
|
90
|
+
});
|
|
88
91
|
return Object.assign(Object.assign({}, proposedConnection), { options: Object.assign(Object.assign({}, proposedConnection.options), currentExcludedPropertyValues.options) });
|
|
89
92
|
});
|
|
90
93
|
return Object.assign(Object.assign({}, proposedChanges), { update: newProposedUpdates });
|
|
@@ -100,7 +103,7 @@ class ConnectionsHandler extends default_1.default {
|
|
|
100
103
|
getFormattedOptions(connection, clients) {
|
|
101
104
|
try {
|
|
102
105
|
return {
|
|
103
|
-
options: Object.assign(Object.assign({}, connection.options), { idpinitiated: Object.assign(Object.assign({}, connection.options.idpinitiated), { client_id: (0, utils_1.convertClientNameToId)(connection.options.idpinitiated.client_id, clients) }) })
|
|
106
|
+
options: Object.assign(Object.assign({}, connection.options), { idpinitiated: Object.assign(Object.assign({}, connection.options.idpinitiated), { client_id: (0, utils_1.convertClientNameToId)(connection.options.idpinitiated.client_id, clients) }) }),
|
|
104
107
|
};
|
|
105
108
|
}
|
|
106
109
|
catch (e) {
|
|
@@ -111,9 +114,14 @@ class ConnectionsHandler extends default_1.default {
|
|
|
111
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
115
|
if (this.existing)
|
|
113
116
|
return this.existing;
|
|
114
|
-
const connections = yield this.client.connections.getAll({
|
|
117
|
+
const connections = yield this.client.connections.getAll({
|
|
118
|
+
paginate: true,
|
|
119
|
+
include_totals: true,
|
|
120
|
+
});
|
|
115
121
|
// Filter out database connections
|
|
116
122
|
this.existing = connections.filter((c) => c.strategy !== 'auth0');
|
|
123
|
+
if (this.existing === null)
|
|
124
|
+
return [];
|
|
117
125
|
return this.existing;
|
|
118
126
|
});
|
|
119
127
|
}
|
|
@@ -125,13 +133,25 @@ class ConnectionsHandler extends default_1.default {
|
|
|
125
133
|
const { connections } = assets;
|
|
126
134
|
// Do nothing if not set
|
|
127
135
|
if (!connections)
|
|
128
|
-
return {
|
|
136
|
+
return {
|
|
137
|
+
del: [],
|
|
138
|
+
create: [],
|
|
139
|
+
update: [],
|
|
140
|
+
conflicts: [],
|
|
141
|
+
};
|
|
129
142
|
// Convert enabled_clients by name to the id
|
|
130
143
|
const clients = yield this.client.clients.getAll({ paginate: true, include_totals: true });
|
|
131
|
-
const existingConnections = yield this.client.connections.getAll({
|
|
144
|
+
const existingConnections = yield this.client.connections.getAll({
|
|
145
|
+
paginate: true,
|
|
146
|
+
include_totals: true,
|
|
147
|
+
});
|
|
132
148
|
const formatted = assets.connections.map((connection) => (Object.assign(Object.assign(Object.assign({}, connection), this.getFormattedOptions(connection, clients)), { enabled_clients: (0, utils_1.getEnabledClients)(assets, connection, existingConnections, clients) })));
|
|
133
149
|
const proposedChanges = yield _super.calcChanges.call(this, Object.assign(Object.assign({}, assets), { connections: formatted }));
|
|
134
|
-
const proposedChangesWithExcludedProperties = (0, exports.addExcludedConnectionPropertiesToChanges)({
|
|
150
|
+
const proposedChangesWithExcludedProperties = (0, exports.addExcludedConnectionPropertiesToChanges)({
|
|
151
|
+
proposedChanges,
|
|
152
|
+
existingConnections,
|
|
153
|
+
config: this.config,
|
|
154
|
+
});
|
|
135
155
|
return proposedChangesWithExcludedProperties;
|
|
136
156
|
});
|
|
137
157
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import DefaultAPIHandler from './default';
|
|
2
|
+
import { CalculatedChanges, Assets } from '../../../types';
|
|
3
|
+
export declare const schema: {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
strategy: {
|
|
9
|
+
type: string;
|
|
10
|
+
enum: string[];
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
name: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
options: {
|
|
17
|
+
type: string;
|
|
18
|
+
properties: {
|
|
19
|
+
customScripts: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
required: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default class DatabaseHandler extends DefaultAPIHandler {
|
|
30
|
+
constructor(config: DefaultAPIHandler);
|
|
31
|
+
objString(db: any): string;
|
|
32
|
+
getClientFN(fn: 'create' | 'delete' | 'getAll' | 'update'): Function;
|
|
33
|
+
getType(): Promise<import("../../../types").Asset>;
|
|
34
|
+
calcChanges(assets: Assets): Promise<CalculatedChanges>;
|
|
35
|
+
processChanges(assets: Assets): Promise<void>;
|
|
36
|
+
}
|