Line data Source code
1 4 : (ns matchscore.domain.permission.query
2 : "Read-side of the permission aggregate. Roles come from Postgres;
3 : assignments / policies come from the in-memory enforcer cache."
4 : (:require
5 : [matchscore.access.core :as access]
6 : [matchscore.domain.permission.entity :as entity]
7 : [matchscore.domain.permission.repository.postgres :as roles-repo]))
8 :
9 :
10 4 : (defn list-roles
11 : "Lookup all roles from the `roles` table."
12 : [{:keys [repos]}]
13 24 : (when-let [repo (:roles-postgres-repo repos)] (roles-repo/get-all repo)))
14 :
15 :
16 4 : (defn find-role
17 : [{:keys [repos]} role-name]
18 26 : (when-let [repo (:roles-postgres-repo repos)] (roles-repo/find-by-name repo role-name)))
19 :
20 :
21 4 : (defn list-assignments
22 : "All `g` rows from the enforcer as Assignment maps."
23 : [ctx]
24 6 : (mapv entity/assignment-row->map (access/list-grouping-policies ctx)))
25 :
26 :
27 4 : (defn list-assignments-for-user
28 : [ctx user-uuid]
29 7 : (mapv entity/assignment-row->map (access/list-assignments-for-user ctx user-uuid)))
30 :
31 :
32 4 : (defn list-policies
33 : "All `p` rows from the enforcer as Policy maps."
34 : [ctx]
35 12 : (mapv entity/policy-row->map (access/list-policies ctx)))
|