@@ -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 )
0 commit comments