Server: add module auth with Master API

This commit is contained in:
Barry Low committed 2018-11-03 15:48:09 -07:00
1 parent f324b362a5
commit 32eac12dfa
5 files changed
+23 -3

No files matched your search

+2 -2
View File
@@ -46,10 +46,10 @@ export const getUser = authId => {
.catch(err => {
logger.info('getUser err')
logger.info(err)
reject(new DatabaseError(err))
reject(err)
})
} catch (error) {
reject(new DatabaseError(error))
reject(error)
}
})
}
+3
View File
@@ -0,0 +1,3 @@
import moduleAuth from './moduleAuth'
export { moduleAuth }
+13
View File
@@ -0,0 +1,13 @@
import { logger } from '../logger'
export const moduleAuth = async (req, res, next, db) => {
if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) {
logger.info('Module authenticated')
next();
} else {
logger.error('Module authentication error')
res.send(wrongPreshared);
}
}
export default moduleAuth