# Library for parsing and modifying ACL files

**URL:** <https://forum.solidproject.org/t/library-for-parsing-and-modifying-acl-files/1977>\
**Category:** App Testing\
**Created:** [July 8, 2019, 11:45am UTC](https://forum.solidproject.org/t/library-for-parsing-and-modifying-acl-files/1977 "2019-07-08T11:45:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![A\_A](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/a_a/32/786_2.png) [@A\_A](https://forum.solidproject.org/u/A_A)\
**Post date:** [July 8, 2019, 11:45am UTC](https://forum.solidproject.org/t/library-for-parsing-and-modifying-acl-files/1977/1 "2019-07-08T11:45:31Z")

</div>

I’ve finished the first version of an acl library: [https://otto-aa.github.io/solid-acl-parser/](https://otto-aa.github.io/solid-acl-parser/) (see quickstart on how to use it)  
It makes it rather easy to parse an acl turtle, then modify the permissions and finally parse it back to a turtle string. I will write a wrapper which also does fetching and saving to a pod in the next days.

There are some limitations, but it should be sufficient for the majority of use cases. It currently doesn’t support trustedApps, multiple accessTo-values in the same acl file and multiple default values for the same rule. Maybe this will change in future versions, but I’m not yet sure how I would do this without making it less simple to use.

Here is a short example, demonstrating how to add write permissions for a specific webId. More examples can be found in the documenation.

```javascript
const { AclParser, Permissions } = SolidAclParser
const { WRITE, CONTROL } = Permissions

async function main() {
  // Parse the turtle to an AclDoc object which we can modify
  const parser = new AclParser({ aclUrl, fileUrl })
  const doc = await parser.turtleToAclDoc(turtle)

  // Give the webId WRITE and CONTROL permissions
  doc.addRule([WRITE, CONTROL], webId)

  // Parse it back to turtle so we can store it in the pod
  const newTurtle = await parser.aclDocToTurtle(doc)
  console.log(newTurtle)
}
main()

```

I’ve also recreated nearly all examples from the WAC-Spec for testing purposes, so if something is missing in the documentation you could check if it is used [there](https://github.com/Otto-AA/solid-acl-parser/blob/master/tests/parse/samples.js).

If you find a bug, think that a feature is missing or the interface lacks something, I’d be glad to hear your feedback on it
