mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
WIP: enable non-csrf routes from modules
This commit is contained in:
parent
8726a8fb4d
commit
2cf2199964
2 changed files with 11 additions and 4 deletions
|
@ -18,6 +18,10 @@ module.exports = Modules =
|
|||
applyRouter: (webRouter, apiRouter) ->
|
||||
for module in @modules
|
||||
module.router?.apply(webRouter, apiRouter)
|
||||
|
||||
applyNonCsrfRouter: (webRouter, apiRouter) ->
|
||||
for module in @modules
|
||||
module.nonCsrfRouter?.apply(webRouter, apiRouter)
|
||||
|
||||
viewIncludes: {}
|
||||
loadViewIncludes: (app) ->
|
||||
|
@ -58,4 +62,4 @@ module.exports = Modules =
|
|||
return callback(error) if error?
|
||||
return callback null, results
|
||||
|
||||
Modules.loadModules()
|
||||
Modules.loadModules()
|
||||
|
|
|
@ -90,9 +90,6 @@ webRouter.use session
|
|||
secure: Settings.secureCookie
|
||||
store: sessionStore
|
||||
key: Settings.cookieName
|
||||
webRouter.use csrfProtection
|
||||
webRouter.use translations.expressMiddlewear
|
||||
webRouter.use translations.setLangBasedOnDomainMiddlewear
|
||||
|
||||
# passport
|
||||
webRouter.use passport.initialize()
|
||||
|
@ -113,6 +110,12 @@ Modules.hooks.fire 'passportSetup', passport, (err) ->
|
|||
if err?
|
||||
logger.err {err}, "error setting up passport in modules"
|
||||
|
||||
Modules.applyNonCsrfRouter(webRouter, apiRouter)
|
||||
|
||||
webRouter.use csrfProtection
|
||||
webRouter.use translations.expressMiddlewear
|
||||
webRouter.use translations.setLangBasedOnDomainMiddlewear
|
||||
|
||||
# Measure expiry from last request, not last login
|
||||
webRouter.use (req, res, next) ->
|
||||
req.session.touch()
|
||||
|
|
Loading…
Reference in a new issue