Skip to content

Commit da1b42f

Browse files
author
Sachin Maheshwari
committed
m2m support
1 parent 476a492 commit da1b42f

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

config/default.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"idleTimeout": 1000
3434
},
3535
"analyticsKey": "",
36-
"validIssuers": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
37-
"jwksUri": "",
36+
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
3837
"busApiUrl": "http://api.topcoder-dev.com",
3938
"busApiToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoicHJvamVjdC1zZXJ2aWNlIiwiaWF0IjoxNTEyNzQ3MDgyLCJleHAiOjE1MjEzODcwODJ9.PHuNcFDaotGAL8RhQXQMdpL8yOKXxjB5DbBIodmt7RE",
4039
"HEALTH_CHECK_URL": "_health"

config/development.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"authDomain": "topcoder-dev.com",
32
"pubsubQueueName": "dev.project.service",
43
"pubsubExchangeName": "dev.projects",
54
"attachmentsS3Bucket": "topcoder-dev-media"

config/test.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"authSecret": "secret",
3-
"authDomain": "topcoder-dev.com",
2+
"AUTH_SECRET": "secret",
43
"logLevel": "debug",
54
"captureLogs": "false",
65
"logentriesToken": "",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"pg": "^4.5.5",
5656
"pg-native": "^1.10.0",
5757
"sequelize": "^3.23.0",
58-
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.2",
58+
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.3",
5959
"traverse": "^0.6.6",
6060
"urlencode": "^1.1.0"
6161
},

src/util.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ _.assignIn(util, {
7070
* @return {boolean} true/false
7171
*/
7272
hasRole: (req, role) => {
73+
const isMachineToken = _.get(req, 'authUser.isMachine', false);
74+
if (isMachineToken) return true;
7375
let roles = _.get(req, 'authUser.roles', []);
7476
roles = roles.map(s => s.toLowerCase());
7577
return _.indexOf(roles, role.toLowerCase()) >= 0;
@@ -81,6 +83,8 @@ _.assignIn(util, {
8183
* @return {boolean} true/false
8284
*/
8385
hasRoles: (req, roles) => {
86+
const isMachineToken = _.get(req, 'authUser.isMachine', false);
87+
if (isMachineToken) return true;
8488
let authRoles = _.get(req, 'authUser.roles', []);
8589
authRoles = authRoles.map(s => s.toLowerCase());
8690
return _.intersection(authRoles, roles.map(r => r.toLowerCase())).length > 0;
@@ -101,6 +105,8 @@ _.assignIn(util, {
101105
* @return {boolean} true/false
102106
*/
103107
hasAdminRole: (req) => {
108+
const isMachineToken = _.get(req, 'authUser.isMachine', false);
109+
if (isMachineToken) return true;
104110
let roles = _.get(req, 'authUser.roles', []);
105111
roles = roles.map(s => s.toLowerCase());
106112
return _.intersection(roles, ADMIN_ROLES.map(r => r.toLowerCase())).length > 0;

0 commit comments

Comments
 (0)