Skip to content
Snippets Groups Projects
Commit fedd7225 authored by Bryan Maass's avatar Bryan Maass
Browse files

Revert "WIP: Pairing on making perms checking less wild"

Keep the same behavior, but stick with the saner flow control

This reverts commit 63bcb5b4.
parent 00b623c7
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
:feature :advanced-permissions :feature :advanced-permissions
[{database-id :database :as query}] [{database-id :database :as query}]
(or (or
#_(not= :blocked (data-perms/full-db-permission-for-user api/*current-user-id* :perms/view-data database-id)) (not= :blocked (data-perms/full-db-permission-for-user api/*current-user-id* :perms/view-data database-id))
(let [table-ids #p (query-perms/query->source-table-ids query)] (let [table-ids (query-perms/query->source-table-ids query)]
(= #{:unrestricted} (= #{:unrestricted}
(set (set
(map (partial data-perms/table-permission-for-user api/*current-user-id* :perms/view-data database-id) (map (partial data-perms/table-permission-for-user api/*current-user-id* :perms/view-data database-id)
......
...@@ -186,11 +186,12 @@ ...@@ -186,11 +186,12 @@
"Checks that the current user has at least `required-perm` for the entire DB specified by `db-id`." "Checks that the current user has at least `required-perm` for the entire DB specified by `db-id`."
[perm-type required-perm gtap-perms db-id] [perm-type required-perm gtap-perms db-id]
(or (or
(data-perms/at-least-as-permissive? perm-type (data-perms/at-least-as-permissive? perm-type
(data-perms/full-db-permission-for-user api/*current-user-id* perm-type db-id) (data-perms/full-db-permission-for-user api/*current-user-id* perm-type db-id)
required-perm) required-perm)
(when gtap-perms (when gtap-perms
(data-perms/at-least-as-permissive? perm-type gtap-perms required-perm)))) (data-perms/at-least-as-permissive? perm-type gtap-perms required-perm))
(throw (perms-exception {db-id {perm-type required-perm}}))))
(defn- has-perm-for-table? (defn- has-perm-for-table?
"Checks that the current user has the permissions for tables specified in `table-id->perm`. This can be satisfied via "Checks that the current user has the permissions for tables specified in `table-id->perm`. This can be satisfied via
...@@ -236,9 +237,8 @@ ...@@ -236,9 +237,8 @@
`throw-exceptions?` to `false`). `throw-exceptions?` to `false`).
If the [:gtap ::perms] path is present in the query, these perms are implicitly granted to the current user." If the [:gtap ::perms] path is present in the query, these perms are implicitly granted to the current user."
[{{gtap-perms :gtaps} ::perms, :as query} [{{gtap-perms :gtaps} ::perms, :as query} required-perms & {:keys [throw-exceptions?]
required-perms & {:keys [throw-exceptions?] :or {throw-exceptions? true}}]
:or {throw-exceptions? true}}]
(try (try
;; Check any required v1 paths ;; Check any required v1 paths
(when-let [paths (:paths required-perms)] (when-let [paths (:paths required-perms)]
......
...@@ -97,8 +97,8 @@ ...@@ -97,8 +97,8 @@
;; set when querying for field values of dashboard filters, which only require ;; set when querying for field values of dashboard filters, which only require
;; collection perms for the dashboard and not ad-hoc query perms ;; collection perms for the dashboard and not ad-hoc query perms
*param-values-query* *param-values-query*
(when-not (query-perms/has-perm-for-query? outer-query :perms/view-data required-perms) (when-not (query-perms/check-data-perms outer-query required-perms :throw-exceptions? false)
(throw (query-perms/perms-exception required-perms))) (check-block-permissions outer-query))
:else :else
(do (do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment