%META:TOPICPARENT{name="ValQuickStartGuide"}%
---+ SPARQL ACLs in Virtuoso
%TOC%
---++ Introduction
Virtuoso uses the [[http://docs.openlinksw.com/val/val_acl.html][VAL ACL system]]
to control access to named graphs, and to SPARQL in general. When enabled, these rules are automatically enforced in
various Virtuoso interaction including the /sparql
endpoints, and can also be used manually in any other
application as described below.
SPARQL access is controlled in two ways:
* General access ACLs grant a person the basic right to perform SPARQL SELECT
, UPDATE
,
or SPONGE
queries. These ACL rules always apply to the same specific resource URI, urn:virtuoso:access:sparql
,
has a scope of [[http://www.openlinksw.com/c/9D2L64WF][oplacl:Query]]
. For historical reasons, this ACL
is disabled by default, which grants everyone the right to SELECT
, UPDATE
, and SPONGE
.
See below on how to enable the ACL scope, and thus, the evaluation of the rules.
* Named graph ACLs grant access to specific private graphs. (Public graphs are always fully accessible, or
they are not really public. See below for details.) These ACL rules grant access to one private graph at a time, and
have a scope of [[http://www.openlinksw.com/c/9DPPK5PP][oplacl:PrivateGraphs]]
.
---++ Private Graphs used for ACL storage
The Rules can be controlled via two APIs --
* [[http://docs.openlinksw.com/val/group__val__acl__module__http__api.html][RESTful VAL ACL API]]
* [[http://docs.openlinksw.com/val/group__val__acl__module__internal__api.html#ga89b2c77c10c82186ddc0e7b46093123c][Internal VAL API]]
Alternatively, one can manually add rules to the private graph matching the realm in which the rules should apply. Such manual addition
means that two properties of each rule, [[http://www.openlinksw.com/c/9BHM6464][oplacl:hasRealm]]
and
[[http://www.openlinksw.com/c/9CZ4K3FH][foaf:maker]]
, which are invisibly and automatically managed by the APIs, must
also be manually managed.
Given the default realm --
http://www.openlinksw.com/ontology/acl#DefaultRealm
-- and the default hostname --
{HOST-CNAME}
-- the graph IRI would be --
http://{HOST-CNAME}/acl/graph/rules/http%3A%2F%2Fwww.openlinksw.com%2Fontology%2Facl%23DefaultRealm
-- and the groups would be stored in named graph --
http://{HOST-CNAME}/acl/graph/groups/http%3A%2F%2Fwww.openlinksw.com%2Fontology%2Facl%23DefaultRealm
Note: [[http://docs.openlinksw.com/val/val_configuration.html#val_configuration_acl_graphs][these defaults can be customized]] for better readability.
---++ Enabling or Disabling ACL Rule Evalution
Each set of ACL rules is defined as one ACL scope.
As implied above, there are two ACL scopes in VAL, each with a set of default access modes which are used if ACL rule evaluation has been disabled. The purpose and default configurations of these two scopes are --
* [[http://www.openlinksw.com/c/9D2L64WF][oplacl:Query]]
for general SPARQL access
PREFIX acl:
PREFIX oplacl:
INSERT
INTO
{
oplacl:PrivateGraphs a oplacl:Scope ;
rdfs:label "Sparql" ;
rdfs:comment """Sparql ACL scopes which contains all ACL rules granting access to specific named graphs.
By default ACLs are disabled. System admins can enabled ACLs. There are no default access
modes since Virtuoso only applies ACLs to private graphs which should remain private.""" ;
oplacl:hasApplicableAccess oplacl:Read ,
oplacl:Write ,
oplacl:Sponge .
};
* [[http://www.openlinksw.com/c/9DPPK5PP][oplacl:PrivateGraphs]]
for access to specific private graphs
PREFIX acl:
PREFIX oplacl:
INSERT
INTO
{
oplacl:Query a oplacl:Scope ;
rdfs:label "SQL" ;
rdfs:comment """SQL ACL scopes which contains all ACL rules granting permission to perform SQL operations
or SPARQL operations in general. The latter is complemented by the sparql scope which contains
rules for named graph access.""" ;
oplacl:hasApplicableAccess oplacl:Read ,
oplacl:Write ,
oplacl:Sponge ;
oplacl:hasDefaultAccess oplacl:Read ,
oplacl:Write ,
oplacl:Sponge .
};
A scope can be explicitly enabled or disabled in any given realm. By default, they are neither, which means that it is up to the application to decide.
Given the default realm [[http://www.openlinksw.com/ontology/acl#DefaultRealm][oplacl:DefaultRealm]]
, the evaluation of ACLs for private
graphs could be disabled as follows:
SPARQL
PREFIX oplacl:
WITH
DELETE
{
oplacl:DefaultRealm oplacl:hasEnabledAclScope oplacl:PrivateGraphs .
}
INSERT
{
oplacl:DefaultRealm oplacl:hasDisabledAclScope oplacl:PrivateGraphs .
};
To enable the evalution of general SPARQL access rules in the default realm one would use:
SPARQL
PREFIX oplacl:
WITH
DELETE
{
oplacl:DefaultRealm oplacl:hasDisabledAclScope oplacl:Query .
}
INSERT
{
oplacl:DefaultRealm oplacl:hasEnabledAclScope oplacl:Query .
};
---++ Examples
In the following examples --
* the default realm [[http://www.openlinksw.com/ontology/acl#DefaultRealm][oplacl:DefaultRealm]]
is used for creating the ACL resources.
* {HOST-CNAME}
is used as a placeholder for the default hostname of the system on which the ACL resource are created.
Note: [[http://docs.openlinksw.com/val/val_configuration.html#val_configuration_acl_graphs][these defaults can be customized]] for better readability.
---+++ Example ACL Rules for General SPARQL Access
---++++ Grant Everyone the Right To SPARQL Select
SPARQL
PREFIX oplacl:
PREFIX acl:
PREFIX foaf:
WITH
INSERT
{
<{RULE-IRI}> a acl:Authorization ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasAccessMode oplacl:Read ;
acl:accessTo ;
acl:agentClass foaf:Agent ;
oplacl:hasScope oplacl:Query ;
oplacl:hasRealm oplacl:DefaultRealm .
};
---++++ Grant an Individual the Right to Grant Sponge Permissions
SPARQL
PREFIX oplacl:
PREFIX acl:
PREFIX foaf:
WITH
INSERT
{
<{RULE-IRI}> a acl:Authorization ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasAccessMode oplacl:GrantSponge ;
acl:accessTo ;
acl:agent <{AGENT-IRI}> ;
oplacl:hasScope oplacl:Query ;
oplacl:hasRealm oplacl:DefaultRealm .
};
---++++ Granting Permissions to a Group Of People
---+++++ First, Create a Group
There are two types of groups:
* static defined by a simple list of individuals, as seen below
* conditional defined by a set of conditions which describe a dynamic group of individuals
---++++++ A Static Group
SPARQL
PREFIX oplacl:
PREFIX foaf:
WITH
INSERT
{
<{GROUP-IRI}> a foaf:Group,
oplacl:StaticGroup ;
foaf:name "Some people" ;
foaf:maker <{ADMIN-IRI}> ;
foaf:member <{AGENT-IRI-1}> ,
[...]
<{AGENT-IRI-N}> .
};
---++++++ A Conditional Group of Anyone who has Authenticated
The Required Group in a [[http://docs.openlinksw.com/val/val_acl.html#val_acl_groups_conditional][conditional group]] which includes every authenticated NetID:
SPARQL
PREFIX oplacl:
PREFIX foaf:
WITH
INSERT
{
<{GROUP-IRI}> a oplacl:ConditionalGroup ;
foaf:name "Valid Identifiers" ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasCondition [
a oplacl:GroupCondition,
oplacl:GenericCondition ;
oplacl:hasCriteria oplacl:NetID ;
oplacl:hasComparator oplacl:IsNotNull ;
oplacl:hasValue 1
] .
};
---++++++ A Conditional Group of Anyone who has a Verified WebID
The Required Group in a [[http://docs.openlinksw.com/val/val_acl.html#val_acl_groups_conditional][conditional group]] which includes every authenticated NetID:
SPARQL
PREFIX oplacl:
PREFIX foaf:
WITH
INSERT
{
<{GROUP-IRI}> a oplacl:ConditionalGroup ;
foaf:name "Valid WebIDs" ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasCondition [
a oplacl:GroupCondition,
oplacl:GenericCondition ;
oplacl:hasCriteria oplacl:WebIDVerified ;
oplacl:hasComparator oplacl:EqualTo ;
oplacl:hasValue 1
] .
};
---++++++ A Conditional Group of Anyone who has presented a Valid X.509 Client Certificate
The Required Group in a [[http://docs.openlinksw.com/val/val_acl.html#val_acl_groups_conditional][conditional group]] which includes every valid X.509 certificate:
SPARQL
PREFIX oplacl:
PREFIX foaf:
WITH
INSERT
{
<{GROUP-IRI}> a oplacl:ConditionalGroup ;
foaf:name "Valid X.509 Certificates" ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasCondition [
a oplacl:GroupCondition,
oplacl:GenericCondition ;
oplacl:hasCriteria oplacl:CertVerified ;
oplacl:hasComparator oplacl:EqualTo ;
oplacl:hasValue 1
] .
};
---++++++ A Conditional Group of Any Verified WebID Which Claims to be a Person
Query conditions consist of a query which supports two variables which are replaced with the profile graph and the personal URI respectively.
SPARQL
PREFIX oplacl:
PREFIX foaf:
WITH
INSERT
{
<{GROUP-IRI}> a oplacl:ConditionalGroup ;
foaf:name "Valid WebIDs" ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasCondition [
a oplacl:GroupCondition,
oplacl:GenericCondition ;
oplacl:hasCriteria oplacl:WebIDVerified ;
oplacl:hasComparator oplacl:EqualTo ;
oplacl:hasValue 1
] ,
[
a oplacl:GroupCondition,
oplacl:QueryCondition ;
oplacl:hasQuery """ASK WHERE { GRAPH ^{graph}^ { ^{uri}^ a foaf:Person } }"""
]
};
---+++++ Second, Create a Rule to Grant Privileges to the Group Members
---++++++ An ACL Rule to grant Sponge Privileges to the Group Members
Once the group has been created it can be referenced in a new Authorization that provides members with the ability to grant Sponge privileges to others so that they too can use the Sponger functionality via SPARQL based data access:
SPARQL
PREFIX oplacl:
PREFIX acl:
PREFIX foaf:
WITH
INSERT
{
<{RULE-IRI}> a acl:Authorization ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasAccessMode oplacl:Sponge ;
acl:accessTo ;
acl:agent <{GROUP-IRI}> ;
oplacl:hasScope oplacl:Query ;
oplacl:hasRealm oplacl:DefaultRealm .
};
---++++++ An ACL Rule to grant Write Privileges to the Group Members
Once the group has been created it can be referenced in a new Authorization that provides members with Write (Insert, Update, and Delete) privileges via SPARQL data access:
SPARQL
PREFIX oplacl:
PREFIX acl:
PREFIX foaf:
WITH
INSERT
{
<{RULE-IRI}> a acl:Authorization ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasAccessMode oplacl:Write ;
acl:accessTo ;
acl:agent <{GROUP-IRI}> ;
oplacl:hasScope oplacl:Query ;
oplacl:hasRealm oplacl:DefaultRealm .
};
---+++ Example ACL Rules for Access To Private Graphs
---++++ Grant Read Access on a Private Graph to an Individual
SPARQL
PREFIX oplacl:
PREFIX acl:
WITH
INSERT
{
<{RULE-IRI}> a acl:Authorization ;
foaf:maker <{ADMIN-IRI}> ;
oplacl:hasAccessMode oplacl:Read ;
acl:accessTo <{NAMED-GRAPH-IRI}> ;
acl:agent <{AGENT-IRI}> ;
oplacl:hasScope oplacl:PrivateGraphs ;
oplacl:hasRealm oplacl:DefaultRealm .
};
---++ See Also
* [[VAL_SpongerACLs][Sponger ACLs]]
* [[http://docs.openlinksw.com/val/val_acl.html][VAL ACL System]]
* [[VAL_SqlACLs][SQL ACLs - Control SPARQL Access in SQL Connections (ODBC)]]