Feature/mock login (#23)

This commit is contained in:
Nordine Bittich
2021-08-04 16:49:07 +02:00
committed by GitHub
parent f24c994b90
commit f4b25b639a
11 changed files with 276 additions and 11 deletions

View File

@@ -7,14 +7,30 @@ alias Acl.GroupSpec, as: GroupSpec
alias Acl.GroupSpec.GraphCleanup, as: GraphCleanup
defmodule Acl.UserGroups.Config do
defp access_by_role( group_string ) do
%AccessByQuery{
vars: ["session_group","session_role"],
query: sparql_query_for_access_role( group_string ) }
end
defp sparql_query_for_access_role( group_string ) do
"PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
SELECT ?session_group ?session_role WHERE {
<SESSION_ID> ext:sessionGroup/mu:uuid ?session_group;
ext:sessionRole ?session_role.
FILTER( ?session_role = \"#{group_string}\" )
}"
end
def user_groups do
[
%GroupSpec{
name: "public",
%GroupSpec{
name: "ch-admin",
useage: [:read, :write, :read_for_write],
access: %AlwaysAccessible{},
access: access_by_role( "ChAdmin" ),
graphs: [ %GraphSpec{
graph: "http://mu.semte.ch/graphs/public",
graph: "http://mu.semte.ch/graphs/contacthub/",
constraint: %ResourceConstraint{
resource_types: [
"http://www.w3.org/ns/org#Organization",
@@ -51,9 +67,48 @@ defmodule Acl.UserGroups.Config do
"http://lblod.data.gift/vocabularies/organisatie/BestuurseenheidClassificatieCode",
"http://lblod.data.gift/vocabularies/organisatie/TypeBetrokkenheid",
"http://www.w3.org/2004/02/skos/core#ConceptScheme",
"http://www.w3.org/2004/02/skos/core#Concept"
"http://www.w3.org/2004/02/skos/core#Concept",
"http://xmlns.com/foaf/0.1/Image",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject" ] } } ] },
%GroupSpec{
name: "public",
useage: [:read],
access: %AlwaysAccessible{},
graphs: [ %GraphSpec{
graph: "http://mu.semte.ch/graphs/public",
constraint: %ResourceConstraint{
resource_types: [
"http://data.vlaanderen.be/ns/besluit#Bestuurseenheid",
"http://xmlns.com/foaf/0.1/Person",
"http://xmlns.com/foaf/0.1/OnlineAccount"
]
} },
%GraphSpec{
graph: "http://mu.semte.ch/graphs/sessions",
constraint: %ResourceFormatConstraint{
resource_prefix: "http://mu.semte.ch/sessions/"
} } ] },
%GroupSpec{
name: "org",
useage: [:read],
access: %AccessByQuery{
vars: ["session_group"],
query: "PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
SELECT ?session_group ?session_role WHERE {
<SESSION_ID> ext:sessionGroup/mu:uuid ?session_group.
}" },
graphs: [ %GraphSpec{
graph: "http://mu.semte.ch/graphs/organizations/",
constraint: %ResourceConstraint{
resource_types: [
"http://xmlns.com/foaf/0.1/Person",
"http://xmlns.com/foaf/0.1/OnlineAccount",
"http://www.w3.org/ns/adms#Identifier",
] } } ] },
# // CLEANUP
#
%GraphCleanup{
originating_graph: "http://mu.semte.ch/application",
useage: [:read, :write],

View File

@@ -245,7 +245,7 @@ LoadPath = /usr/local/virtuoso-opensource/lib/virtuoso/hosting
;Load1 = plain, wikiv
;Load2 = plain, mediawiki
;Load3 = plain, creolewiki
;Load4 = plain, im
;Load4 = plain, im
;Load5 = plain, wbxml2
;Load6 = plain, hslookup
;Load7 = attach, libphp5.so

View File

@@ -194,7 +194,21 @@ defmodule Dispatcher do
# sparql endpoint
###############################################################
match "/sparql/*path", %{ accept: [:any], layer: :api} do
forward conn, path, "http://db:8890/sparql/"
Proxy.forward conn, path, "http://db:8890/sparql/"
end
###############
# LOGIN
match "/accounts/*path", %{ accept: [:json], layer: :api} do
Proxy.forward conn, path, "http://resource/accounts/"
end
match "/groups/*path", %{ accept: [:json], layer: :api} do
Proxy.forward conn, path, "http://resource/groups/"
end
match "/mock/sessions/*path", %{ accept: [:any], layer: :api} do
Proxy.forward conn, path, "http://mocklogin/sessions/"
end
###############

View File

@@ -0,0 +1,32 @@
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX mu:<http://mu.semte.ch/vocabularies/core/>
PREFIX ext:<http://mu.semte.ch/vocabularies/ext/>
INSERT DATA {
GRAPH <http://mu.semte.ch/application> {
<http://data.lblod.info/id/persoon/d39fe09e-d339-4e43-8680-dbbcfb3d3470> a foaf:Person ;
mu:uuid "d39fe09e-d339-4e43-8680-dbbcfb3d3470" ;
foaf:firstName "Mock" ;
foaf:familyName "Agentschap Binnenlands Bestuur" ;
foaf:member <http://data.lblod.info/id/bestuurseenheden/141d9d6b-54af-4d17-b313-8d1c30bc3f5b> ;
foaf:account <http://data.lblod.info/id/account/3a91ff60-07c1-4136-ac5e-55cf401e0956> .
<http://data.lblod.info/id/account/3a91ff60-07c1-4136-ac5e-55cf401e0956> a foaf:OnlineAccount ;
mu:uuid "3a91ff60-07c1-4136-ac5e-55cf401e0956" ;
foaf:accountServiceHomepage <https://github.com/lblod/mock-login-service>;
ext:sessionRole "ChAdmin".
}
GRAPH <http://mu.semte.ch/graphs/organizations/141d9d6b-54af-4d17-b313-8d1c30bc3f5b> {
<http://data.lblod.info/id/persoon/d39fe09e-d339-4e43-8680-dbbcfb3d3470> a foaf:Person ;
mu:uuid "d39fe09e-d339-4e43-8680-dbbcfb3d3470" ;
foaf:firstName "Mock" ;
foaf:familyName "Agentschap Binnenlands Bestuur" ;
foaf:member <http://data.lblod.info/id/bestuurseenheden/141d9d6b-54af-4d17-b313-8d1c30bc3f5b> ;
foaf:account <http://data.lblod.info/id/account/3a91ff60-07c1-4136-ac5e-55cf401e0956> .
<http://data.lblod.info/id/account/3a91ff60-07c1-4136-ac5e-55cf401e0956> a foaf:OnlineAccount ;
mu:uuid "3a91ff60-07c1-4136-ac5e-55cf401e0956" ;
foaf:accountServiceHomepage <https://github.com/lblod/mock-login-service>;
ext:sessionRole "ChAdmin".
}
}

View File

@@ -0,0 +1,13 @@
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
INSERT DATA {
GRAPH <http://mu.semte.ch/application> {
<http://data.lblod.info/id/bestuurseenheden/141d9d6b-54af-4d17-b313-8d1c30bc3f5b> a besluit:Bestuurseenheid ;
mu:uuid "141d9d6b-54af-4d17-b313-8d1c30bc3f5b" ;
skos:prefLabel "Agentschap Binnenlands Bestuur" ;
dcterms:identifier "OVO001835" .
}
}

View File

@@ -0,0 +1,18 @@
DELETE {
GRAPH <http://mu.semte.ch/application> {
?s ?p ?o .
}
} INSERT {
GRAPH <http://mu.semte.ch/graphs/public> {
?s ?p ?o .
}
} WHERE {
GRAPH <http://mu.semte.ch/application> {
?s a ?type ; ?p ?o .
VALUES ?type {
<http://data.vlaanderen.be/ns/besluit#Bestuurseenheid>
<http://xmlns.com/foaf/0.1/Person>
<http://xmlns.com/foaf/0.1/OnlineAccount>
}
}
}

View File

@@ -0,0 +1,52 @@
DELETE {
GRAPH <http://mu.semte.ch/application> {
?s ?p ?o .
}
} INSERT {
GRAPH <http://mu.semte.ch/graphs/contacthub/141d9d6b-54af-4d17-b313-8d1c30bc3f5b/ChAdmin> {
?s ?p ?o .
}
} WHERE {
GRAPH <http://mu.semte.ch/application> {
?s a ?type ; ?p ?o .
VALUES ?type {
<http://www.w3.org/ns/org#Organization>
<http://data.vlaanderen.be/ns/besluit#Bestuurseenheid>
<http://data.lblod.info/vocabularies/erediensten/BestuurVanDeEredienst>
<http://data.vlaanderen.be/ns/besluit#Bestuursorgaan>
<http://data.lblod.info/vocabularies/erediensten/Eredienstbestuursorgaan>
<http://www.w3.org/ns/adms#Identifier>
<https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator>
<http://www.w3.org/ns/org#ChangeEvent>
<http://data.lblod.info/vocabularies/erediensten/BetrokkenLokaleBesturen>
<http://www.w3.org/ns/prov#Location>
<http://www.w3.org/ns/org#Site>
<http://www.w3.org/ns/locn#Address>
<http://www.w3.org/ns/person#Person>
<http://data.vlaanderen.be/ns/mandaat#Mandaat>
<http://data.vlaanderen.be/ns/mandaat#Mandataris>
<http://data.lblod.info/vocabularies/erediensten/EredienstMandataris>
<http://schema.org/ContactPoint>
<http://data.lblod.info/vocabularies/leidinggevenden/Bestuursfunctie>
<http://data.lblod.info/vocabularies/erediensten/CentraalBestuurVanDeEredienst>
<http://data.lblod.info/vocabularies/erediensten/CentraleBestuursorgaan>
<http://data.lblod.info/vocabularies/erediensten/RepresentatiefOrgaan>
<http://www.w3.org/ns/org#Role>
<http://www.w3.org/ns/org#Post>
<http://data.lblod.info/vocabularies/contacthub/AgentInPositie>
<http://lblod.data.gift/vocabularies/organisatie/OrganisatieStatusCode>
<http://lblod.data.gift/vocabularies/organisatie/BestuursfunctieCode>
<http://lblod.data.gift/vocabularies/organisatie/BestuursorgaanClassificatieCode>
<http://lblod.data.gift/vocabularies/organisatie/TypeEredienst>
<http://lblod.data.gift/vocabularies/organisatie/HelftVerkiezing>
<http://lblod.data.gift/vocabularies/organisatie/Veranderingsgebeurtenis>
<http://lblod.data.gift/vocabularies/organisatie/MandatarisStatusCode>
<http://lblod.data.gift/vocabularies/organisatie/BestuurseenheidClassificatieCode>
<http://lblod.data.gift/vocabularies/organisatie/TypeBetrokkenheid>
<http://www.w3.org/2004/02/skos/core#ConceptScheme>
<http://www.w3.org/2004/02/skos/core#Concept>
<http://xmlns.com/foaf/0.1/Image>
<http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject>
}
}
}

View File

@@ -0,0 +1,73 @@
{
"version": "0.1",
"prefixes": {
"foaf": "http://xmlns.com/foaf/0.1/",
"besluit": "http://data.vlaanderen.be/ns/besluit#",
"dct": "http://purl.org/dc/terms/",
"skos": "http://www.w3.org/2004/02/skos/core#"
},
"resources": {
"users": {
"name": "user",
"class": "foaf:Person",
"attributes": {
"first-name": {
"type": "string",
"predicate": "foaf:firstName"
},
"family-name": {
"type": "string",
"predicate": "foaf:familyName"
}
},
"relationships": {
"accounts": {
"predicate": "foaf:account",
"target": "account",
"cardinality": "many"
},
"groups": {
"predicate": "foaf:member",
"target": "group",
"cardinality": "many"
}
},
"new-resource-base": "http://data.lblod.info/id/gebruiker/"
},
"accounts": {
"name": "account",
"class": "foaf:OnlineAccount",
"attributes": {
"provider": {
"type": "string",
"predicate": "foaf:accountServiceHomepage"
},
"identifier": {
"type": "string",
"predicate": "dct:identifier"
}
},
"relationships": {
"user": {
"predicate": "foaf:account",
"target": "user",
"cardinality": "one",
"inverse": true
}
},
"new-resource-base": "http://data.lblod.info/id/account/"
},
"groups": {
"name": "group",
"class": "besluit:Bestuurseenheid",
"attributes": {
"name": {
"type": "string",
"predicate": "skos:prefLabel"
}
},
"relationships": {},
"new-resource-base": "http://data.lblod.info/id/bestuurseenheden/"
}
}
}

View File

@@ -11,4 +11,5 @@
(defparameter *cache-count-queries* t)
(defparameter *supply-cache-headers-p* t)
(read-domain-file "domain.json")
(read-domain-file "domain.json")
(read-domain-file "auth.json")

View File

@@ -11,6 +11,9 @@ services:
restart: "no"
db:
restart: "no"
triplestore:
ports:
- "8890:8890"
migrations:
restart: "no"
resource:
@@ -26,4 +29,8 @@ services:
kalliope-api:
restart: "no"
deltanotifier:
restart: "no"
restart: "no"
mocklogin:
image: lblod/mock-login-service:latest
links:
- db:database

View File

@@ -9,10 +9,10 @@ x-logging:
services:
identifier:
image: semtech/mu-identifier:1.9.1
image: semtech/mu-identifier:1.8.1
environment:
DEFAULT_ACCESS_CONTROL_ALLOW_ORIGIN_HEADER: "*"
DEFAULT_MU_AUTH_ALLOWED_GROUPS_HEADER: "[{\"variables\":[],\"name\":\"public\"}, {\"variables\":[],\"name\":\"clean\"}]"
DEFAULT_MU_AUTH_ALLOWED_GROUPS_HEADER: "[{\"variables\":[],\"name\":\"public\"}]"
labels:
- "logging=true"
restart: always