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
a96841e9
Commit
a96841e9
authored
9 years ago
by
Cam Saül
Browse files
Options
Downloads
Plain Diff
Merge pull request #1369 from metabase/mongo-ssl-support
Mongo SSL Support #1312
parents
8f90a38a
d98cc368
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontend/src/lib/core.js
+1
-0
1 addition, 0 deletions
frontend/src/lib/core.js
src/metabase/driver/mongo.clj
+6
-2
6 additions, 2 deletions
src/metabase/driver/mongo.clj
src/metabase/driver/mongo/util.clj
+15
-10
15 additions, 10 deletions
src/metabase/driver/mongo/util.clj
with
22 additions
and
12 deletions
frontend/src/lib/core.js
+
1
−
0
View file @
a96841e9
...
...
@@ -262,4 +262,5 @@ import _ from "underscore";
});
});
};
}).
apply
(
exports
);
This diff is collapsed.
Click to expand it.
src/metabase/driver/mongo.clj
+
6
−
2
View file @
a96841e9
...
...
@@ -125,7 +125,7 @@
{
:driver-name
"MongoDB"
:details-fields
[{
:name
"host"
:display-name
"Host"
:default
"localhost"
}
:default
"localhost"
}
{
:name
"port"
:display-name
"Port"
:type
:integer
...
...
@@ -140,7 +140,11 @@
{
:name
"pass"
:display-name
"Database password"
:type
:password
:placeholder
"******"
}]
:placeholder
"******"
}
{
:name
"ssl"
:display-name
"Use a secure connection (SSL)?"
:type
:boolean
:default
false
}]
:features
#
{
:nested-fields
}
:can-connect?
can-connect?
:active-table-names
active-table-names
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver/mongo/util.clj
+
15
−
10
View file @
a96841e9
...
...
@@ -22,12 +22,16 @@
Bound by top-level `with-mongo-connection` so it may be reused within its body."
nil
)
(
def
^
:private
mongo-connection-options
;; Have to use the Java builder directly since monger's wrapper method doesn't support .serverSelectionTimeout :unamused:
(
defn-
build-connection-options
"Build connection options for Mongo.
We have to use `MongoClientOptions.Builder` directly to configure our Mongo connection
since Monger's wrapper method doesn't support `.serverSelectionTimeout` or `.sslEnabled`."
[
&
{
:keys
[
ssl?
]}]
(
->
(
com.mongodb.MongoClientOptions$Builder.
)
(
.connectTimeout
connection-timeout-ms
)
(
.serverSelectionTimeout
connection-timeout-ms
)
(
.build
)))
(
.sslEnabled
ssl?
)
.build
))
;; The arglists metadata for mg/connect are actually *WRONG* -- the function additionally supports a 3-arg airity where you can pass
;; options and credentials, as we'd like to do. We need to go in and alter the metadata of this function ourselves because otherwise
...
...
@@ -40,12 +44,13 @@
"Run F with a new connection (bound to `*mongo-connection*`) to DATABASE.
Don't use this directly; use `with-mongo-connection`."
[
f
database
]
(
let
[{
:keys
[
dbname
host
port
user
pass
]
:or
{
port
27017
,
pass
""
}}
(
cond
(
string?
database
)
{
:dbname
database
}
(
:dbname
(
:details
database
))
(
:details
database
)
; entire Database obj
(
:dbname
database
)
database
; connection details map only
:else
(
throw
(
Exception.
(
str
"with-mongo-connection failed: bad connection details:"
(
:details
database
)))))
;; The Mongo SSL detail is keyed by :use-ssl because the frontend has accidentally been saving all of the Mongo DBs with {:ssl true}
(
let
[{
:keys
[
dbname
host
port
user
pass
use-ssl
]
:or
{
port
27017
,
pass
""
,
use-ssl
false
}}
(
cond
(
string?
database
)
{
:dbname
database
}
(
:dbname
(
:details
database
))
(
:details
database
)
; entire Database obj
(
:dbname
database
)
database
; connection details map only
:else
(
throw
(
Exception.
(
str
"with-mongo-connection failed: bad connection details:"
(
:details
database
)))))
user
(
when
(
seq
user
)
; ignore empty :user and :pass strings
user
)
pass
(
when
(
seq
pass
)
...
...
@@ -53,7 +58,7 @@
server-address
(
mg/server-address
host
port
)
credentials
(
when
user
(
mcred/create
user
dbname
pass
))
connect
(
partial
mg/connect
server-address
mongo
-connection-options
)
connect
(
partial
mg/connect
server-address
(
build
-connection-options
:ssl?
use-ssl
)
)
conn
(
if
credentials
(
connect
credentials
)
(
connect
))
...
...
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