perseids-project / plokamos

RDF-based annotations for Perseids
MIT License
6 stars 2 forks source link

use proxy endpoints #129

Open balmas opened 7 years ago

balmas commented 7 years ago

the plokamos update code should be using the proxy endpoint through the nemo annotations plugin for update calls, rather than posting directly to annotation.perseids.org

fbaumgardt commented 7 years ago

To change the SPARQL endpoints, use the constructor like so: https://github.com/perseids-project/nemo_plokamos_plugin/blob/master/tests/test_app.py#L13

balmas commented 7 years ago

@fbaumgardt it's taken me a little while to wade my way through various issues with the oauth plugin and the proxy setup that hadn't been found before. I've identified a couple of new problems:

1) the proxy doesn't currently know how to distinguish between select requests and update requests and proxies everything to the update endpoint, which fails when you send a select . I worked around this for the moment splitting the proxied parameter up, to allow update to be proxied and not select (which is not a full solution because it doesn't address how to proxy selects but could be postponed since we don't need to proxy selects). Hoewver, this then led me to find:

2) the way the graphs are stored, the authorization check fails because we now issue 2 separate update posts - one for the main annotation, which contains the user uri, and one for the body graph, which does not.

e..g we get these two posts, and only the first passes the authorization check, which looks at the annotatedBy line and compares it with the current user uri (I had to make bug fixes to the oauth plugin and the plokamos plugin to get this to work )

INSERT DATA { GRAPH <http://data.perseus.org/graphs/persons> {
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/oa#Annotation> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://purl.org/dc/terms/source> <https://github.com/perseids-project/plokamos> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://www.w3.org/ns/oa#serializedBy> <https://github.com/perseids-project/plokamos> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://www.w3.org/ns/oa#motivatedBy> <http://www.w3.org/ns/oa#identifying> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://www.w3.org/ns/oa#hasBody> <http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://www.w3.org/ns/oa#annotatedAt> "2017-03-06T22:49:55.440Z"^^<http://www.w3.org/2001/XMLSchema#dateTimeStamp> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://www.w3.org/ns/oa#annotatedBy> <http://data.perseus.org/sosol/users/Bridget%20Almas> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://www.w3.org/ns/oa#hasTarget> <http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#target-04f4> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#target-04f4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/oa#SpecificResource> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#target-04f4> <http://www.w3.org/ns/oa#hasSource> <urn:cts:pdlrefwk:viaf88890045.003.perseus-eng1.A.ajax_1> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#target-04f4> <http://www.w3.org/ns/oa#hasSelector> <http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#sel-03bb> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#sel-03bb> <http://www.w3.org/ns/oa#prefix> "            (Αἴας).1. A son of " .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#sel-03bb> <http://www.w3.org/ns/oa#exact> "Telamon" .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#sel-03bb> <http://www.w3.org/ns/oa#suffix> ", king of Salamis, by Periboea o" .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad#sel-03bb> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/oa#TextQuoteSelector> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> <http://purl.org/dc/terms/title> "http://data.perseus.org/people/smith:ajax-1#this identifies ajax as http://data.perseus.org/people/smith:ajax-1#this in undefined" .
}}
INSERT DATA { GRAPH <http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad> {
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad-bond-252c> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://data.snapdrgn.net/ontology/snap#FatherOf> .
<http://data.perseus.org/people/smith:telamon-2#this> <http://data.snapdrgn.net/ontology/snap#has-bond> <http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad-bond-252c> .
<http://data.perseus.org/collections/urn:cite:perseus:pdljann.14bfb3872b462aad-bond-252c> <http://data.snapdrgn.net/ontology/snap#bond-with> <http://data.perseus.org/people/smith:ajax-1#this> .
}}

I'm going to think on this a little.

fbaumgardt commented 7 years ago

1: My mistake, for some reason I thought GET -> select and POST -> update, but that's obviously not the case.

2: I might have split the two named graphs into separate insert statement because of issues with RDFStore.JS -- I will look into this tomorrow and let you know if that's the case.

But even if we can put multiple graphs into a single INSERT, there are still the DROP GRAPH commands that wouldn't go through. And checking authorization on those is much trickier.

balmas commented 7 years ago

Yeah it all needs a little thought :-)