Skip to content

Commit 8e2e435

Browse files
committed
Now allows users with invalid tokens to access public resources
1 parent 44a5540 commit 8e2e435

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/api/authn/webid-oidc.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ function initialize (app, argv) {
3131
app.use('/', middleware(oidc))
3232

3333
// Perform the actual authentication
34-
app.use('/', oidc.rs.authenticate())
34+
app.use('/', async (req, res, next) => {
35+
oidc.rs.authenticate()(req, res, (err) => {
36+
// Error handling should be deferred to the ldp in case a user with a bad token is trying
37+
// to access a public resource
38+
if (err) {
39+
req.authError = err
40+
}
41+
next()
42+
})
43+
})
3544

3645
// Expose session.userId
3746
app.use('/', (req, res, next) => {

lib/handlers/allow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function allow (mode, checkPermissionsForDirectory) {
6666
}
6767
}
6868
}
69-
const error = await req.acl.getError(userId, mode)
69+
const error = req.authError || await req.acl.getError(userId, mode)
7070
debug(`${mode} access denied to ${userId || '(none)'}: ${error.status} - ${error.message}`)
7171
next(error)
7272
}

0 commit comments

Comments
 (0)