Skip to content

Commit

Permalink
fix: typo, trim api key (#207)
Browse files Browse the repository at this point in the history
* fix: typo

* chore: remove unnecessary then

* fix: trim api key

* fix: typo

* chore: add api key salt to .env-example
  • Loading branch information
jeantanzj authored May 11, 2020
1 parent 1461357 commit c094dcf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion backend/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SES_HOST=
SES_PASS=
SES_USER=
SES_PORT=
SECRET_MANAGER_SALT="$2b$10$iDQWc/ZxTnAOMdx8022VWe"
SECRET_MANAGER_SALT=$2b$10$iDQWc/ZxTnAOMdx8022VWe
TWILIO_API_SECRET=YOURSECRET
TWILIO_MESSAGING_SERVICE_SID=MGXXX
TWILIO_API_KEY=SKXXX
Expand All @@ -20,3 +20,4 @@ DEFAULT_COUNTRY_CODE=65
FRONTEND_URL=http://localhost:3000
COOKIE_DOMAIN=localhost
AWS_LOG_GROUP_NAME='postmangovsg-beanstalk-test'
API_KEY_SALT_V1=$2b$10$5CuueB/CRZq8/JgmkzAK1e
1 change: 0 additions & 1 deletion backend/bin/api-key/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const generateKey = () => {

const generateHash = (value, salt) => {
return bcrypt.hash(value, salt)
.then(hashed => hashed)
.catch(err=>{
console.error(`Could not generate hash. Exiting. ${err.stack}`)
process.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/core/loaders/cloudwatch.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const cloudwatchLoader = async (): Promise<void> => {
const instanceId = await getInstanceId()
try {
if (instanceId) {
logger.info({ message: `Detetcted instanceId as ${instanceId}` })
logger.info({ message: `Detected instanceId as ${instanceId}` })
logger.add(new WinstonCloudwatch({
logGroupName: config.aws.logGroupName,
logStreamName: instanceId,
Expand Down
3 changes: 2 additions & 1 deletion backend/src/core/middlewares/is-authenticated.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const getApiKey = (req: Request): string | null => {
const authHeader = req.get('authorization')
if(!authHeader) return null

const [header, apiKey] = authHeader.split(' ')
const [header, bearerToken] = authHeader.split(' ')
if (headerKey !== header) return null

const apiKey = bearerToken.trim()
const [name, version, key] = apiKey.split('_')
if (!name || !version || !key) return null

Expand Down
2 changes: 1 addition & 1 deletion backend/src/email/routes/email.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ router.get('/upload/start', celebrate(uploadStartValidator), canEditCampaign, up
* application/json:
* schema:
* required:
* - transcation_id
* - transaction_id
* - filename
* properties:
* transaction_id:
Expand Down

0 comments on commit c094dcf

Please sign in to comment.