Skip to content

Commit 7ceb0e0

Browse files
variables clean-up and lib secuirty fixes.
1 parent ad70652 commit 7ceb0e0

File tree

7 files changed

+176
-364
lines changed

7 files changed

+176
-364
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ The other configurations can be changed in `config/default.js` or by setting env
8080
- `LOG_LEVEL` the logging level, `error` or `debug`
8181
- `PORT` the port on that app listens
8282
- `API_VERSION` the api version
83-
- `ALLOWED_SERVICES` the allowed calling services
8483
- `JWT_TOKEN_SECRET` the secret to sign JWT tokens
85-
- `JWT_TOKEN_EXPIRES_IN` the JWT token expiration
8684
- `TC_EMAIL_URL` the email service URL (http://localhost:4001, if deployed locally)
8785
- `TC_EMAIL_TOKEN` the email service authentication token (see tc-email README for details **link should be added later**)
8886
- `TC_EMAIL_CACHE_PERIOD` the period to cache template placeholders from email service (60 min default)
@@ -96,14 +94,6 @@ npm install
9694
npm start
9795
```
9896

99-
## Generate JWT Tokens:
100-
101-
To generate JWT Tokens for allowed services, run:
102-
103-
```bash
104-
npm run generate-tokens
105-
```
106-
10797
To view the Swagger UI interface visit `http://localhost:3000/docs`
10898

10999
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.

common/helper.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,6 @@ function verifyJwtToken (token) {
116116
return payload
117117
}
118118

119-
/**
120-
* Sign the payload and get the JWT token.
121-
*
122-
* @param {Object} payload the payload to be sign
123-
* @returns {String} the token
124-
*/
125-
function signJwtToken (payload) {
126-
return jwt.sign(payload, config.JWT_TOKEN_SECRET, {expiresIn: config.JWT_TOKEN_EXPIRES_IN})
127-
}
128-
129119
/**
130120
* Validate the event payload
131121
*
@@ -164,7 +154,6 @@ function verifyTokenScope (req, scope) {
164154
module.exports = {
165155
buildService,
166156
verifyJwtToken,
167-
signJwtToken,
168157
validateEventPayload,
169158
verifyTokenScope
170159
}

config/default.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ module.exports = {
99
AUTH_SECRET: process.env.JWT_TOKEN_SECRET,
1010
VALID_ISSUERS: process.env.VALID_ISSUERS ? process.env.VALID_ISSUERS.replace(/\\"/g, '') : null,
1111
JWT_TOKEN_SECRET: process.env.JWT_TOKEN_SECRET || '',
12-
JWT_TOKEN_EXPIRES_IN: process.env.JWT_TOKEN_EXPIRES_IN || '100 days',
13-
ALLOWED_SERVICES: process.env.ALLOWED_SERVICES || ['project-service', 'message-service'],
1412
TC_EMAIL_SERVICE_URL: process.env.TC_EMAIL_SERVICE_URL,
1513
TC_EMAIL_SERVICE_CACHE_PERIOD: process.env.TC_EMAIL_SERVICE_CACHE_PERIOD || (3600 * 1000),
1614

deploy.sh

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ AWS_ECS_CONTAINER_NAME=$(eval "echo \$${ENV}_AWS_ECS_CONTAINER_NAME")
3636
LOG_LEVEL=$(eval "echo \$${ENV}_LOG_LEVEL")
3737
JWT_TOKEN_SECRET=$(eval "echo \$${ENV}_JWT_TOKEN_SECRET")
3838
API_VERSION=$(eval "echo \$${ENV}_API_VERSION")
39-
ALLOWED_SERVICES=$(eval "echo \$${ENV}_ALLOWED_SERVICES")
40-
JWT_TOKEN_EXPIRES_IN=$(eval "echo \$${ENV}_JWT_TOKEN_EXPIRES_IN")
4139
PORT=$(eval "echo \$${ENV}_NODE_PORT")
4240

4341
KAFKA_URL=$(eval "echo \$${ENV}_KAFKA_URL")
4442
KAFKA_CLIENT_CERT=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT")
4543
KAFKA_CLIENT_CERT_KEY=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT_KEY")
4644

47-
AUTH_DOMAIN=$(eval "echo \$${ENV}_AUTH_DOMAIN")
4845
VALID_ISSUERS=$(eval "echo \$${ENV}_VALID_ISSUERS")
4946

5047
TC_EMAIL_SERVICE_URL=$(eval "echo \$${ENV}_TC_EMAIL_SERVICE_URL")
@@ -123,25 +120,13 @@ make_task_def(){
123120
"name": "JWT_TOKEN_SECRET",
124121
"value": "%s"
125122
},
126-
{
127-
"name": "ALLOWED_SERVICES",
128-
"value": "%s"
129-
},
130-
{
131-
"name": "JWT_TOKEN_EXPIRES_IN",
132-
"value": "%s"
133-
},
134123
{
135124
"name": "API_VERSION",
136125
"value": "%s"
137126
},
138127
{
139128
"name": "PORT",
140129
"value": "%s"
141-
},
142-
{
143-
"name": "AUTH_DOMAIN",
144-
"value": "%s"
145130
},
146131
{
147132
"name": "VALID_ISSUERS",
@@ -190,7 +175,7 @@ make_task_def(){
190175
}
191176
]'
192177

193-
task_def=$(printf "$task_template" $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV $KAFKA_URL "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $LOG_LEVEL $JWT_TOKEN_SECRET "$ALLOWED_SERVICES" $JWT_TOKEN_EXPIRES_IN "$API_VERSION" $PORT "$AUTH_DOMAIN" "$VALID_ISSUERS" $TC_EMAIL_SERVICE_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV)
178+
task_def=$(printf "$task_template" $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV $KAFKA_URL "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $LOG_LEVEL $JWT_TOKEN_SECRET "$API_VERSION" $PORT "$VALID_ISSUERS" $TC_EMAIL_SERVICE_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV)
194179
}
195180

196181
register_definition() {

generate-tokens.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)