Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
cb005ca6
Unverified
Commit
cb005ca6
authored
6 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Warn on Postgres conn str w/ ssl=true but not sslmode=require
parent
810e7a61
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/db.clj
+22
-12
22 additions, 12 deletions
src/metabase/db.clj
test/metabase/db_test.clj
+8
-5
8 additions, 5 deletions
test/metabase/db_test.clj
with
30 additions
and
17 deletions
src/metabase/db.clj
+
22
−
12
View file @
cb005ca6
...
...
@@ -55,18 +55,28 @@
return a broken-out map."
[
uri
]
(
when-let
[[
_
_
protocol
user
pass
host
port
db
query
]
(
re-matches
jdbc-connection-regex
uri
)]
(
merge
{
:type
(
case
(
keyword
protocol
)
:postgres
:postgres
:postgresql
:postgres
:mysql
:mysql
)
:user
user
:password
pass
:host
host
:port
port
:dbname
db
}
(
some->
query
codec/form-decode
walk/keywordize-keys
))))
(
u/prog1
(
merge
{
:type
(
case
(
keyword
protocol
)
:postgres
:postgres
:postgresql
:postgres
:mysql
:mysql
)
:user
user
:password
pass
:host
host
:port
port
:dbname
db
}
(
some->
query
codec/form-decode
walk/keywordize-keys
))
;; If someone is using Postgres and specifies `ssl=true` they might need to specify `sslmode=require`. Let's let
;; them know about that to make their lives a little easier. See https://github.com/metabase/metabase/issues/8908
;; for more details.
(
when
(
and
(
=
(
:type
<>
)
:postgres
)
(
=
(
:ssl
<>
)
"true"
)
(
not
(
:sslmode
<>
)))
(
log/warn
(
trs
"Warning: Postgres connection string with `ssl=true` detected."
)
(
trs
"You may need to add `?sslmode=require` to your application DB connection string."
)
(
trs
"If Metabase fails to launch, please add it and try again."
)
(
trs
"See https://github.com/metabase/metabase/issues/8908 for more details."
))))))
(
def
^
:private
connection-string-details
(
delay
(
when-let
[
uri
(
config/config-str
:mb-db-connection-uri
)]
...
...
This diff is collapsed.
Click to expand it.
test/metabase/db_test.clj
+
8
−
5
View file @
cb005ca6
(
ns
metabase.db-test
(
:require
[
expectations
:refer
[
expect
]]
[
metabase.db
:as
mdb
]))
[
metabase.db
:as
mdb
]
[
metabase.test.util.log
:as
tu.log
]))
;; parse minimal connection string
(
expect
...
...
@@ -16,12 +17,14 @@
(
expect
{
:type
:postgres,
:user
"tom"
,
:password
"1234"
,
:host
"localhost"
,
:port
"5432"
,
:dbname
"toms_cool_db"
,
:ssl
"true"
,
:sslfactory
"org.postgresql.ssl.NonValidatingFactory"
}
(
#
'mdb/parse-connection-string
(
str
"postgres://tom:1234@localhost:5432/toms_cool_db"
"?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"
)))
(
tu.log/suppress-output
(
#
'mdb/parse-connection-string
(
str
"postgres://tom:1234@localhost:5432/toms_cool_db"
"?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"
))))
;; the leading "jdbc" found in driver JDBC docs should be ignored
(
expect
{
:type
:postgres,
:user
"tom"
,
:password
"1234"
,
:host
"localhost"
,
:port
"5432"
,
:dbname
"toms_cool_db"
,
:ssl
"true"
,
:sslfactory
"org.postgresql.ssl.NonValidatingFactory"
}
(
#
'mdb/parse-connection-string
(
str
"jdbc:postgres://tom:1234@localhost:5432/toms_cool_db"
"?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"
)))
(
tu.log/suppress-output
(
#
'mdb/parse-connection-string
(
str
"jdbc:postgres://tom:1234@localhost:5432/toms_cool_db"
"?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"
))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment