Skip to content

Commit

Permalink
Release 0.23.0 (#297)
Browse files Browse the repository at this point in the history
* version bump

* npm run format

* npm run release

* move cumul.io rule

* rebuild rules.json to add cumul.io rule
  • Loading branch information
joshcanhelp authored Aug 4, 2021
1 parent 2ea2be8 commit 16d75cf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rules-templates",
"version": "0.22.0",
"version": "0.23.0",
"description": "Auth0 Rules Repository",
"main": "./rules",
"scripts": {
Expand Down
30 changes: 20 additions & 10 deletions rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>This rule will deny access to an app from a specific set of IP addresses.</p>",
"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": "<p>This rule will only allow access to an app from a specific set of IP addresses</p>",
"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": "<p>This rule will only allow access to an app from a specific set of IP addresses</p>",
"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": "<p>This rule will deny access to an app from a specific set of IP addresses.</p>",
"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",
Expand Down Expand Up @@ -491,6 +491,16 @@
"description": "<p>Please see the <a href=\"https://marketplace.auth0.com/integrations/arengu-progressive-profiling\">Aregnu Progressive Profiling integration</a> for more information and detailed installation instructions.</p>\n<p><strong>Required configuration</strong> (this Rule will be skipped if any of the below are not defined):</p>\n<ul>\n<li><code>SESSION_TOKEN_SECRET</code>: A long, random string at least 32 bytes long</li>\n<li><code>ARENGU_PROFILE_FORM_URL</code>: The URL that contains an <a href=\"https://github.com/arengu/forms-js-sdk#embed-a-form\">embedded form</a> or with a <a href=\"https://www.arengu.com/pages\">hosted form page</a></li>\n</ul>",
"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/[email protected]');\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": "<p>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.</p>",
"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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 16d75cf

Please sign in to comment.