Skip to content

Commit 8512ccd

Browse files
committed
chore(readme): update ODRL scopes entry
1 parent 124d032 commit 8512ccd

1 file changed

Lines changed: 83 additions & 5 deletions

File tree

README.md

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ Using the `:scopes` parameter notation it is possible to provide multiple scope
400400
### Defining an authorization policy in ODRL
401401

402402
> [!WARNING]
403-
> Support for ODRL policies is under development and some functionality, such as using scopes, is not yet (fully) supported.
403+
> Support for ODRL policies is under development and some functionality is not yet (fully) supported.
404404

405405
This service also supports defining policies using [ODRL](https://www.w3.org/TR/odrl-model/), as an alternative to the lisp-style configuration illustrated above. To enable ODRL policies, set `*use-odrl-config-p*` to non-nil in the config file mounted in `./config/authorization/config.lisp` as shown below. Note, other service configuration settings, such as `*backend*`, should still be set in the same file.
406406

@@ -531,7 +531,7 @@ example:foafPersonNamesOnlyAsset a odrl:Asset, sh:NodeShape ;
531531

532532
Alternatively, you may be interested in most triples for a resource type except those with a few specific predicates. While you can list all relevant predicates as above, sparql-parser supports a shorter notation to describe such situations more concisely. Similar to above this uses SHACL property shapes to specify the desired predicates, but surrounding them with a `sh:not` logical constraint component. For example, say you are interested in all triples with a `foaf:OnlineAccount` resource as subject, except those triples that have as predicate `ext:password` or `account:accountName`. This can be specified as shown in the `example:foafOnlineAccountAsset` shown below.
533533

534-
```lisp
534+
```ttl
535535
@prefix example: <http://www.example.org/>
536536
@prefix ext: <http://mu.semte.ch/vocabularies/ext/> .
537537
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@@ -549,7 +549,7 @@ example:foafOnlineAccountAsset a odrl:Asset, sh:NodeShape ;
549549

550550
So far the assets only concerned triples with a *subject* of a specific resource type. To specify triples where the *object* is of a given resource type you can use property shapes with an `sh:inversePath` as property path. For example, the `example:foafPersonObjectAsset` below covers all triples which have an object of type `foaf:Person`. Here the `ext:all` object acts as a wildcard value meaning all predicates.
551551

552-
```lisp
552+
```ttl
553553
@prefix example: <http://www.example.org/> .
554554
@prefix ext: <http://mu.semte.ch/vocabularies/ext/> .
555555
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@@ -566,7 +566,7 @@ example:foafPersonObjectAsset a odrl:Asset, sh:NodeShape ;
566566

567567
Similarly as before, you can also specify a concrete predicate for an inverse path to limit an asset to triples with an object of a certain *and* specific predicates. For example, the `example:foafPersonObjectEmployeeAsset` below covers triples that have a `foaf:Person` as object and have `schema:employee` as predicate.
568568

569-
```lisp
569+
```ttl
570570
@prefix example: <http://www.example.org/> .
571571
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
572572
@prefix odrl: <http://www.w3.org/ns/odrl/2/> .
@@ -739,7 +739,85 @@ This functionality is not part of the ODRL policy itself. This should be configu
739739
This functionality is not part of the ODRL policy itself. This should be configured in the `config.lisp` file as explained in [this guide](#enable-additional-logging).
740740

741741
#### Define access rights for specific services in ODRL
742-
Specifying scopes is **not** yet supported in ODRL policies. If you require this functionality you have to define you configuration in the lisp-style syntax.
742+
It is likely that in your semantic.works application not all requests sent to the SPARQL endpoint are (indirectly) triggered by users with a session. For example, a service may periodically and autonomously retrieve triples from the endpoint. In such cases, requests are not associated with a session from which the appropriate access-groups can be determined. Sparql-parser supports *scopes** which facilitate defining access control rules for such scenarios.
743+
744+
**NOTE**: This requires the service to which rights are granted is created with [mu-javascript-template](https://github.com/mu-semtech/mu-javascript-template) v1.9.0 or newer. Services based on older templates should first be upgraded or can use [mu-auth-sudo](https://github.com/lblod/mu-auth-sudo) as alternative solution.
745+
746+
For instance, let's assume your application has the following access control policy:
747+
748+
```ttl
749+
@prefix example: <http://www.example.org/> .
750+
@prefix ext: <http://mu.semte.ch/vocabularies/ext/> .
751+
@prefix odrl: <http://www.w3.org/ns/odrl/2/> .
752+
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
753+
754+
example:authenticatedUserParty a odrl:PartyCollection ;
755+
vcard:fn "authenticated" ;
756+
ext:definedBy """PREFIX session: <http://mu.semte.ch/vocabularies/session/>
757+
758+
SELECT DISTINCT ?account WHERE {
759+
<SESSION_ID> session:account ?account.
760+
}""" .
761+
762+
example:peopleGraph a odrl:AssetCollection ;
763+
vcard:fn "people" ;
764+
ext:graphPrefix <http://mu.semte.ch/graphs/people> .
765+
766+
example:foafPersonAsset a odrl:Asset, sh:NodeShape ;
767+
odrl:partOf example:peopleGraph ;
768+
sh:targetClass foaf:Person .
769+
770+
example:foafOnlineAccountAsset a odrl:Asset, sh:NodeShape ;
771+
odrl:partOf example:peopleGraph ;
772+
sh:targetClass foaf:OnlineAccount .
773+
774+
example:publicRead a odrl:Permission ;
775+
odrl:action odrl:read ;
776+
odrl:target example:peopleGraph ;
777+
odrl:assignee example:authenticatedUserParty .
778+
779+
example:publicWrite a odrl:Permission ;
780+
odrl:action odrl:modify ;
781+
odrl:target example:peopleGraph ;
782+
odrl:assignee example:authenticatedUserParty .
783+
```
784+
785+
Now say you have a service `peopleservice` in your application which requires periodically retrieve the names of the `foaf:Person`s in the `people` graph. In your `docker-compose.yml` entry for this service, specify a value for the `DEFAULT_MU_AUTH_SCOPE` environment variable. The `peopleservice` will supply this value in the header of each outgoing request.
786+
787+
```yaml
788+
services:
789+
peopleservice:
790+
image: example/peopleservice:0.0.1
791+
environment:
792+
DEFAULT_MU_AUTH_SCOPE: "http://services.semantic.works/people-service"
793+
```
794+
795+
In your sparql-parser configuration you can use the `ext:scope` predicate to specify a scope for a permission. For instance, the following snippet essentially states that the permissions are applicable for requests with the scope `"http://services.semantic.works/people-service"`.
796+
797+
```ttl
798+
example:publicRead a odrl:Permission ;
799+
odrl:action odrl:read ;
800+
odrl:target example:peopleGraph ;
801+
odrl:assignee example:authenticatedUserParty ;
802+
ext:scope "http://services.semantic.works/people-service" .
803+
804+
example:publicWrite a odrl:Permission ;
805+
odrl:action odrl:modify ;
806+
odrl:target example:peopleGraph ;
807+
odrl:assignee example:authenticatedUserParty ;
808+
ext:scope "http://services.semantic.works/people-service" .
809+
```
810+
811+
It is possible to specify multiple scopes for a single permission. In this case a permission will be applicable if a request specifies one of the scopes in its header. For example, the following snippet apply to requests that specify as scope header either `"http://services.semantic.works/people-service"` or `"http://services.semantic.works/another-service"`.
812+
813+
```ttl
814+
example:publicRead a odrl:Permission ;
815+
odrl:action odrl:read ;
816+
odrl:target example:peopleGraph ;
817+
odrl:assignee example:authenticatedUserParty ;
818+
ext:scope "http://services.semantic.works/people-service" ,
819+
"http://services.semantic.works/another-service"
820+
```
743821

744822
## Reference
745823
### ACL configuration interface

0 commit comments

Comments
 (0)