Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Under Construction

Henry Story edited this page Nov 23, 2013 · 1 revision

The sections below were working at one point but have not been tested recently. The docs are kept here for later use.

WebID test

  1. get yourself a WebID certificate ( e.g. My-Profile will give you a nice one ), or use the certgen service described above.
  2. Use the browser you got a certificate above to connect to https://localhost:8443/test/webid/hello+world. Your browser will request a certificate from you and return a (way to simple message) - more advanced versions of this server will show a lot more info...

The code to run this is a few lines in Application:

  import JenaConfig._
  implicit val JenaWebIDVerifier = new WebIDVerifier[Jena]()


  val JenaWebIDAuthN = new WebIDAuthN[Jena]()

  implicit val idGuard: IdGuard[Jena] = WebAccessControl[Jena](linkedDataCache)
  def webReq(req: RequestHeader) : WebRequest[Jena] =
    new PlayWebRequest[Jena](new WebIDAuthN[Jena],new URL("https://localhost:8443/"),meta _)(req)

  // Authorizes anyone with a valid WebID
  object WebIDAuth extends Auth[Jena](idGuard,webReq _)

 def webId(path: String) = WebIDAuth() { authFailure =>
    Unauthorized("You are not authorized "+ authFailure)
  }
  { authReq =>
      Ok("You are authorized for " + path + ". Your ids are: " + authReq.user)
  }

The Auth class can be tuned for any type of authentication, by passing the relevant authentication and acl function to it. The WebId Authentication code WebIDAuthN is quite short and makes use of the Claims monad to help isolate what is verified and what is not.

For Web Access Control with WebID you have to start play in secure mode ( see above ) and create a WebID.

CORS

(no longer working right now)

To fetch a remote rdf resource in a CORS proxy friendly manner send an HTTP GET request to
http://localhost:9000/srv/cors?url={remote-url} replacing {remoate-url} with a URL-encoded url.

Using the command line tool curl the following command fetches Dean Allemang's "rdf/xml" foaf profile and returns it as Turtle with the needed CORS headers.

$ curl -s -i -H "Accept: text/turtle" -H "Origin: http://tricks.js"  "http://localhost:9000/srv/cors?url=http://www.topquadrant.com/people/dallemang/foaf.rdf"
HTTP/1.1 200 OK
Access-Control-Allow-Origin: http://tricks.js
Last-Modified: Tue, 06 Jan 2009 16:37:29 GMT
Server: Apache
Accept-Ranges: bytes
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Length: 12006
Content-Type: application/rdf+xml
Date: Tue, 10 Jul 2013 08:56:24 GMT
ETag: "125d8606-2ee6-45fd305ed0440"

@prefix dc:      <http://purl.org/dc/elements/1.1/> .
@prefix geo:     <http://www.w3.org/2003/01/geo/wgs84_pos#> .

The usual use case for fetching such a resource is to make the query in JavaScript, using a library such as rdflib

Todo

Query support returning json does not seem to work

curl -X POST -H "Content-Type: application/sparql-query; charset=UTF-8" -H "Accept: application/sparql-results+json" --data-binary "SELECT ?p WHERE { <http://bblfish.net/people/henry/card#me> <http://xmlns.com/foaf/0.1/knows> [ <http://xmlns.com/foaf/0.1/name> ?p ] . } " -i http://localhost:9000/2013/card.ttl

Proxy a Web Site

Want to try out what an existing Web site would look like with WebID enabled? Just proxy it. Note: this currently only works well for sites whose URLs are all relative.

To do this you need to do three things:

  1. In conf/application.conf set the rww.proxy... properties
  2. If you did not change rww.proxy.acl property then go to test_www/meta.ttl and edit the acls there.
  3. In conf/routes uncomment the controllers.AuthProxyApp.proxy(rg) . This has to be the root for urls to work correctly.

You should then be able to run RWW_Play on the tls port

> run  -Dhttps.port=8443 -Dhttps.trustStore=noCA

and on going to the https://localhost:8443/ and see a version of the remote server.

Todo:

  • make the access control better by not having the first page ask for a certificate.
  • write a library to easily hook into the access control system so that mappers from WebIDs to other systems can be built quickly
  • enable other methods such as PUT/POST/DELETE...
  • have the metadata be more flexible - currently it only looks in one file, the acl system should follow links

Development Tricks

publishing libraries to local play repository

If you are working on a library that is needed as part of this project, and in order to avoid having to upload that library to a remote server during the debugging phase ( which slows down development ) then you need to publish those libaries in the local Play repository that you are using. So before running the publish-local command for your library, run the following

$ cd Play20
$ export PLAY=`pwd`/Play20
$ export SBT_PROPS=-Dsbt.ivy.home=$PLAY/repository
$ ./sbt
> publish-local