From b11428955518c83b2995def8ab57daeba66e15de Mon Sep 17 00:00:00 2001 From: Nordine Bittich Date: Thu, 7 Oct 2021 15:51:29 +0200 Subject: [PATCH] refactoring PR --- config/authorization/config.ex | 49 +++++++++++++++++++++------------- docker-compose.yml | 2 +- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/config/authorization/config.ex b/config/authorization/config.ex index 3e699fb..6d2e096 100644 --- a/config/authorization/config.ex +++ b/config/authorization/config.ex @@ -7,10 +7,13 @@ alias Acl.GroupSpec, as: GroupSpec alias Acl.GroupSpec.GraphCleanup, as: GraphCleanup defmodule Acl.UserGroups.Config do +@account_type [ + "http://xmlns.com/foaf/0.1/Person", + "http://xmlns.com/foaf/0.1/OnlineAccount" +] @protected_resource_type [ "http://www.w3.org/ns/org#Organization", "http://data.vlaanderen.be/ns/besluit#Bestuurseenheid", - "http://xmlns.com/foaf/0.1/OnlineAccount", "http://data.lblod.info/vocabularies/erediensten/BestuurVanDeEredienst", "http://data.vlaanderen.be/ns/besluit#Bestuursorgaan", "http://data.lblod.info/vocabularies/erediensten/RolBedienaar", @@ -25,8 +28,7 @@ defmodule Acl.UserGroups.Config do "http://data.lblod.info/vocabularies/erediensten/VerbondenJuridischeStructuren", "http://www.w3.org/ns/prov#Location", "http://www.w3.org/ns/org#Site", - "http://www.w3.org/ns/locn#Address", - "http://xmlns.com/foaf/0.1/Person", + "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", @@ -77,18 +79,15 @@ defmodule Acl.UserGroups.Config do def user_groups do [ - %GroupSpec{ + %GroupSpec{ name: "acmidm", useage: [:read, :write, :read_for_write], access: %AccessByQuery{ query: "PREFIX ext: PREFIX mu: - PREFIX musession: - SELECT ?s WHERE { - ?s ?p ?o. - FILTER NOT EXISTS { - ext:hasAccount ?account. - } + PREFIX session: + SELECT ?account WHERE { + session:account ?account. } LIMIT 1", vars: [] }, @@ -100,6 +99,26 @@ defmodule Acl.UserGroups.Config do } } ] + }, + %GroupSpec{ + name: "account", + useage: [:read], + access: %AccessByQuery{ + query: "PREFIX mu: + PREFIX session: + SELECT ?account WHERE { + session:account ?account. + } LIMIT 1", + vars: [] + }, + graphs: [ + %GraphSpec{ + graph: "http://mu.semte.ch/graphs/contacthub/accounts", + constraint: %ResourceConstraint{ + resource_types: @account_type + } + } + ] }, %GroupSpec{ name: "ch-admin", @@ -121,16 +140,8 @@ defmodule Acl.UserGroups.Config do "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/" - } } ] }, + } }]}, - - - # // CLEANUP # %GraphCleanup{ diff --git a/docker-compose.yml b/docker-compose.yml index 5d19d38..0d6b68c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -102,7 +102,7 @@ services: links: - db:database environment: - MU_APPLICATION_GRAPH: "http://mu.semte.ch/graphs/contacthub/141d9d6b-54af-4d17-b313-8d1c30bc3f5b/ChAdmin" + MU_APPLICATION_GRAPH: "http://mu.semte.ch/graphs/contacthub/accounts" MU_APPLICATION_AUTH_DISCOVERY_URL: "https://authenticatie-ti.vlaanderen.be/op" MU_APPLICATION_AUTH_CLIENT_ID: "677af572-2e2f-4e61-ad38-036723bb314c" MU_APPLICATION_AUTH_REDIRECT_URI: "https://organisaties.abb.lblod.info/authorization/callback"