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

feat(tools): add visability of auth0 rules #108

Merged
merged 2 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/';

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.


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