mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-09 14:25:25 +02:00
No auth and req.user for cover images
This commit is contained in:
@@ -18,6 +18,26 @@ class Auth {
|
||||
constructor() {
|
||||
// Map of openId sessions indexed by oauth2 state-variable
|
||||
this.openIdAuthSession = new Map()
|
||||
this.ignorePattern = /\/api\/items\/[^/]+\/cover/
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the request should not be authenticated.
|
||||
* @param {import('express').Request} req
|
||||
* @returns {boolean}
|
||||
* @private
|
||||
*/
|
||||
authNotNeeded(req) {
|
||||
return req.method === 'GET' && this.ignorePattern.test(req.originalUrl)
|
||||
}
|
||||
|
||||
ifAuthNeeded(middleware) {
|
||||
return (req, res, next) => {
|
||||
if (this.authNotNeeded(req)) {
|
||||
return next()
|
||||
}
|
||||
middleware(req, res, next)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user