Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
feat(tools): add visability of auth0 rules (#108)
Browse files Browse the repository at this point in the history
* feat(tools): add visability of auth0 rules

* fix(ns): update ns
  • Loading branch information
Bouncey authored and raisedadead committed May 4, 2018
1 parent 6fd836b commit 222fd18
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions auth0-rules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Auth0 Rules

The functions held in this directory have no direct effect inside the open-api, but are held here for visability and code review.

They are subject to a manual deploy process, that is to say, we copy/paste them inside the Auth0 dashboard.
21 changes: 21 additions & 0 deletions auth0-rules/add-accountLinkId-to-token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable */

/*
Function name should be removed for deployment
uuid is global inside Auth0 Rules
https://auth0.com/docs/appliance/modules
*/

function addAccountLinkId(user, context, callback) {
const namespace = 'https://auth-ns.freecodecamp.org/';
user.app_metadata = user.app_metadata || {};
user.app_metadata.accountLinkId = user.app_metadata.accountLinkId || uuid();
context.idToken[namespace + 'accountLinkId'] =
user.app_metadata.accountLinkId;

callback(null, user, context);
}
2 changes: 1 addition & 1 deletion src/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { JWT_CERT } = process.env;

export { updateAppMetaData } from './auth0';

export const namespace = 'https://www.freecodecamp.org/';
export const namespace = 'https://auth-ns.freecodecamp.org/';

export const getTokenFromContext = ctx =>
ctx &&
Expand Down
2 changes: 1 addition & 1 deletion test/utils/test-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const NodeEnvironment = require('jest-environment-node');

// can be found in ~/src/auth/index.js
// not 'required' due to jest no knowing how to read es6 modules
const namespace = 'https://www.freecodecamp.org/';
const namespace = 'https://auth-ns.freecodecamp.org/';

const { JWT_CERT } = process.env;

Expand Down

0 comments on commit 222fd18

Please sign in to comment.