@@ -14,7 +14,7 @@ import type { IdentifierStrategy } from '../util/identifiers/IdentifierStrategy'
1414import { readableToQuads } from '../util/StreamUtil' ;
1515import { ACL , RDF } from '../util/Vocabularies' ;
1616import type { AccessChecker } from './access/AccessChecker' ;
17- import type { PermissionReaderInput } from './PermissionReader' ;
17+ import type { PermissionReaderInput , PermissionReaderOutput } from './PermissionReader' ;
1818import { PermissionReader } from './PermissionReader' ;
1919import type { AclPermission } from './permissions/AclPermission' ;
2020import { AclMode } from './permissions/AclPermission' ;
@@ -40,7 +40,7 @@ export class WebAclReader extends PermissionReader {
4040
4141 private readonly aclStrategy : AuxiliaryIdentifierStrategy ;
4242 private readonly aclStore : ResourceStore ;
43- private readonly identifierStrategy : IdentifierStrategy ;
43+ public readonly identifierStrategy : IdentifierStrategy ;
4444 private readonly accessChecker : AccessChecker ;
4545
4646 public constructor ( aclStrategy : AuxiliaryIdentifierStrategy , aclStore : ResourceStore ,
@@ -52,13 +52,26 @@ export class WebAclReader extends PermissionReader {
5252 this . accessChecker = accessChecker ;
5353 }
5454
55+ // FIXME: this utility function is unrelated to permission
56+ // so should be moved elsewhere by editing the componentjs config:
57+ private getAncestors ( identifier : ResourceIdentifier ) : ResourceIdentifier [ ] {
58+ let ancestor = this . identifierStrategy . getParentContainer ( identifier ) ;
59+ let ancestors : ResourceIdentifier [ ] = [ ] ;
60+ ancestors . push ( ancestor ) ;
61+ while ( ! this . identifierStrategy . isRootContainer ( ancestor ) ) {
62+ ancestor = this . identifierStrategy . getParentContainer ( ancestor ) ;
63+ ancestors . push ( ancestor ) ;
64+ }
65+ return ancestors ;
66+ }
67+
5568 /**
5669 * Checks if an agent is allowed to execute the requested actions.
5770 * Will throw an error if this is not the case.
5871 * @param input - Relevant data needed to check if access can be granted.
5972 */
6073 public async handle ( { identifier, credentials, modes } : PermissionReaderInput ) :
61- Promise < PermissionSet > {
74+ Promise < PermissionReaderOutput > {
6275 // Determine the required access modes
6376 this . logger . debug ( `Retrieving permissions of ${ credentials . agent ?. webId } for ${ identifier . path } ` ) ;
6477
@@ -95,7 +108,7 @@ export class WebAclReader extends PermissionReader {
95108 permissions [ CredentialGroup . public ] ! . delete =
96109 permissions [ CredentialGroup . public ] ! . write && parentPermissions [ CredentialGroup . public ] ! . write ;
97110 }
98- return permissions ;
111+ return { permissions, ancestors : this . getAncestors ( identifier ) } ;
99112 }
100113
101114 /**
0 commit comments