Book cover uploader, moving streams to /metadata/streams, adding jwt auth from query string, auth check static metadata

This commit is contained in:
advplyr 2021-09-21 20:57:33 -05:00
parent ae1b94e991
commit b23f9362ef
18 changed files with 377 additions and 36 deletions

View file

@ -38,8 +38,16 @@ class Auth {
}
async authMiddleware(req, res, next) {
const authHeader = req.headers['authorization']
const token = authHeader && authHeader.split(' ')[1]
var token = null
// If using a get request, the token can be passed as a query string
if (req.method === 'GET' && req.query && req.query.token) {
token = req.query.token
} else {
const authHeader = req.headers['authorization']
token = authHeader && authHeader.split(' ')[1]
}
if (token == null) {
Logger.error('Api called without a token', req.path)
return res.sendStatus(401)