Skip to content

Commit fa4d1d2

Browse files
committed
Require Read permissions for authProxy.
Addresses read part of #595.
1 parent f3a0ff1 commit fa4d1d2

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

lib/handlers/allow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var debug = require('../debug.js').ACL
88

99
function allow (mode) {
1010
return function allowHandler (req, res, next) {
11-
var ldp = req.app.locals.ldp
11+
var ldp = req.app.locals.ldp || {}
1212
if (!ldp.webid) {
1313
return next()
1414
}

lib/handlers/auth-proxy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = addAuthProxyHandlers
44

55
const proxy = require('http-proxy-middleware')
66
const debug = require('../debug')
7+
const allow = require('./allow')
78

89
const PROXY_SETTINGS = {
910
logLevel: 'silent',
@@ -32,7 +33,7 @@ function addAuthProxyHandler (app, sourcePath, target) {
3233
}, PROXY_SETTINGS)
3334

3435
// Activate the proxy
35-
app.use(`${sourcePath}*`, proxy(settings))
36+
app.use(`${sourcePath}*`, allow('Read'), proxy(settings))
3637
}
3738

3839
// Adds a headers with authentication information

test/integration/auth-proxy-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Auth Proxy', () => {
1818

1919
// Set up Solid server
2020
server = ldnode({
21-
root: path.join(__dirname, '../resources'),
21+
root: path.join(__dirname, '../resources/auth-proxy'),
2222
authProxy: {
2323
'/server/a': 'http://server-a.org'
2424
},

test/resources/auth-proxy/.acl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
2+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
3+
4+
# All permissions on the root
5+
<#owner>
6+
a acl:Authorization;
7+
acl:agent <https://ruben.verborgh.org/profile/#me>;
8+
acl:accessTo <./>;
9+
acl:defaultForNew <./>;
10+
acl:mode acl:Read, acl:Write, acl:Control.

test/resources/auth-proxy/index.html

Whitespace-only changes.

test/resources/auth-proxy/index.html.acl

Whitespace-only changes.

0 commit comments

Comments
 (0)