aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/graph/ac/null.py
blob: c9ec7d085be67e8811e46a74a5447f193a32e942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

# imports
import typing

# bsfs imports
from bsfs import schema
from bsfs.namespace import ns
from bsfs.query import ast
from bsfs.utils import URI

# inner-module imports
from . import base

# exports
__all__: typing.Sequence[str] = (
    'NullAC',
    )


## code ##

class NullAC(base.AccessControlBase):
    """The NULL access control implements a dummy policy that allows any action to any user."""

    def is_protected_predicate(self, pred: schema.Predicate) -> bool:
        """Return True if a predicate cannot be modified manually."""
        return pred.uri == ns.bsn.t_created

    def create(self, node_type: schema.Node, guids: typing.Iterable[URI]):
        """Perform post-creation operations on nodes, e.g. ownership information."""

    def link_from_node(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]:
        """Return nodes for which outbound links can be written."""
        return guids

    def link_to_node(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]:
        """Return nodes for which inbound links can be written."""
        return guids

    def write_literal(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]:
        """Return nodes to which literals can be attached."""
        return guids

    def createable(self, node_type: schema.Node, guids: typing.Iterable[URI]) -> typing.Iterable[URI]:
        """Return nodes that are allowed to be created."""
        return guids

    def filter_read(
            self,
            node_type: schema.Node,
            query: typing.Optional[ast.filter.FilterExpression]
            ) -> typing.Optional[ast.filter.FilterExpression]:
        """Re-write a filter *query* to get (i.e., read) *node_type* nodes."""
        return query

    def fetch_read(self, node_type: schema.Node, query: ast.fetch.FetchExpression) -> ast.fetch.FetchExpression:
        """Re-write a fetch *query* to get (i.e, read) values for *node_type* nodes."""
        return query

## EOF ##