Skip to content

Commit

Permalink
db: Remove sensitive cols from echoed data
Browse files Browse the repository at this point in the history
  • Loading branch information
goshatch committed Sep 5, 2024
1 parent 18c27f9 commit f5378e9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/apossiblespace/parts/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
:migration-dir "migrations"
:db db-spec})

(def sensitive-columns #{:password_hash})

(defn- remove-sensitive-data [data]
(apply dissoc data sensitive-columns))

(defn init-db
[]
(mulog/log ::initializing-database)
Expand All @@ -68,10 +73,13 @@
(defn insert!
[table data]
(let [data-with-uuid (assoc data :id (generate-uuid))]
(jdbc/execute! write-datasource
(-> (jdbc/execute! write-datasource
(sql/format {:insert-into table
:values [data-with-uuid]})
{:builder-fn rs/as-unqualified-maps})))
:values [data-with-uuid]
:returning :*})
{:builder-fn rs/as-unqualified-maps})
first
remove-sensitive-data)))

(defn update!
[table data where-clause]
Expand Down

0 comments on commit f5378e9

Please sign in to comment.