Loop ACL to extract array of objectIds

Hello,

I would like to extract user ids from ACL in form of array in the Cloud Code and through console I found this way:

const acl = object.getACL() || {};
for (const userId in acl.permissionsById) {
    console.log(`acl has ${userId}`);
}

I wonder now if there is any “getUserIds” function that is not documented? I would like to double check the safety of my code also?

Thanks!

@cbaker6, if I may ask… I now face the same just in ParseSwift SDK. As far I investigated, there is not direct method to extract array of objectIds. I did trick it in this way:

let encoder = group.getJSONEncoder()
var participantsIds: [String] = []
if let acl = group.ACL, let descriptionData = try? encoder.encode(acl) {
    //Coding ACL back to data
    if let decodedACL = try? JSONDecoder().decode([String : [String:Bool]].self, from: descriptionData) {
          //Decoding and extracting the keys
          let keys = decodedACL.keys
          participantsIds.append(contentsOf: keys)
    }
}

The reason why I want to achieve this functionality is to spare “participants” array field in an ParseObject, because the participant will be always the users that have ACL set and there is no public read on that ParseObject

You can try to write an Extention to ParseACL that gives you a computed property of the keys to get an array.

You mean to add it to the ParseSwift SDK? Sure I can make a PR for that.

You mean to add it to the ParseSwift SDK? Sure I can make a PR for that.

No, I wouldn’t add this to the Swift SDK. You can do this in your own app.

I wouldn’t add this to the SDK until there is a consensus from the server team and others that this isn’t a security issue by letting a user see all of the objectId's who have access to an object. I would guess there’s some reasoning why the ACL list is setup the way it is.

Understood, thank you!