Skip to content

Commit 84dbff3

Browse files
committed
Make DELETE require write permissions on container
1 parent 4d52960 commit 84dbff3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/handlers/allow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
module.exports = allow
22

33
const $rdf = require('rdflib')
4+
const path = require('path')
45
const ACL = require('../acl-checker')
56
const debug = require('../debug.js').ACL
67
const fs = require('fs')
78
const { promisify } = require('util')
89
const HTTPError = require('../http-error')
910

10-
function allow (mode) {
11+
function allow (mode, relativePath = '') {
1112
return async function allowHandler (req, res, next) {
1213
const ldp = req.app.locals.ldp || {}
1314
if (!ldp.webid) {
@@ -23,6 +24,11 @@ function allow (mode) {
2324
? res.locals.path
2425
: req.path
2526

27+
// If a relativePath has been provided, check permissions based on that
28+
if (relativePath) {
29+
reqPath = path.join(reqPath, relativePath)
30+
}
31+
2632
// Check whether the resource exists
2733
let stat
2834
try {

lib/ldp-middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function LdpMiddleware (corsSettings) {
2626
router.post('/*', allow('Append'), post)
2727
router.patch('/*', allow('Append'), patch)
2828
router.put('/*', allow('Write'), put)
29-
router.delete('/*', allow('Write'), del)
29+
router.delete('/*', allow('Write', '..'), del)
3030

3131
return router
3232
}

0 commit comments

Comments
 (0)