Add REST API access key (#75)
parent
b660e84bea
commit
69697da8e9
@ -0,0 +1,14 @@ |
||||
import {NextFunction, Request, Response} from 'express' |
||||
import {config} from 'src/config' |
||||
|
||||
export const verifyApiKey = (req: Request, res: Response, next: NextFunction) => { |
||||
const {rest_api_key: headerApiKey} = req.headers |
||||
const {apiKey} = config.api.rest |
||||
|
||||
// If config api key is not empty, check api key in header
|
||||
if (apiKey && headerApiKey === apiKey) { |
||||
next() |
||||
} else { |
||||
res.sendStatus(403) |
||||
} |
||||
} |
Loading…
Reference in new issue