Skip to content
Snippets Groups Projects
Unverified Commit 832c9172 authored by Cam Saul's avatar Cam Saul
Browse files

Fix some long lines

parent 6e8159c7
Branches
Tags
No related merge requests found
......@@ -10,7 +10,9 @@
[toucan.models :as models])
(:import java.sql.Blob))
;;; ------------------------------------------------------------ Toucan Extensions ------------------------------------------------------------
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | Toucan Extensions |
;;; +----------------------------------------------------------------------------------------------------------------+
(models/set-root-namespace! 'metabase.models)
......@@ -46,7 +48,8 @@
(def ^:private encrypted-json-out (comp json-out encryption/maybe-decrypt))
;; cache the decryption/JSON parsing because it's somewhat slow (~500µs vs ~100µs on a *fast* computer)
(def ^:private cached-encrypted-json-out (memoize/ttl encrypted-json-out :ttl/threshold (* 60 60 1000))) ; cache decrypted JSON for one hour
;; cache the decrypted JSON for one hour
(def ^:private cached-encrypted-json-out (memoize/ttl encrypted-json-out :ttl/threshold (* 60 60 1000)))
(models/add-type! :encrypted-json
:in encrypted-json-in
......@@ -94,14 +97,18 @@
:update add-updated-at-timestamp)
;;; ------------------------------------------------------------ New Permissions Stuff ------------------------------------------------------------
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | New Permissions Stuff |
;;; +----------------------------------------------------------------------------------------------------------------+
(defprotocol IObjectPermissions
"Methods for determining whether the current user has read/write permissions for a given object."
(perms-objects-set [this, ^clojure.lang.Keyword read-or-write]
"Return a set of permissions object paths that a user must have access to in order to access this object. This should be something like #{\"/db/1/schema/public/table/20/\"}.
READ-OR-WRITE will be either `:read` or `:write`, depending on which permissions set we're fetching (these will be the same sets for most models; they can ignore this param).")
"Return a set of permissions object paths that a user must have access to in order to access this object. This
should be something like #{\"/db/1/schema/public/table/20/\"}. READ-OR-WRITE will be either `:read` or `:write`,
depending on which permissions set we're fetching (these will be the same sets for most models; they can ignore
this param).")
(can-read? ^Boolean [instance], ^Boolean [entity, ^Integer id]
"Return whether `*current-user*` has *read* permissions for an object. You should use one of these implmentations:
......@@ -109,7 +116,8 @@
* `(constantly true)`
* `superuser?`
* `(partial current-user-has-full-permissions? :read)` (you must also implement `perms-objects-set` to use this)
* `(partial current-user-has-partial-permissions? :read)` (you must also implement `perms-objects-set` to use this)")
* `(partial current-user-has-partial-permissions? :read)` (you must also implement `perms-objects-set` to use
this)")
(^{:hydrate :can_write} can-write? ^Boolean [instance], ^Boolean [entity, ^Integer id]
"Return whether `*current-user*` has *write* permissions for an object. You should use one of these implmentations:
......@@ -117,7 +125,8 @@
* `(constantly true)`
* `superuser?`
* `(partial current-user-has-full-permissions? :write)` (you must also implement `perms-objects-set` to use this)
* `(partial current-user-has-partial-permissions? :write)` (you must also implement `perms-objects-set` to use this)"))
* `(partial current-user-has-partial-permissions? :write)` (you must also implement `perms-objects-set` to use
this)"))
(def IObjectPermissionsDefaults
"Default implementations for `IObjectPermissions`."
......@@ -147,14 +156,14 @@
(def ^{:arglists '([read-or-write entity object-id] [read-or-write object])}
^Boolean current-user-has-full-permissions?
"Implementation of `can-read?`/`can-write?` for the new permissions system.
`true` if the current user has *full* permissions for the paths returned by its implementation of `perms-objects-set`.
(READ-OR-WRITE is either `:read` or `:write` and passed to `perms-objects-set`; you'll usually want to partially bind it in the implementation map)."
"Implementation of `can-read?`/`can-write?` for the new permissions system. `true` if the current user has *full*
permissions for the paths returned by its implementation of `perms-objects-set`. (READ-OR-WRITE is either `:read` or
`:write` and passed to `perms-objects-set`; you'll usually want to partially bind it in the implementation map)."
(make-perms-check-fn 'metabase.models.permissions/set-has-full-permissions-for-set?))
(def ^{:arglists '([read-or-write entity object-id] [read-or-write object])}
^Boolean current-user-has-partial-permissions?
"Implementation of `can-read?`/`can-write?` for the new permissions system.
`true` if the current user has *partial* permissions for the paths returned by its implementation of `perms-objects-set`.
(READ-OR-WRITE is either `:read` or `:write` and passed to `perms-objects-set`; you'll usually want to partially bind it in the implementation map)."
"Implementation of `can-read?`/`can-write?` for the new permissions system. `true` if the current user has *partial*
permissions for the paths returned by its implementation of `perms-objects-set`. (READ-OR-WRITE is either `:read` or
`:write` and passed to `perms-objects-set`; you'll usually want to partially bind it in the implementation map)."
(make-perms-check-fn 'metabase.models.permissions/set-has-partial-permissions-for-set?))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment