Skip to content

Commit

Permalink
add bearer authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
pkage committed Oct 19, 2019
1 parent 02202eb commit 151593b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const groupID = config.groupID
const apikey = secrets.apikey

const authenticationMiddleware = (req, res, next) => {
if (!req.query.key || req.query.key !== apikey) {
const expected_header = `Bearer ${apikey}`
if (!req.headers.authorization || req.headers.authorization !== expected_header) {
res
.status(401)
.send({
Expand Down Expand Up @@ -50,7 +51,7 @@ const readScrape = () => JSON.parse(fs.readFileSync(cachefile))
app.get('/api/members', (req, res) => {
try {
res.json({ success: true, ...readScrape() })
} except (e) {
} catch (e) {
res.json({ success: false, status: e.toString() })

}
Expand Down

0 comments on commit 151593b

Please sign in to comment.