@auth0/auth0-checkmate 1.4.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.
Files changed (114) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/workflows/npm-release.yml +77 -0
  3. package/.github/workflows/sca_scan.yml +10 -0
  4. package/.github/workflows/test.yml +48 -0
  5. package/AUTHORS +5 -0
  6. package/LICENSE +203 -0
  7. package/README.md +166 -0
  8. package/THIRD-PARTY-NOTICES +226 -0
  9. package/analyzer/lib/actions/checkActionsHardCodedValues.js +151 -0
  10. package/analyzer/lib/actions/checkActionsRuntime.js +105 -0
  11. package/analyzer/lib/actions/checkDependencies.js +111 -0
  12. package/analyzer/lib/attack_protection/checkBotDetectionSetting.js +76 -0
  13. package/analyzer/lib/attack_protection/checkBreachedPassword.js +140 -0
  14. package/analyzer/lib/attack_protection/checkBruteForce.js +89 -0
  15. package/analyzer/lib/attack_protection/checkSuspiciousIPThrottling.js +89 -0
  16. package/analyzer/lib/canonical_domain/checkCanonicalDomain.js +63 -0
  17. package/analyzer/lib/clients/checkAllowedCallbacks.js +122 -0
  18. package/analyzer/lib/clients/checkAllowedLogoutUrl.js +124 -0
  19. package/analyzer/lib/clients/checkApplicationLoginUri.js +125 -0
  20. package/analyzer/lib/clients/checkCrossOriginAuthentication.js +91 -0
  21. package/analyzer/lib/clients/checkGrantTypes.js +138 -0
  22. package/analyzer/lib/clients/checkJWTSignAlg.js +118 -0
  23. package/analyzer/lib/clients/checkRefreshToken.js +108 -0
  24. package/analyzer/lib/clients/checkWebOrigins.js +55 -0
  25. package/analyzer/lib/constants.js +63 -0
  26. package/analyzer/lib/custom_domain/checkCustomDomain.js +53 -0
  27. package/analyzer/lib/databases/checkAuthenticationMethods.js +98 -0
  28. package/analyzer/lib/databases/checkDASHardCodedValues.js +163 -0
  29. package/analyzer/lib/databases/checkEmailAttributeVerification.js +114 -0
  30. package/analyzer/lib/databases/checkEnabledDatabaseCustomization.js +83 -0
  31. package/analyzer/lib/databases/checkPasswordComplexity.js +100 -0
  32. package/analyzer/lib/databases/checkPasswordHistory.js +92 -0
  33. package/analyzer/lib/databases/checkPasswordNoPersonalInfo.js +91 -0
  34. package/analyzer/lib/databases/checkPasswordPolicy.js +95 -0
  35. package/analyzer/lib/databases/checkPromotedDBConnection.js +96 -0
  36. package/analyzer/lib/email_provider/checkEmailProvider.js +37 -0
  37. package/analyzer/lib/email_templates/checkEmailTemplates.js +71 -0
  38. package/analyzer/lib/error_page_template/checkErrorPageTemplate.js +153 -0
  39. package/analyzer/lib/event_streams/checkEventStreams.js +71 -0
  40. package/analyzer/lib/executeCheck.js +12 -0
  41. package/analyzer/lib/hooks/checkHooks.js +43 -0
  42. package/analyzer/lib/listOfAnalyser.js +24 -0
  43. package/analyzer/lib/log_streams/checkLogStream.js +60 -0
  44. package/analyzer/lib/logger.js +16 -0
  45. package/analyzer/lib/multifactor/checkGuardianFactors.js +72 -0
  46. package/analyzer/lib/multifactor/checkGuardianPolicy.js +40 -0
  47. package/analyzer/lib/network_acl/checkNetworkACL.js +35 -0
  48. package/analyzer/lib/rules/checkRules.js +102 -0
  49. package/analyzer/lib/tenant_settings/checkDefaultAudience.js +53 -0
  50. package/analyzer/lib/tenant_settings/checkDefaultDirectory.js +48 -0
  51. package/analyzer/lib/tenant_settings/checkEnabledDynamicClientRegistration.js +60 -0
  52. package/analyzer/lib/tenant_settings/checkSandboxVersion.js +37 -0
  53. package/analyzer/lib/tenant_settings/checkSessionLifetime.js +95 -0
  54. package/analyzer/lib/tenant_settings/checkSupportEmail.js +61 -0
  55. package/analyzer/lib/tenant_settings/checkSupportUrl.js +61 -0
  56. package/analyzer/lib/tenant_settings/checkTenantLoginUrl.js +71 -0
  57. package/analyzer/lib/tenant_settings/checkTenantLogoutUrl.js +60 -0
  58. package/analyzer/report.js +404 -0
  59. package/analyzer/tools/auth0.js +443 -0
  60. package/analyzer/tools/helpers.js +71 -0
  61. package/analyzer/tools/summary.js +84 -0
  62. package/analyzer/tools/utils.js +72 -0
  63. package/bin/index.js +393 -0
  64. package/eslint.config.mjs +16 -0
  65. package/images/auth0.png +0 -0
  66. package/images/okta.png +0 -0
  67. package/locales/en.json +1417 -0
  68. package/package.json +66 -0
  69. package/tests/actions/checkActionsHardCodedValues.test.js +106 -0
  70. package/tests/actions/checkActionsRuntime.test.js +102 -0
  71. package/tests/actions/checkDependencies.test.js +131 -0
  72. package/tests/attack_protection/checkBreachedPassword.test.js +253 -0
  73. package/tests/attack_protection/checkBruteForce.test.js +181 -0
  74. package/tests/attack_protection/checkSuspiciousIPThrottling.test.js +222 -0
  75. package/tests/canonical_domain/checkCanonicalDomain.test.js +94 -0
  76. package/tests/clients/checkAllowedCallbacks.test.js +149 -0
  77. package/tests/clients/checkAllowedLogoutUrl.test.js +149 -0
  78. package/tests/clients/checkApplicationLoginUri.test.js +180 -0
  79. package/tests/clients/checkCrossOriginAuthentication.test.js +99 -0
  80. package/tests/clients/checkGrantTypes.test.js +154 -0
  81. package/tests/clients/checkJWTSignAlg.test.js +121 -0
  82. package/tests/clients/checkRefreshToken.test.js +63 -0
  83. package/tests/clients/checkWebOrigins.test.js +140 -0
  84. package/tests/custom_domain/checkCustomDomain.test.js +73 -0
  85. package/tests/databases/checkAuthenticationMethods.test.js +124 -0
  86. package/tests/databases/checkDASHardCodedValues.test.js +77 -0
  87. package/tests/databases/checkEmailAttributeVerification.test.js +79 -0
  88. package/tests/databases/checkEnabledDatabaseCustomization.test.js +68 -0
  89. package/tests/databases/checkPasswordComplexity.test.js +127 -0
  90. package/tests/databases/checkPasswordHistory.test.js +100 -0
  91. package/tests/databases/checkPasswordNoPersonalInfo.test.js +94 -0
  92. package/tests/databases/checkPasswordPolicy.test.js +161 -0
  93. package/tests/databases/checkPromotedDBConnection.test.js +62 -0
  94. package/tests/email_provider/checkEmailProvider.test.js +58 -0
  95. package/tests/email_templates/checkEmailTemplates.test.js +120 -0
  96. package/tests/error_page_template/checkErrorPageTemplate.test.js +315 -0
  97. package/tests/event_streams/checkEventStreams.test.js +118 -0
  98. package/tests/hooks/checkHooks.test.js +112 -0
  99. package/tests/log_streams/checkLogStream.test.js +140 -0
  100. package/tests/multifactor/checkGuardianFactors.test.js +94 -0
  101. package/tests/multifactor/checkGuardianPolicy.test.js +49 -0
  102. package/tests/rules/checkRules.test.js +102 -0
  103. package/tests/tenant_settings/checkDefaultAudience.test.js +62 -0
  104. package/tests/tenant_settings/checkDefaultDirectory.test.js +62 -0
  105. package/tests/tenant_settings/checkEnabledDynamicClientRegistration.test.js +97 -0
  106. package/tests/tenant_settings/checkSandboxVersion.test.js +50 -0
  107. package/tests/tenant_settings/checkSessionLifetime.test.js +108 -0
  108. package/tests/tenant_settings/checkSupportEmail.test.js +77 -0
  109. package/tests/tenant_settings/checkSupportUrl.test.js +77 -0
  110. package/tests/tenant_settings/checkTenantLoginUri.test.js +82 -0
  111. package/tests/tenant_settings/checkTenantLogoutUrl.test.js +108 -0
  112. package/tests/tools/auth0.test.js +833 -0
  113. package/tests/tools/helpers.test.js +692 -0
  114. package/views/pdf_cli_report.handlebars +571 -0
@@ -0,0 +1,140 @@
1
+ /*
2
+ {
3
+ attackProtection: {
4
+ breachedPasswordDetection: {
5
+ "enabled": true,
6
+ "shields": [
7
+ "user_notification",
8
+ "admin_notification",
9
+ "block"
10
+ ],
11
+ "admin_notification_frequency": [
12
+ "daily",
13
+ "monthly",
14
+ "weekly",
15
+ "immediately"
16
+ ],
17
+ "method": "standard|enhanced",
18
+ "stage": {
19
+ "pre-user-registration": {
20
+ "shields": [
21
+ "block",
22
+ "admin_notification"
23
+ ]
24
+ },
25
+ "pre-change-password": {
26
+ "shields": [
27
+ "block"
28
+ ]
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ */
35
+ const _ = require("lodash");
36
+ const executeCheck = require("../executeCheck");
37
+ const CONSTANTS = require("../constants");
38
+
39
+ // Expected values
40
+ const validShields = ["user_notification", "admin_notification", "block"];
41
+ const validFrequencies = ["daily", "monthly", "weekly", "immediately"];
42
+ const validMethods = ["standard", "enhanced"];
43
+
44
+ // Function to validate configuration
45
+ function validateBreachedPasswordConfig(config) {
46
+ const report = [];
47
+ if (_.isEmpty(config)) {
48
+ return report;
49
+ }
50
+ // Validate "enabled"
51
+ if (config.enabled) {
52
+ report.push({ field: "enabled", status: CONSTANTS.SUCCESS });
53
+ } else {
54
+ report.push({ field: "disabled", status: CONSTANTS.FAIL });
55
+ }
56
+
57
+ // Validate "shields"
58
+ if (config.shields && config.shields.length > 0) {
59
+ if (config.shields.some((shield) => !validShields.includes(shield))) {
60
+ report.push({ field: "shields_invalid_values", status: CONSTANTS.FAIL });
61
+ } else {
62
+ report.push({
63
+ field: "shields_values",
64
+ value: config.shields.length > 0 ? config.shields.join(", ") : "empty",
65
+ status: CONSTANTS.SUCCESS,
66
+ });
67
+ }
68
+ }
69
+ if (!config.shields.includes("block")) {
70
+ report.push({
71
+ field: "stage_login_shields_block_not_configured",
72
+ status: CONSTANTS.FAIL,
73
+ });
74
+ }
75
+
76
+ if (config.stage["pre-user-registration"] && !config.stage["pre-user-registration"].shields.includes("block")) {
77
+ report.push({
78
+ field: "stage_pre_user_shields_block_not_configured",
79
+ status: CONSTANTS.FAIL,
80
+ });
81
+ }
82
+
83
+ if (
84
+ config.stage["pre-change-password"] &&
85
+ !config.stage["pre-change-password"].shields.includes("block")
86
+ ) {
87
+ report.push({
88
+ field: "stage_pre_change_password_shields_block_not_configured",
89
+ status: CONSTANTS.FAIL,
90
+ });
91
+ }
92
+ // Validate "admin_notification_frequency"
93
+ if (
94
+ config.admin_notification_frequency &&
95
+ config.admin_notification_frequency.length > 0
96
+ ) {
97
+ if (
98
+ config.admin_notification_frequency.some(
99
+ (freq) => !validFrequencies.includes(freq),
100
+ )
101
+ ) {
102
+ report.push({
103
+ field: "admin_frequency_invalid_values",
104
+ value: config.admin_notification_frequency.join(", "),
105
+ status: CONSTANTS.FAIL,
106
+ });
107
+ } else {
108
+ report.push({
109
+ field: "admin_frequency_values",
110
+ value: config.admin_notification_frequency.join(", "),
111
+ status: CONSTANTS.SUCCESS,
112
+ });
113
+ }
114
+ }
115
+
116
+ // Validate "method"
117
+ if (!validMethods.includes(config.method)) {
118
+ report.push({ field: "method_invalid_value", status: CONSTANTS.FAIL });
119
+ } else {
120
+ report.push({
121
+ field: "method_value",
122
+ value: config.method,
123
+ status: CONSTANTS.SUCCESS,
124
+ });
125
+ }
126
+
127
+ if (config.enabled && config.shields.length === 0) {
128
+ report.push({ field: "monitoring_mode", status: CONSTANTS.FAIL });
129
+ }
130
+ return report;
131
+ }
132
+
133
+ function checkBreachedPassword(options) {
134
+ const { breachedPasswordDetection } = options.attackProtection || {};
135
+ return executeCheck("checkBreachedPassword", (callback) => {
136
+ return callback(validateBreachedPasswordConfig(breachedPasswordDetection));
137
+ });
138
+ }
139
+
140
+ module.exports = checkBreachedPassword;
@@ -0,0 +1,89 @@
1
+ /*
2
+ {
3
+ attackProtection: {
4
+ bruteForceProtection: {
5
+ "enabled": true,
6
+ "shields": [
7
+ "block",
8
+ "user_notification"
9
+ ],
10
+ "mode": "count_per_identifier_and_ip",
11
+ "allowlist": [],
12
+ "max_attempts": 3
13
+ }
14
+ }
15
+ */
16
+ const _ = require("lodash");
17
+ const executeCheck = require("../executeCheck");
18
+ const CONSTANTS = require("../constants");
19
+
20
+ // Validation Rules
21
+ function validateBruteForceSettings(config) {
22
+ const report = [];
23
+ if (_.isEmpty(config)) {
24
+ return report;
25
+ }
26
+ // Check if brute force protection is enabled
27
+ if (config.enabled) {
28
+ report.push({
29
+ field: "enabled",
30
+ status: CONSTANTS.SUCCESS,
31
+ });
32
+ } else {
33
+ report.push({
34
+ field: "disabled",
35
+ status: CONSTANTS.FAIL,
36
+ });
37
+ }
38
+
39
+ // Validate shields
40
+ const requiredShields = ["block", "user_notification"];
41
+ const requiredModes = ["count_per_identifier"];
42
+ const missingShields = requiredShields.filter(
43
+ (shield) => !config.shields.includes(shield),
44
+ );
45
+ if (missingShields.length === 0) {
46
+ report.push({
47
+ field: "shieldsConfigured",
48
+ status: CONSTANTS.SUCCESS,
49
+ });
50
+ } else {
51
+ report.push({
52
+ field: "shieldsMissing",
53
+ status: CONSTANTS.FAIL,
54
+ value: missingShields.join(", "),
55
+ });
56
+ }
57
+
58
+ // Check allowlist
59
+ if (config.allowlist.length > 0) {
60
+ report.push({
61
+ field: "allowlistPresent",
62
+ status: CONSTANTS.FAIL,
63
+ value: config.allowlist.join(", "),
64
+ });
65
+ } else {
66
+ report.push({
67
+ field: "allowlistEmpty",
68
+ status: CONSTANTS.SUCCESS,
69
+ });
70
+ }
71
+ // validate account lock out mode settings
72
+ if (config?.mode && !requiredModes.includes(config?.mode)) {
73
+ report.push({
74
+ field: "enableAccountLockout",
75
+ status: CONSTANTS.FAIL,
76
+ value: config?.mode
77
+ });
78
+ }
79
+ // Return the validation report
80
+ return report;
81
+ }
82
+ function checkBruteForce(options) {
83
+ const { bruteForceProtection } = options.attackProtection || {};
84
+ return executeCheck("checkBruteForce", (callback) => {
85
+ return callback(validateBruteForceSettings(bruteForceProtection));
86
+ });
87
+ }
88
+
89
+ module.exports = checkBruteForce;
@@ -0,0 +1,89 @@
1
+ /*
2
+ {
3
+ attackProtection: {
4
+ suspiciousIpThrottling: {
5
+ "enabled": true,
6
+ "shields": [
7
+ "admin_notification",
8
+ "block"
9
+ ],
10
+ "allowlist": [],
11
+ "stage": {
12
+ "pre-login": {
13
+ "max_attempts": 100,
14
+ "rate": 864000
15
+ },
16
+ "pre-user-registration": {
17
+ "max_attempts": 50,
18
+ "rate": 1200
19
+ }
20
+ }
21
+ }
22
+ }
23
+ */
24
+ const _ = require("lodash");
25
+ const executeCheck = require("../executeCheck");
26
+ const CONSTANTS = require("../constants");
27
+
28
+ // Validation Rules
29
+ function validateSettings(config) {
30
+ const report = [];
31
+ if (_.isEmpty(config)) {
32
+ return report;
33
+ }
34
+ // Check if brute force protection is enabled
35
+ if (config.enabled) {
36
+ report.push({
37
+ field: "enabled",
38
+ status: CONSTANTS.SUCCESS,
39
+ });
40
+ } else {
41
+ report.push({
42
+ field: "disabled",
43
+ status: CONSTANTS.FAIL,
44
+ });
45
+ }
46
+
47
+ // Validate shields
48
+ const requiredShields = ["block", "admin_notification"];
49
+ const missingShields = requiredShields.filter(
50
+ (shield) => !config.shields.includes(shield),
51
+ );
52
+ if (missingShields.length === 0) {
53
+ report.push({
54
+ field: "shieldsConfigured",
55
+ status: CONSTANTS.SUCCESS,
56
+ });
57
+ } else {
58
+ report.push({
59
+ field: "shieldsMissing",
60
+ status: CONSTANTS.FAIL,
61
+ value: missingShields.join(", "),
62
+ });
63
+ }
64
+
65
+ // Check allowlist
66
+ if (config.allowlist.length > 0) {
67
+ report.push({
68
+ field: "allowlistPresent",
69
+ status: CONSTANTS.FAIL,
70
+ value: config.allowlist.join(", "),
71
+ });
72
+ } else {
73
+ report.push({
74
+ field: "allowlistEmpty",
75
+ status: CONSTANTS.SUCCESS,
76
+ });
77
+ }
78
+
79
+ // Return the validation report
80
+ return report;
81
+ }
82
+ function checkSuspiciousIPThrottling(options) {
83
+ const { suspiciousIpThrottling } = options.attackProtection || {};
84
+ return executeCheck("checkSuspiciousIPThrottling", (callback) => {
85
+ return callback(validateSettings(suspiciousIpThrottling));
86
+ });
87
+ }
88
+
89
+ module.exports = checkSuspiciousIPThrottling;
@@ -0,0 +1,63 @@
1
+ /*
2
+ {
3
+ customDomains: [
4
+ {
5
+ domain: 'constoso.com',
6
+ primary: true,
7
+ status: 'ready',
8
+ tls_policy: 'recommended',
9
+ type: 'auth0_managed_certs',
10
+ verification: [Object]
11
+ }
12
+ ],
13
+ logs: [
14
+ {
15
+ type: 's',
16
+ hostname: 'contoso.us.auth0.com',
17
+ _id: '90020250210004837491441000000000000001223372036874609060'
18
+ }
19
+ ]
20
+ }
21
+ */
22
+ const _ = require("lodash");
23
+ const executeCheck = require("../executeCheck");
24
+ const CONSTANTS = require("../constants");
25
+ function checkCanonicalDomain(options) {
26
+ const { customDomains, logs, log_query } = options || {
27
+ customDomains: [],
28
+ logs: [],
29
+ };
30
+ return executeCheck("checkCanonicalDomain", (callback) => {
31
+ const report = [];
32
+ if (_.isEmpty(logs)) {
33
+ report.push({
34
+ field: "canonical_domain_no_logs",
35
+ value: `<br> ${log_query}`,
36
+ status: CONSTANTS.FAIL,
37
+ });
38
+ return callback(report);
39
+ }
40
+ if (_.isEmpty(customDomains) && !_.isEmpty(logs)) {
41
+ report.push({
42
+ field: "canonical_domain_used",
43
+ value: `<br> ${log_query} <br> log_id: ${logs[0]._id}`,
44
+ status: CONSTANTS.FAIL,
45
+ });
46
+ return callback(report);
47
+ }
48
+ // Finding a match
49
+ const matchedLog = _.find(logs, (log) => {
50
+ return _.some(customDomains, (domain) => log.hostname === domain.domain);
51
+ });
52
+ if (_.isEmpty(matchedLog)) {
53
+ report.push({
54
+ field: "canonical_domain_used",
55
+ value: `<br> ${log_query} <br> log_id: ${logs[0]._id}`,
56
+ status: CONSTANTS.FAIL,
57
+ });
58
+ }
59
+ return callback(report);
60
+ });
61
+ }
62
+
63
+ module.exports = checkCanonicalDomain;
@@ -0,0 +1,122 @@
1
+ /*
2
+ {
3
+ clients: [
4
+ {
5
+ "tenant": "contos0",
6
+ "global": false,
7
+ "is_token_endpoint_ip_header_trusted": false,
8
+ "name": "Default App",
9
+ "is_first_party": true,
10
+ "oidc_conformant": true,
11
+ "sso_disabled": false,
12
+ "cross_origin_auth": false,
13
+ "refresh_token": {
14
+ "expiration_type": "expiring",
15
+ "leeway": 0,
16
+ "token_lifetime": 2592000,
17
+ "idle_token_lifetime": 1296000,
18
+ "infinite_token_lifetime": false,
19
+ "infinite_idle_token_lifetime": false,
20
+ "rotation_type": "rotating"
21
+ },
22
+ "allowed_clients": [],
23
+ "allowed_logout_urls": [
24
+ "http://localhost:3000"
25
+ ],
26
+ "callbacks": [
27
+ "http://localhost:3000"
28
+ ],
29
+ "native_social_login": {
30
+ "apple": {
31
+ "enabled": false
32
+ },
33
+ "facebook": {
34
+ "enabled": false
35
+ }
36
+ },
37
+ "client_id": "client_id",
38
+ "callback_url_template": false,
39
+ "jwt_configuration": {
40
+ "alg": "RS256",
41
+ "lifetime_in_seconds": 36000,
42
+ "secret_encoded": false
43
+ },
44
+ "client_aliases": [],
45
+ "token_endpoint_auth_method": "none",
46
+ "app_type": "spa",
47
+ "grant_types": [
48
+ "authorization_code",
49
+ "implicit",
50
+ "refresh_token"
51
+ ],
52
+ "web_origins": [
53
+ "http://localhost:3000"
54
+ ],
55
+ "custom_login_page_on": true
56
+ }
57
+ ]
58
+ }
59
+ */
60
+ const _ = require("lodash");
61
+ const executeCheck = require("../executeCheck");
62
+ const CONSTANTS = require("../constants");
63
+
64
+ // Function to check callback URLs for insecure patterns (localhost, http, 127.0.0.1)
65
+ function checkCallbackURLsForApp(app) {
66
+ const callbackUrls = app.callbacks || [];
67
+ const report = [];
68
+ const insecurePatterns = ["localhost", "http://", "127.0.0.1"];
69
+ if (callbackUrls.length === 0 && app.app_type !== "non_interactive") {
70
+ report.push({
71
+ name: app.client_id ? app.name.concat(` (${app.client_id})`) : app.name,
72
+ client_id: app.client_id || app.name,
73
+ field: "missing_callbacks",
74
+ url: "",
75
+ status: CONSTANTS.SUCCESS,
76
+ app_type: app.app_type,
77
+ });
78
+ }
79
+ callbackUrls.forEach((url) => {
80
+ const subArr = insecurePatterns.filter((str) => url.includes(str));
81
+ if (subArr.length > 0) {
82
+ report.push({
83
+ name: app.client_id ? app.name.concat(` (${app.client_id})`) : app.name,
84
+ client_id: app.client_id || app.name,
85
+ field: "insecure_callbacks",
86
+ value: url,
87
+ status: CONSTANTS.FAIL,
88
+ app_type: app.app_type,
89
+ is_first_party: app.is_first_party
90
+ });
91
+ }
92
+ });
93
+ return report;
94
+ }
95
+
96
+ function checkAllowedCallbacks(options) {
97
+ return executeCheck("checkAllowedCallbacks", (callback) => {
98
+ const { clients } = options;
99
+ const reports = [];
100
+ if (_.isEmpty(clients)) {
101
+ return callback(reports);
102
+ }
103
+ clients.forEach((client) => {
104
+ var report = checkCallbackURLsForApp(client);
105
+ if (report.length === 0) {
106
+ report.push({
107
+ name: client.name,
108
+ client_id: client.client_id || client.name,
109
+ field: "secure_callbacks",
110
+ status: CONSTANTS.SUCCESS,
111
+ value: client.callbacks ? client.callbacks.join(", ") : "",
112
+ app_type: client.app_type || "unknown",
113
+ is_first_party: client.is_first_party
114
+ });
115
+ }
116
+ reports.push({ name: client.name.concat(` (${client.client_id})`), report: report });
117
+ });
118
+ return callback(reports);
119
+ });
120
+ }
121
+
122
+ module.exports = checkAllowedCallbacks;
@@ -0,0 +1,124 @@
1
+ /*
2
+ {
3
+ clients: [
4
+ {
5
+ "tenant": "contos0",
6
+ "global": false,
7
+ "is_token_endpoint_ip_header_trusted": false,
8
+ "name": "Default App",
9
+ "is_first_party": true,
10
+ "oidc_conformant": true,
11
+ "sso_disabled": false,
12
+ "cross_origin_auth": false,
13
+ "refresh_token": {
14
+ "expiration_type": "expiring",
15
+ "leeway": 0,
16
+ "token_lifetime": 2592000,
17
+ "idle_token_lifetime": 1296000,
18
+ "infinite_token_lifetime": false,
19
+ "infinite_idle_token_lifetime": false,
20
+ "rotation_type": "rotating"
21
+ },
22
+ "allowed_clients": [],
23
+ "allowed_logout_urls": [
24
+ "http://localhost:3000"
25
+ ],
26
+ "callbacks": [
27
+ "http://localhost:3000"
28
+ ],
29
+ "native_social_login": {
30
+ "apple": {
31
+ "enabled": false
32
+ },
33
+ "facebook": {
34
+ "enabled": false
35
+ }
36
+ },
37
+ "client_id": "client_id",
38
+ "callback_url_template": false,
39
+ "jwt_configuration": {
40
+ "alg": "RS256",
41
+ "lifetime_in_seconds": 36000,
42
+ "secret_encoded": false
43
+ },
44
+ "client_aliases": [],
45
+ "token_endpoint_auth_method": "none",
46
+ "app_type": "spa",
47
+ "grant_types": [
48
+ "authorization_code",
49
+ "implicit",
50
+ "refresh_token"
51
+ ],
52
+ "web_origins": [
53
+ "http://localhost:3000"
54
+ ],
55
+ "custom_login_page_on": true
56
+ }
57
+ ]
58
+ }
59
+ */
60
+ const _ = require("lodash");
61
+ const executeCheck = require("../executeCheck");
62
+ const CONSTANTS = require("../constants");
63
+ // Function to check callback URLs for insecure patterns (localhost, http, 127.0.0.1)
64
+ function checkURLsForApp(app) {
65
+ const allowed_logout_urls = app.allowed_logout_urls || [];
66
+ const report = [];
67
+ const insecurePatterns = ["localhost", "http://", "127.0.0.1"];
68
+ if (allowed_logout_urls.length === 0 && app.app_type !== "non_interactive") {
69
+ // report.push({
70
+ // name: app.name.concat(` (${app.client_id})`),
71
+ // client_id: app.client_id || app.name,
72
+ // field: 'missing_allowed_logout_urls',
73
+ // url: 'missing_allowed_logout_urls',
74
+ // status: CONSTANTS.FAIL,
75
+ // app_type: app.app_type
76
+ // });
77
+ return report;
78
+ }
79
+ allowed_logout_urls.forEach((url) => {
80
+ const subArr = insecurePatterns.filter((str) => url.includes(str));
81
+ if (subArr.length > 0) {
82
+ report.push({
83
+ name: app.client_id ? app.name.concat(` (${app.client_id})`) : app.name,
84
+ client_id: app.client_id || app.name,
85
+ field: "insecure_allowed_logout_urls",
86
+ value: url,
87
+ status: CONSTANTS.FAIL,
88
+ app_type: app.app_type,
89
+ is_first_party: app.is_first_party
90
+ });
91
+ }
92
+ });
93
+ return report;
94
+ }
95
+
96
+ function checkAllowedLogoutUrl(options) {
97
+ return executeCheck("checkAllowedLogoutUrl", (callback) => {
98
+ const { clients } = options;
99
+ const reports = [];
100
+ if (_.isEmpty(clients)) {
101
+ return callback(reports);
102
+ }
103
+ clients.forEach((client) => {
104
+ var report = checkURLsForApp(client);
105
+ if (report.length === 0) {
106
+ report.push({
107
+ name: client.name,
108
+ client_id: client.client_id || client.name,
109
+ field: "secure_allowed_logout_urls",
110
+ status: CONSTANTS.SUCCESS,
111
+ value: client.allowed_logout_urls
112
+ ? client.allowed_logout_urls.join(", ")
113
+ : "",
114
+ app_type: client.app_type || "unknown",
115
+ is_first_party: client.is_first_party
116
+ });
117
+ }
118
+ reports.push({ name: client.name.concat(` (${client.client_id})`), report: report });
119
+ });
120
+ return callback(reports);
121
+ });
122
+ }
123
+
124
+ module.exports = checkAllowedLogoutUrl;