Skip to content

Commit

Permalink
Don't use a connection string to connect to the database
Browse files Browse the repository at this point in the history
This is because migratus prints out the entire connection string
in case of errors, which can leak sensitive information.

See yogthos/migratus#189
  • Loading branch information
jysandy committed Sep 4, 2020
1 parent e1d0b53 commit b68c170
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 36 deletions.
29 changes: 17 additions & 12 deletions config/config.ci.edn
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{:db-connection-string "jdbc:postgresql://localhost:5432/chronograph_ci?user=chronograph_ci_user&password=chronograph_ci_pwd"
:oauth {:google {:redirect-uri "http://localhost:8000/google-oauth2-redirect"
:response-type "code"
:login-endpoint "https://accounts.google.com/o/oauth2/v2/auth"
:token-endpoint "https://oauth2.googleapis.com/token"
:client-id "test-client-id"
:client-secret "test-client-secret"
:scope "test scopes"}}
:auth {:token-signing-key "your-signing-key-here"
:token-expiry-in-seconds 3600}
:app-log-level "debug"
:port 8000}
{:db-spec {:dbtype "postgresql"
:dbname "chronograph_ci"
:host "localhost"
:port 5432
:user "chronograph_ci_user"
:password "chronograph_ci_pwd"}
:oauth {:google {:redirect-uri "http://localhost:8000/google-oauth2-redirect"
:response-type "code"
:login-endpoint "https://accounts.google.com/o/oauth2/v2/auth"
:token-endpoint "https://oauth2.googleapis.com/token"
:client-id "test-client-id"
:client-secret "test-client-secret"
:scope "test scopes"}}
:auth {:token-signing-key "your-signing-key-here"
:token-expiry-in-seconds 3600}
:app-log-level "debug"
:port 8000}
25 changes: 15 additions & 10 deletions config/config.dev.edn
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{:db-connection-string "jdbc:postgresql://localhost:19401/chronograph_dev?user=chronograph_dev&password=chronograph_devpwd"
:oauth {:google #merge [{:redirect-uri "http://localhost:8000/google-oauth2-redirect"
:response-type "code"
:login-endpoint "https://accounts.google.com/o/oauth2/v2/auth"
:token-endpoint "https://oauth2.googleapis.com/token"}
#include "google.secrets.edn"]}
:auth {:token-signing-key "your-signing-key-here"
:token-expiry-in-seconds 3600}
:app-log-level "debug"
:port 8000}
{:db-spec {:dbtype "postgresql"
:dbname "chronograph_dev"
:host "localhost"
:port 19401
:user "chronograph_dev"
:password "chronograph_devpwd"}
:oauth {:google #merge [{:redirect-uri "http://localhost:8000/google-oauth2-redirect"
:response-type "code"
:login-endpoint "https://accounts.google.com/o/oauth2/v2/auth"
:token-endpoint "https://oauth2.googleapis.com/token"}
#include "google.secrets.edn"]}
:auth {:token-signing-key "your-signing-key-here"
:token-expiry-in-seconds 3600}
:app-log-level "debug"
:port 8000}
29 changes: 17 additions & 12 deletions config/config.test.edn
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{:db-connection-string "jdbc:postgresql://localhost:19401/chronograph_test?user=chronograph_test&password=chronograph_testpwd"
:oauth {:google {:redirect-uri "http://localhost:8000/google-oauth2-redirect"
:response-type "code"
:login-endpoint "https://accounts.google.com/o/oauth2/v2/auth"
:token-endpoint "https://oauth2.googleapis.com/token"
:client-id "test-client-id"
:client-secret "test-client-secret"
:scope "test scopes"}}
:auth {:token-signing-key "your-signing-key-here"
:token-expiry-in-seconds 3600}
:app-log-level "debug"
:port 8000}
{:db-spec {:dbtype "postgresql"
:dbname "chronograph_test"
:host "localhost"
:port 19401
:user "chronograph_test"
:password "chronograph_testpwd"}
:oauth {:google {:redirect-uri "http://localhost:8000/google-oauth2-redirect"
:response-type "code"
:login-endpoint "https://accounts.google.com/o/oauth2/v2/auth"
:token-endpoint "https://oauth2.googleapis.com/token"
:client-id "test-client-id"
:client-secret "test-client-secret"
:scope "test scopes"}}
:auth {:token-signing-key "your-signing-key-here"
:token-expiry-in-seconds 3600}
:app-log-level "debug"
:port 8000}
2 changes: 1 addition & 1 deletion src/clj/chronograph/db/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(jdbc-date-time/read-as-instant)

(defstate datasource
:start (jdbc/get-datasource {:jdbcUrl (:db-connection-string config/config)})
:start (jdbc/get-datasource (:db-spec config/config))
:stop nil)

(def sql-opts {:builder-fn jdbc-result-set/as-unqualified-kebab-maps
Expand Down
2 changes: 1 addition & 1 deletion src/clj/chronograph/migrations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

(defn config []
{:store :database
:db {:connection-uri (:db-connection-string config/config)}})
:db (:db-spec config/config)})

(defn create-migration [migration-name]
(migratus/create (config) migration-name))
Expand Down

0 comments on commit b68c170

Please sign in to comment.