Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
f1725159
Commit
f1725159
authored
Dec 30, 2019
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: accept db ssl config
parent
89dc81a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
config.sample.yml
config.sample.yml
+17
-4
db.js
server/core/db.js
+21
-2
No files found.
config.sample.yml
View file @
f1725159
...
...
@@ -22,6 +22,7 @@ port: 3000
db
:
type
:
postgres
# PostgreSQL / MySQL / MariaDB / MS SQL Server only:
host
:
localhost
port
:
5432
...
...
@@ -29,6 +30,19 @@ db:
pass
:
wikijsrocks
db
:
wiki
ssl
:
false
# Optional - PostgreSQL / MySQL / MariaDB only:
# -> Uncomment lines you need below and set `auto` to false
# -> Full list of accepted options: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
sslOptions
:
auto
:
true
# rejectUnauthorized: false
# ca: path/to/ca.crt
# cert: path/to/cert.crt
# key: path/to/key.pem
# pfx: path/to/cert.pfx
# passphrase: xyz123
# SQLite only:
storage
:
path/to/database.sqlite
...
...
@@ -95,7 +109,7 @@ logLevel: info
uploads
:
# Maximum upload size in bytes per file (default: 5242880 (5 MB))
maxFileSize
:
5242880
# Maximum file uploads per request (default:
2
0)
# Maximum file uploads per request (default:
1
0)
maxFiles
:
10
# ---------------------------------------------------------------------
...
...
@@ -109,5 +123,5 @@ offline: false
# ---------------------------------------------------------------------
# Data Path
# ---------------------------------------------------------------------
# Writeable data path for Wiki.js, mainly for cache and user uploads.
dataPath
:
./data
\ No newline at end of file
# Writeable data path used for cache and temporary user uploads.
dataPath
:
./data
server/core/db.js
View file @
f1725159
...
...
@@ -3,6 +3,7 @@ const autoload = require('auto-load')
const
path
=
require
(
'path'
)
const
Promise
=
require
(
'bluebird'
)
const
Knex
=
require
(
'knex'
)
const
fs
=
require
(
'fs'
)
const
Objection
=
require
(
'objection'
)
const
migrationSource
=
require
(
'../db/migrator-source'
)
...
...
@@ -34,13 +35,31 @@ module.exports = {
}
const
dbUseSSL
=
(
WIKI
.
config
.
db
.
ssl
===
true
||
WIKI
.
config
.
db
.
ssl
===
'true'
||
WIKI
.
config
.
db
.
ssl
===
1
||
WIKI
.
config
.
db
.
ssl
===
'1'
)
let
sslOptions
=
null
if
(
dbUseSSL
&&
_
.
isPlainObject
(
dbConfig
)
&&
_
.
get
(
dbConfig
,
'sslOptions.auto'
,
null
)
===
false
)
{
sslOptions
=
dbConfig
.
sslOptions
if
(
sslOptions
.
ca
)
{
sslOptions
.
ca
=
fs
.
readFileSync
(
path
.
resolve
(
WIKI
.
ROOTPATH
,
sslOptions
.
ca
))
}
if
(
sslOptions
.
cert
)
{
sslOptions
.
cert
=
fs
.
readFileSync
(
path
.
resolve
(
WIKI
.
ROOTPATH
,
sslOptions
.
cert
))
}
if
(
sslOptions
.
key
)
{
sslOptions
.
key
=
fs
.
readFileSync
(
path
.
resolve
(
WIKI
.
ROOTPATH
,
sslOptions
.
key
))
}
if
(
sslOptions
.
pfx
)
{
sslOptions
.
pfx
=
fs
.
readFileSync
(
path
.
resolve
(
WIKI
.
ROOTPATH
,
sslOptions
.
pfx
))
}
}
else
{
sslOptions
=
true
}
switch
(
WIKI
.
config
.
db
.
type
)
{
case
'postgres'
:
dbClient
=
'pg'
if
(
dbUseSSL
&&
_
.
isPlainObject
(
dbConfig
))
{
dbConfig
.
ssl
=
true
dbConfig
.
ssl
=
sslOptions
}
break
case
'mariadb'
:
...
...
@@ -48,7 +67,7 @@ module.exports = {
dbClient
=
'mysql2'
if
(
dbUseSSL
&&
_
.
isPlainObject
(
dbConfig
))
{
dbConfig
.
ssl
=
true
dbConfig
.
ssl
=
sslOptions
}
// Fix mysql boolean handling...
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment