Skip to content

Commit c328a3e

Browse files
My changes on top of #1122
1 parent a8b917c commit c328a3e

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

lib/acl-checker.js

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,16 @@ class ACLChecker {
5757
const modes = [ACL(mode)]
5858
const agentOrigin = this.agentOrigin
5959
const trustedOrigins = this.trustedOrigins
60-
const originTrustedModes = agent && agentOrigin ? await this.getOriginTrustedModes(agent, agentOrigin) : []
60+
let originTrustedModes = []
61+
try {
62+
this.fetch(aclFile.doc().value)
63+
originTrustedModes = await aclCheck.getTrustedModesForOrigin(acl.graph, resource, directory, aclFile, agentOrigin, (uriNode) => {
64+
return this.fetch(uriNode.doc().value, acl.graph)
65+
})
66+
} catch (e) {
67+
console.error(e.message)
68+
}
6169
const accessDenied = aclCheck.accessDenied(acl.graph, resource, directory, aclFile, agent, modes, agentOrigin, trustedOrigins, originTrustedModes)
62-
6370
if (accessDenied && user) {
6471
this.messagesCached[cacheKey].push(HTTPError(403, accessDenied))
6572
} else if (accessDenied) {
@@ -69,26 +76,6 @@ class ACLChecker {
6976
return this.aclCached[cacheKey]
7077
}
7178

72-
async getOriginTrustedModes (agent, agentOrigin) {
73-
let agentStore
74-
try {
75-
this.requests[agent.uri] = this.requests[agent.uri] || this.fetch(agent.uri)
76-
agentStore = await this.requests[agent.uri]
77-
} catch (err) {
78-
if (err && (err.code === 'ENOENT' || err.status === 404)) {
79-
// If we're unable to resolve the agent, we conclude that origin has no trusted modes
80-
this.requests[agent.uri] = Promise.resolve(null)
81-
return Promise.resolve([])
82-
}
83-
debug(err)
84-
throw err
85-
}
86-
if (agentStore) {
87-
return aclCheck.getTrustedModesForOrigin(agentStore, agent, agentOrigin)
88-
}
89-
return Promise.resolve([])
90-
}
91-
9279
async getError (user, mode) {
9380
const cacheKey = `${mode}-${user}`
9481
this.aclCached[cacheKey] = this.aclCached[cacheKey] || this.can(user, mode)

test/integration/authentication-oidc-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const path = require('path')
33
const fs = require('fs-extra')
44
const { UserStore } = require('@solid/oidc-auth-manager')
55
const UserAccount = require('../../lib/models/user-account')
6-
const SolidAuthOIDC = require('@solid/solid-auth-oidc')
6+
// const SolidAuthOIDC = require('@solid/solid-auth-oidc')
77

8-
const fetch = require('node-fetch')
9-
const localStorage = require('localstorage-memory')
8+
// const fetch = require('node-fetch')
9+
// const localStorage = require('localstorage-memory')
1010
const URL = require('whatwg-url').URL
1111
global.URL = URL
1212
global.URLSearchParams = require('whatwg-url').URLSearchParams
@@ -20,7 +20,7 @@ chai.use(require('dirty-chai'))
2020
// In this test we always assume that we are Alice
2121

2222
describe('Authentication API (OIDC)', () => {
23-
let alice, bob
23+
let alice, bob // eslint-disable-line no-unused-vars
2424

2525
let aliceServerUri = 'https://localhost:7000'
2626
let aliceWebId = 'https://localhost:7000/profile/card#me'

0 commit comments

Comments
 (0)