Skip to content

Commit

Permalink
Cumul.io Rule (#296)
Browse files Browse the repository at this point in the history
* Cumul.io Rule

Adding the rule here for the marketplace integration. Adds user_metadata.cumulio to id and access tokens to be used within cumulio. 
I've also added a warning as to this is what the integration does to the installation guideline markdown file.

* Update src/rules/add-metadata-to-token.js

Co-authored-by: Josh Cunningham <[email protected]>

* Resolving PR comments

Co-authored-by: Josh Cunningham <[email protected]>
Co-authored-by: Josh Cunningham <[email protected]>
  • Loading branch information
3 people authored Jul 23, 2021
1 parent b1e55a7 commit 2ea2be8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/rules/a/cumulio-add-metadata-to-tokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @title User metadata for Cumul.io
* @overview Add Cumul.io user metadata to tokens to be used for Cumul.io dashboard filtering
* @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
* 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){
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");
return;
}
callback(null, user, context);
}

0 comments on commit 2ea2be8

Please sign in to comment.