@@ -16,11 +16,10 @@ class ACLChecker {
1616 constructor ( resource , options = { } ) {
1717 this . resource = resource
1818 this . resourceUrl = new URL ( resource )
19- this . agentOrigin = options . agentOrigin
19+ this . agentOrigin = options . strictOrigin && options . agentOrigin ? rdf . sym ( options . agentOrigin ) : null
2020 this . fetch = options . fetch
2121 this . fetchGraph = options . fetchGraph
22- this . strictOrigin = options . strictOrigin
23- this . trustedOrigins = options . trustedOrigins
22+ this . trustedOrigins = options . strictOrigin && options . trustedOrigins ? options . trustedOrigins . map ( trustedOrigin => rdf . sym ( trustedOrigin ) ) : null
2423 this . suffix = options . suffix || DEFAULT_ACL_SUFFIX
2524 this . aclCached = { }
2625 this . messagesCached = { }
@@ -56,17 +55,14 @@ class ACLChecker {
5655 const aclFile = rdf . sym ( acl . acl )
5756 const agent = user ? rdf . sym ( user ) : null
5857 const modes = [ ACL ( mode ) ]
59- const agentOrigin = this . agentOrigin ? rdf . sym ( this . agentOrigin ) : null
60- const trustedOrigins = this . trustedOrigins ? this . trustedOrigins . map ( trustedOrigin => rdf . sym ( trustedOrigin ) ) : null
58+ const agentOrigin = this . agentOrigin
59+ const trustedOrigins = this . trustedOrigins
6160 const accessDenied = aclCheck . accessDenied ( acl . graph , resource , directory , aclFile , agent , modes , agentOrigin , trustedOrigins )
62- if ( accessDenied && this . agentOrigin && this . resourceUrl . origin !== this . agentOrigin ) {
63- this . messagesCached [ cacheKey ] . push ( HTTPError ( 403 , accessDenied ) )
64- } else if ( accessDenied && user ) {
61+
62+ if ( accessDenied && user ) {
6563 this . messagesCached [ cacheKey ] . push ( HTTPError ( 403 , accessDenied ) )
66- } else if ( accessDenied && ! user ) {
67- this . messagesCached [ cacheKey ] . push ( HTTPError ( 401 , 'Unauthenticated' ) )
6864 } else if ( accessDenied ) {
69- this . messagesCached [ cacheKey ] . push ( HTTPError ( 401 , accessDenied ) )
65+ this . messagesCached [ cacheKey ] . push ( HTTPError ( 401 , 'Unauthenticated' ) )
7066 }
7167 this . aclCached [ cacheKey ] = Promise . resolve ( ! accessDenied )
7268 return this . aclCached [ cacheKey ]
0 commit comments