mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 16:29:37 +00:00
No auth and req.user for cover images
This commit is contained in:
parent
9e990d7927
commit
4224b8a486
2 changed files with 27 additions and 7 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue