Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move timesheet and worklogs to employee-specific graph #4

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions config/authorization/config.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
;; specifications can be folded too. This could help when building
;; indexes.

(define-graph timesheet ("http://mu.semte.ch/graphs/redpencil")
(define-graph timesheet ("http://mu.semte.ch/graphs/employees/")
("cal:Vevent" -> _)
("skos:Collection" -> _)
("foaf:Person" -> _)
Expand Down Expand Up @@ -109,29 +109,47 @@
<http://mu.semte.ch/user-groups/admin> foaf:member ?user .
} LIMIT 1")


(supply-allowed-group "employee"
:parameters ()
:parameters ("employeeId")
:query "PREFIX session: <http://mu.semte.ch/vocabularies/session/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
SELECT ?account WHERE {
SELECT ?account ?employeeId WHERE {
<SESSION_ID> session:account ?account .
?user foaf:account ?account .
<http://mu.semte.ch/user-groups/employee> foaf:member ?user .
?user mu:uuid ?employeeId .
} LIMIT 1")

(supply-allowed-group "kimai-each-employee"
:parameters ("employeeId")
:query "PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
SELECT ?employeeId WHERE {
<http://mu.semte.ch/user-groups/employee> foaf:member ?user .
?user mu:uuid ?employeeId .
}")

;; workaroud to avoid allowed-groups to be discarded because they don't have a grant
(grant (read)
:to-graph (static)
:for-allowed-group "public")
:to-graph (static)
:for-allowed-group "public")

(grant (read)
:to-graph (static)
:for-allowed-group "kimai-each-employee")
;; end workaround

(with-scope "http://services.redpencil.io/timekeeper-kimai-sync-service"
(grant (read write)
:to-graph (kimai timesheet)
:to-graph (kimai)
:for-allowed-group "public")
(grant (read)
:to-graph (users)
:for-allowed-group "public"))
:for-allowed-group "public")
(grant (read write)
:to-graph (timesheet)
:for-allowed-group "kimai-each-employee"))

(grant (read write)
:to-graph (timesheet)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX cal: <http://www.w3.org/2002/12/cal/ical#>
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
DELETE {
GRAPH <http://mu.semte.ch/graphs/redpencil> {
?s ?p ?o .
}
} INSERT {
GRAPH ?g {
?s ?p ?o .
}
} WHERE {
GRAPH <http://mu.semte.ch/graphs/redpencil> {
?s a skos:Collection .
?s ?p ?o .
?s prov:wasAssociatedWith ?employee .
}
?employee mu:uuid ?employeeId .
BIND(IRI(CONCAT("http://mu.semte.ch/graphs/employees/", ?employeeId)) AS ?g)
};
DELETE {
GRAPH <http://mu.semte.ch/graphs/redpencil> {
?s ?p ?o .
}
} INSERT {
GRAPH ?g {
?s ?p ?o .
}
} WHERE {
GRAPH <http://mu.semte.ch/graphs/redpencil> {
?s a cal:Vevent .
?s ?p ?o .
?s prov:wasAssociatedWith ?employee .
}
?employee mu:uuid ?employeeId .
BIND(IRI(CONCAT("http://mu.semte.ch/graphs/employees/", ?employeeId)) AS ?g)
}