Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The commands in this guide assume that your Fedora 4 is running at http://localhost:8080/fcrepo.

Steps

Create these three two files:

Panel
acl.ttl
title
@prefix webac: <http://fedora.info/definitions/v4/webac#>.

<> a webac:Acl .
Panel
titlefoo.ttl
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix dc: <http://purl.org/dc/elements/1.1/>.

<> dc:title "Hello, World!".


Panel
titleauthzacl.ttl
@prefix acl: <http://www.w3.org/ns/auth/acl#>.

<><#authz> a acl:Authorization;
   acl:accessTo </fcrepo/rest/foo>;
   acl:agent "user1";
   acl:mode acl:Read.

...

Upload these files into the repository:

Code Block
languagetext
$ curl -X PUT http://localhost:8080/fcrepo/rest/aclfoo -u admin1:password3 \
    -H "Content-Type: text/turtle" --data-binary @acl@foo.ttl
$ curl -X PUT http://localhost:8080/fcrepo/rest/foo -u admin1:password3 \
    -H "Content-Type: text/turtle" --data-binary @foo.ttl \
    -H 'Link: <http://localhost:8080/fcrepo/rest/acl>; rel="acl"'
$ curl -X PUT http://localhost:8080/fcrepo/rest/acl/authz -/fcr:acl -u admin1:password3 \
    -H "Content-Type: text/turtle" --data-binary @authz@acl.ttl

...

Now user1 is able to read the resource at http://localhost:8080/rest/foo, but user2 cannot. To test this, try the following two commands:

Code Block
languagetext
$ curl -i http://localhost:8080/fcrepo/rest/foo -u user1:password1
$ curl -i http://localhost:8080/fcrepo/rest/foo -u user2:password2

...

Panel
titlefoo.sparql
PREFIX dc: <http://purl.org/dc/elements/1.1/>

INSERT DATA {
    <> dc:description "Quick Start with WebAC and Fedora 4" .
 }
WHERE {}

Then run this to attempt to update foo:

...

Panel
titleauthz.sparql
PREFIX acl: <http://www.w3.org/ns/auth/acl#>

INSERT DATA {
    <><#authz> acl:mode acl:Write .
 }
WHERE {}

Run this command to update the ACL authorization:

...

Now this should return a 204 No Content response. To verify that the update happened, you can also go to http://localhost:8080/fcrepo/rest/foo in your web browser, and confirm that it has both dc:title and dc:description properties.

...

titleAccess Control Link Header

When you perform a successful GET request on a resource that has an ACL associated with it (or with an ancestor), you will receive an additional header of the format.

Code Block
Link: <http://localhost:8080/fcrepo/rest/acl>; rel="acl"

...

.

Note
titleACLs for the Repository Root

When creating an ACL to protect the repository root, you must include a trailing slash in the Authorizations's acl:accessTo predicate, otherwise the Authorization will not match the request URI, and won't get applied.

Code Block
languagetext
titleNon-Working Version
<><#rootAuthz> a acl:Authorization;
    acl:accessTo <https://localhost:8080/fcrepo/rest> .


Code Block
languagetext
titleWorking Version
<><#rootAuthz> a acl:Authorization;
    acl:accessTo <https://localhost:8080/fcrepo/rest/> .
    # note this trailing slash ---------------------^


...