Skip to content
A js library for working with acl files. It allows you to parse the turtle representation, update permissions and agents, and finally convert it back to turtle. It does not cover fetching acl files.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src
tests
types
.babelrc
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
webpack.config.js

README.md

Solid ACL Parser

Build Status

A js library for working with acl files. It allows you to parse the turtle representation, update permissions and agents, and finally convert it back to turtle. It does not cover fetching acl files.

Status of the project

Most features of the WAC-spec are already implemented and tested.

Current limitations:

  • No support for acl:trustedApp
  • No support for multiple accessTo's in the same acl file
  • No support for multiple default's in the same rule (subject id group)

Documentation

Please refer to this website for documentation: https://otto-aa.github.io/solid-acl-parser/

Basic example

This example demonstrates how to parse a turtle string into an AclDoc object, then modify the permissions for a specific user and finally parse it back to turtle.

const SolidAclParser = require('SolicAclParser')

const webId = 'https://solid.example.org/profile/card#me'
const aclUrl = 'https://pod.example.org/private/file.ext.acl'
const fileUrl = 'https://pod.example.org/private/file.ext'
const turtle = `
@prefix   acl:  <http://www.w3.org/ns/auth/acl#>.
@prefix  foaf:  <http://xmlns.com/foaf/0.1/>.

<#authorization2>
    a               acl:Authorization;
    acl:agentClass  foaf:Agent;                               # everyone
    acl:mode        acl:Read;                                 # has Read-only access
    acl:accessTo    <https://alice.databox.me/profile/card>.`

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()

Output turtle

@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.

<https://pod.example.org/private/file.ext.acl#authorization2> a acl:Authorization;
    acl:agentClass foaf:Agent;
    acl:accessTo <https://pod.example.org/private/file.ext>;
    acl:mode acl:Read.
<solid-acl-parser-rule-0> a acl:Authorization;
    acl:agent <https://solid.example.org/profile/card#me>;
    acl:accessTo <https://pod.example.org/private/file.ext>;
    acl:mode acl:Write, acl:Control.
You can’t perform that action at this time.