diff --git a/package-lock.json b/package-lock.json index f3f8109b..2788a37b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rules-templates", - "version": "0.21.0", + "version": "0.23.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 74ff4f90..4e219fcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rules-templates", - "version": "0.22.0", + "version": "0.23.0", "description": "Auth0 Rules Repository", "main": "./rules", "scripts": { diff --git a/rules.json b/rules.json index 4e50bc51..b5a383db 100644 --- a/rules.json +++ b/rules.json @@ -93,24 +93,24 @@ "code": "function emailVerified(user, context, callback) {\n if (!user.email_verified) {\n return callback(\n new UnauthorizedError('Please verify your email before logging in.')\n );\n } else {\n return callback(null, user, context);\n }\n}" }, { - "id": "ip-address-blocklist", - "title": "IP Address Blocklist", - "overview": "Do not allow access to an app from a specific set of IP addresses.", + "id": "ip-address-allowlist", + "title": "IP Address allowlist", + "overview": "Only allow access to an app from a specific set of IP addresses.", "categories": [ "access control" ], - "description": "

This rule will deny access to an app from a specific set of IP addresses.

", - "code": "function ipAddressBlocklist(user, context, callback) {\n const blocklist = ['1.2.3.4', '2.3.4.5']; // unauthorized IPs\n const notAuthorized = blocklist.some(function (ip) {\n return context.request.ip === ip;\n });\n\n if (notAuthorized) {\n return callback(\n new UnauthorizedError('Access denied from this IP address.')\n );\n }\n\n return callback(null, user, context);\n}" + "description": "

This rule will only allow access to an app from a specific set of IP addresses

", + "code": "function ipAddressAllowlist(user, context, callback) {\n const allowlist = ['1.2.3.4', '2.3.4.5']; // authorized IPs\n const userHasAccess = allowlist.some(function (ip) {\n return context.request.ip === ip;\n });\n\n if (!userHasAccess) {\n return callback(new Error('Access denied from this IP address.'));\n }\n\n return callback(null, user, context);\n}" }, { - "id": "ip-address-whitelist", - "title": "IP Address whitelist", - "overview": "Only allow access to an app from a specific set of IP addresses.", + "id": "ip-address-blocklist", + "title": "IP Address Blocklist", + "overview": "Do not allow access to an app from a specific set of IP addresses.", "categories": [ "access control" ], - "description": "

This rule will only allow access to an app from a specific set of IP addresses

", - "code": "function ipAddressWhitelist(user, context, callback) {\n const whitelist = ['1.2.3.4', '2.3.4.5']; // authorized IPs\n const userHasAccess = whitelist.some(function (ip) {\n return context.request.ip === ip;\n });\n\n if (!userHasAccess) {\n return callback(new Error('Access denied from this IP address.'));\n }\n\n return callback(null, user, context);\n}" + "description": "

This rule will deny access to an app from a specific set of IP addresses.

", + "code": "function ipAddressBlocklist(user, context, callback) {\n const blocklist = ['1.2.3.4', '2.3.4.5']; // unauthorized IPs\n const notAuthorized = blocklist.some(function (ip) {\n return context.request.ip === ip;\n });\n\n if (notAuthorized) {\n return callback(\n new UnauthorizedError('Access denied from this IP address.')\n );\n }\n\n return callback(null, user, context);\n}" }, { "id": "roles-creation", @@ -491,6 +491,16 @@ "description": "

Please see the Aregnu Progressive Profiling integration for more information and detailed installation instructions.

\n

Required configuration (this Rule will be skipped if any of the below are not defined):

\n", "code": "async function arenguCompleteUserProfile(user, context, callback) {\n if (\n !configuration.SESSION_TOKEN_SECRET ||\n !configuration.ARENGU_PROFILE_FORM_URL\n ) {\n console.log('Missing required configuration. Skipping.');\n return callback(null, user, context);\n }\n\n const {\n Auth0RedirectRuleUtilities,\n Auth0UserUpdateUtilities\n } = require('@auth0/rule-utilities@0.2.0');\n\n const ruleUtils = new Auth0RedirectRuleUtilities(\n user,\n context,\n configuration\n );\n\n const userUtils = new Auth0UserUpdateUtilities(user, auth0);\n\n function validateSessionToken() {\n try {\n return ruleUtils.validateSessionToken();\n } catch (error) {\n callback(error);\n }\n }\n\n // Modify your login criteria to your needs\n function isLogin() {\n const loginCount = configuration.ARENGU_PROFILE_LOGIN_COUNT || 2;\n return context.stats.loginsCount > parseInt(loginCount, 10);\n }\n\n function isEmptyUserMeta(key) {\n return (\n userUtils.getUserMeta(key) === undefined ||\n userUtils.getUserMeta(key) === null ||\n userUtils.getUserMeta(key).length === 0\n );\n }\n\n function isProfileIncomplete() {\n // Add your required user_medata keys\n return isEmptyUserMeta('job_title') || isEmptyUserMeta('company_name');\n }\n\n if (ruleUtils.isRedirectCallback && ruleUtils.queryParams.session_token) {\n const decodedToken = validateSessionToken();\n const customClaims = decodedToken.other;\n\n for (const [key, value] of Object.entries(customClaims)) {\n userUtils.setUserMeta(key, value);\n }\n\n try {\n await userUtils.updateUserMeta();\n\n return callback(null, user, context);\n } catch (error) {\n return callback(error);\n }\n }\n\n if (isLogin() && isProfileIncomplete()) {\n ruleUtils.doRedirect(configuration.ARENGU_PROFILE_FORM_URL);\n }\n\n return callback(null, user, context);\n}" }, + { + "id": "cumulio-add-metadata-to-tokens", + "title": "User metadata for Cumul.io", + "overview": "Add Cumul.io user metadata to tokens to be used for Cumul.io dashboard filtering", + "categories": [ + "marketplace" + ], + "description": "

This integration simplifies the process of making full use of integrated Cumul.io dashboards' multi tenant features\nby using Auth0 as its authentication layer. The integration will allow you to set up and use user\ninformation in Auth0 to filter and structure your Cumul.io dashboards.

", + "code": "function addMetadataToTokens(user, context, callback) {\n const namespace = 'https://cumulio/';\n user.user_metadata = user.user_metadata || {};\n const cumulioMetadata = user.user_metadata.cumulio || {};\n if (typeof cumulioMetadata === 'object' && cumulioMetadata !== null) {\n Object.keys(cumulioMetadata).forEach((k) => {\n context.idToken[namespace + k] = cumulioMetadata[k];\n context.accessToken[namespace + k] = cumulioMetadata[k];\n });\n } else {\n console.log(\n 'Make sure that user_metadata.cumulio is an object with keys and values'\n );\n return;\n }\n callback(null, user, context);\n}" + }, { "id": "eva-voice-biometric", "title": "EVA Voice Biometric connector", diff --git a/src/rules/a/cumulio-add-metadata-to-tokens.js b/src/rules/cumulio-add-metadata-to-tokens.js similarity index 74% rename from src/rules/a/cumulio-add-metadata-to-tokens.js rename to src/rules/cumulio-add-metadata-to-tokens.js index a69ffb8e..8ca7c2d9 100644 --- a/src/rules/a/cumulio-add-metadata-to-tokens.js +++ b/src/rules/cumulio-add-metadata-to-tokens.js @@ -4,24 +4,24 @@ * @gallery true * @category marketplace * - * This integration simplifies the process of making full use of integrated Cumul.io dashboards' multi tenant features - * by using Auth0 as its authentication layer. The integration will allow you to set up and use user + * This integration simplifies the process of making full use of integrated Cumul.io dashboards' multi tenant features + * by using Auth0 as its authentication layer. The integration will allow you to set up and use user * information in Auth0 to filter and structure your Cumul.io dashboards. */ - function addMetadataToTokens(user, context, callback) { const namespace = 'https://cumulio/'; user.user_metadata = user.user_metadata || {}; const cumulioMetadata = user.user_metadata.cumulio || {}; - if(typeof cumulioMetadata === 'object' && cumulioMetadata !== null){ + if (typeof cumulioMetadata === 'object' && cumulioMetadata !== null) { Object.keys(cumulioMetadata).forEach((k) => { context.idToken[namespace + k] = cumulioMetadata[k]; context.accessToken[namespace + k] = cumulioMetadata[k]; }); - } - else{ - console.log("Make sure that user_metadata.cumulio is an object with keys and values"); + } else { + console.log( + 'Make sure that user_metadata.cumulio is an object with keys and values' + ); return; } callback(null, user, context);