Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Getting-Started-with-Akka-http-signature.md #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions Getting-Started-with-Akka-http-signature.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,62 @@ could not find actor for Actor[akka://rww/user/rootContainer/card]rww.ldp.LDPExc
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
```

### Generating the .acl file

It is always helpful to visualise the .acl file's relations by showing its rdf graph representation. For the file which we can build that representation looks like so:

![Pubkey.acl rdf](http://i.imgur.com/e0dOZSb.png)

One can also generate this .acl file using the [banana-rdf library](https://github.com/banana-rdf/banana-rdf). This will generate an .acl in turtle format:

```scala
val acl = WebACLPrefix[Jena]
val cert = CertPrefix[Jena]

val pgSeq: Seq[PointedGraph[Jena]] = Seq(
bnode("WriteAccess")
-- acl.accessTo ->- URI("https://localhost:8443/2013/pubKey")
-- acl.accessTo ->- URI("https://localhost:8443/2013/pubKey.ttl")
-- acl.agent ->- URI("https://localhost:8443/2013/pubKey#me")
-- acl.agent ->- (
bnode("agentBlankNode")
-- cert.key ->- URI("https://localhost:8443/2013/pubKey#")
)
-- acl.mode ->- acl.Write,

bnode("ReadAccess")
-- acl.agentClass ->- URI("http://xmlns.com/foaf/0.1/Agent")
-- acl.accessTo ->- URI("https://localhost:8443/2013/pubKey")
-- acl.accessTo ->- URI("https://localhost:8443/2013/pubKey.ttl")
-- acl.mode ->- acl.Read,

URI("")
-- acl.include ->- URI("https://localhost:8443/2013/.acl"),

)

val aclGraph = union(pgSeq.map(_.graph))
val aclttl = turtleWriter.asString(aclGraph ,"").get

```
This implementation states that the pubKey file is readable by everyone but only the person that can prove that he holds the corresponding private key has write access to it.

One can then `PUT` the generated information onto the server by using the [Solid-client library](https://github.com/read-write-web/solid-client) :

```scala
def putLocalKey = http.run(
req = PUT[`text/turtle`](
resource = Uri("https://localhost:8443/2013/"),
graph = aclGraph
).get,
keyChain = List(localKey)
)
```

This will replace the acl file which is automatically generated by the `POST` command.

Now that the correct pubKey.acl file has been generated one can manipulate the access control of pubKey.ttl as shown above.


***