Skip to content

Commit

Permalink
Merge pull request #286 from FlowFuse/apply-auth-on-static
Browse files Browse the repository at this point in the history
Ensure auth middleware applied on httpStatic routes
  • Loading branch information
hardillb authored Sep 19, 2024
2 parents 27ea96b + 06d7c3f commit ad84321
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/runtimeSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,16 @@ function getSettingsFile (settings) {
const httpStatic = []
settings.settings.httpStatic.forEach(staticSetting => {
staticSetting.path = path.normalize(path.join(settings.storageDir, staticSetting.path))
if (staticSetting.path.startsWith(settings.storageDir)) {
httpStatic.push(staticSetting)
if (staticSetting.path.startsWith(settings.storageDir) && staticSetting.root) {
httpStatic.push('{' +
'path: ' + JSON.stringify(staticSetting.path) + ',' +
'root: ' + JSON.stringify(staticSetting.root) +
(authMiddlewareRequired ? ', middleware: flowforgeAuthMiddleware' : '') +
'}')
}
})
if (httpStatic.length > 0) {
projectSettings.httpStatic = httpStatic
projectSettings.httpStatic = '[' + httpStatic.join(', ') + ']'
}
}

Expand Down Expand Up @@ -375,7 +379,7 @@ module.exports = {
},
httpAdminCookieOptions: ${JSON.stringify(httpAdminCookieOptions)},
${projectSettings.uibuilder ? 'uibuilder: ' + JSON.stringify(projectSettings.uibuilder) + ',' : ''}
${projectSettings.httpStatic ? 'httpStatic: ' + JSON.stringify(projectSettings.httpStatic) : ''}
${projectSettings.httpStatic ? 'httpStatic: ' + projectSettings.httpStatic : ''}
}
`
return settingsTemplate
Expand Down

0 comments on commit ad84321

Please sign in to comment.