Skip to content

Commit

Permalink
fix: header formatting for Incognia + release (#282)
Browse files Browse the repository at this point in the history
* fix: header formatting for Incognia

* fix: header formatting for Incognia

* fix: header formatting for Incognia
  • Loading branch information
joshcanhelp authored Mar 30, 2021
1 parent a6d6ef8 commit 91e97ad
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 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.19.0",
"version": "0.19.1",
"description": "Auth0 Rules Repository",
"main": "./rules",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
"categories": [
"marketplace"
],
"description": "<p>Please see the <a href=\"https://marketplace.auth0.com/integrations/incognia-authentication\">Incognia Authentication 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>INCOGNIA<em>CLIENT</em>ID: The client ID obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n<li>INCOGNIA<em>CLIENT</em>SECRET: The client secret obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n</ul>",
"description": "<p>Please see the <a href=\"https://marketplace.auth0.com/integrations/incognia-authentication\">Incognia Authentication 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>INCOGNIA_CLIENT_ID</code>: The client ID obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n<li><code>INCOGNIA_CLIENT_SECRET</code>: The client secret obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n</ul>",
"code": "async function incogniaAuthenticationRule(user, context, callback) {\n const _ = require('[email protected]');\n\n const { IncogniaAPI } = require('@incognia/[email protected]');\n\n const { INCOGNIA_CLIENT_ID, INCOGNIA_CLIENT_SECRET } = configuration;\n\n if (!INCOGNIA_CLIENT_ID || !INCOGNIA_CLIENT_SECRET) {\n console.log('Missing required configuration. Skipping.');\n return callback(null, user, context);\n }\n\n const installationId = _.get(\n context,\n 'request.query.incognia_installation_id'\n );\n if (!installationId) {\n console.log('Missing installation_id. Skipping.');\n return callback(null, user, context);\n }\n\n const accountId = _.get(user, 'user_id');\n if (!accountId) {\n console.log('Missing user_id. Skipping.');\n return callback(null, user, context);\n }\n\n let incogniaAPI;\n if (global.incogniaAPI) {\n incogniaAPI = global.incogniaAPI;\n } else {\n incogniaAPI = new IncogniaAPI({\n clientId: INCOGNIA_CLIENT_ID,\n clientSecret: INCOGNIA_CLIENT_SECRET\n });\n global.incogniaAPI = incogniaAPI;\n }\n\n try {\n const loginAssessment = await incogniaAPI.registerLoginAssessment({\n installationId: installationId,\n accountId: accountId\n });\n\n // Incognia's risk assessment will be in a namespaced claim so it can be used in other rules\n // for skipping/prompting MFA or in the mobile app itself to decide whether the user should be\n // redirected to step-up auth for example.\n context.idToken['https://www.incognia.com/assessment'] =\n loginAssessment.riskAssessment;\n } catch (error) {\n console.log('Error calling Incognia API for a new login.');\n return callback(error);\n }\n\n return callback(null, user, context);\n}"
},
{
Expand All @@ -528,7 +528,7 @@
"categories": [
"marketplace"
],
"description": "<p>Please see the <a href=\"https://marketplace.auth0.com/integrations/incognia-onboarding\">Incognia Onboarding 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>INCOGNIA<em>CLIENT</em>ID: The client ID obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n<li>INCOGNIA<em>CLIENT</em>SECRET: The client secret obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n</ul>",
"description": "<p>Please see the <a href=\"https://marketplace.auth0.com/integrations/incognia-onboarding\">Incognia Onboarding 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>INCOGNIA_CLIENT_ID</code>: The client ID obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n<li><code>INCOGNIA_CLIENT_SECRET</code>: The client secret obtained from Incognia's dashboard (My Apps &gt; API Credentials)</li>\n</ul>",
"code": "async function incogniaOnboardingRule(user, context, callback) {\n const _ = require('[email protected]');\n\n const { IncogniaAPI } = require('@incognia/[email protected]');\n const { Auth0UserUpdateUtilities } = require('@auth0/[email protected]');\n\n const {\n INCOGNIA_CLIENT_ID,\n INCOGNIA_CLIENT_SECRET,\n INCOGNIA_HOME_ADDRESS_PROP\n } = configuration;\n\n if (!INCOGNIA_CLIENT_ID || !INCOGNIA_CLIENT_SECRET) {\n console.log('Missing required configuration. Skipping.');\n return callback(null, user, context);\n }\n\n const installationId = _.get(\n context,\n 'request.query.incognia_installation_id'\n );\n if (!installationId) {\n console.log('Missing installation_id. Skipping.');\n return callback(null, user, context);\n }\n\n // User home address should be set using Auth0's Signup API for example. If the home address is\n // not in 'user_metadata.home_address', please specify the path of the field inside the user\n // object where the home address is through the INCOGNIA_HOME_ADDRESS_PROP configuration.\n const homeAddressProp =\n INCOGNIA_HOME_ADDRESS_PROP || 'user_metadata.home_address';\n const homeAddress = _.get(user, homeAddressProp);\n if (!homeAddress) {\n console.log('Missing user home address. Skipping.');\n return callback(null, user, context);\n }\n\n const userUtils = new Auth0UserUpdateUtilities(user, auth0, 'incognia');\n\n const status = userUtils.getAppMeta('status');\n // This rule was previously run and calculated the assessment successfully.\n if (status && status !== 'pending') {\n console.log(\n 'Assessment is already calculated or is unevaluable. Skipping.'\n );\n return callback(null, user, context);\n }\n\n let incogniaAPI;\n if (global.incogniaAPI) {\n incogniaAPI = global.incogniaAPI;\n } else {\n incogniaAPI = new IncogniaAPI({\n clientId: INCOGNIA_CLIENT_ID,\n clientSecret: INCOGNIA_CLIENT_SECRET\n });\n global.incogniaAPI = incogniaAPI;\n }\n\n let onboardingAssessment;\n const signupId = userUtils.getAppMeta('signup_id');\n // The rule was previously run, but Incognia could not assess the signup.\n if (signupId) {\n try {\n onboardingAssessment = await incogniaAPI.getOnboardingAssessment(\n signupId\n );\n } catch (error) {\n console.log('Error calling Incognia API for signup previously submitted');\n return callback(error);\n }\n // This is the first time the rule is being run with all necessary arguments.\n } else {\n try {\n onboardingAssessment = await incogniaAPI.registerOnboardingAssessment({\n installationId: installationId,\n addressLine: homeAddress\n });\n } catch (error) {\n console.log('Error calling Incognia API for new signup submission');\n return callback(error);\n }\n }\n\n /*\n * Updates the status in the metadata now that the assessment was calculated. If the new\n * assessment is valid, the status will go to evaluated and this rule won't be executed again.\n * If Incognia still doesn't know how to assess the signup, it will try to calculate it again up\n * to 48 hours after the first try.\n */\n const firstAssessmentAt = userUtils.getAppMeta('first_assessment_at');\n let newStatus;\n if (onboardingAssessment.riskAssessment !== 'unknown_risk') {\n newStatus = 'evaluated';\n } else if (!firstAssessmentAt) {\n newStatus = 'pending';\n } else {\n const firstAssessmentAge =\n Math.round(Date.now() / 1000) - firstAssessmentAt;\n // 48 hours limit.\n if (firstAssessmentAge > 172800) {\n newStatus = 'unevaluable';\n } else {\n newStatus = 'pending';\n }\n }\n\n const updatedMetadata = {\n status: newStatus,\n first_assessment_at: firstAssessmentAt || Math.round(Date.now() / 1000),\n signup_id: onboardingAssessment.id,\n assessment: onboardingAssessment\n };\n\n try {\n userUtils.setAppMeta('incognia', updatedMetadata);\n await userUtils.updateAppMeta();\n } catch (error) {\n console.log('Error calling Auth0 management API');\n return callback(error);\n }\n\n return callback(null, user, context);\n}"
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/rules/incognia-authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*
* **Required configuration** (this Rule will be skipped if any of the below are not defined):
*
* - INCOGNIA_CLIENT_ID: The client ID obtained from Incognia's dashboard (My Apps > API Credentials)
* - INCOGNIA_CLIENT_SECRET: The client secret obtained from Incognia's dashboard (My Apps > API Credentials)
* - `INCOGNIA_CLIENT_ID`: The client ID obtained from Incognia's dashboard (My Apps > API Credentials)
* - `INCOGNIA_CLIENT_SECRET`: The client secret obtained from Incognia's dashboard (My Apps > API Credentials)
*/

async function incogniaAuthenticationRule(user, context, callback) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/incognia-onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*
* **Required configuration** (this Rule will be skipped if any of the below are not defined):
*
* - INCOGNIA_CLIENT_ID: The client ID obtained from Incognia's dashboard (My Apps > API Credentials)
* - INCOGNIA_CLIENT_SECRET: The client secret obtained from Incognia's dashboard (My Apps > API Credentials)
* - `INCOGNIA_CLIENT_ID`: The client ID obtained from Incognia's dashboard (My Apps > API Credentials)
* - `INCOGNIA_CLIENT_SECRET`: The client secret obtained from Incognia's dashboard (My Apps > API Credentials)
*/

async function incogniaOnboardingRule(user, context, callback) {
Expand Down

0 comments on commit 91e97ad

Please sign in to comment.