This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from rmetcalf9/master
Pullrequest for #168
- Loading branch information
Showing
5 changed files
with
166 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Changing the default user seed data | ||
|
||
Konga will populate the user table with default entries if it finds none are present. If you wish to change the default data you can supply a file with alternative values. A sample file could look like: | ||
|
||
```` | ||
module.exports = [ | ||
{ | ||
"username": "myadmin", | ||
"email": "myadmin@some.domain", | ||
"firstName": "Peter", | ||
"lastName": "Administrator", | ||
"node_id": "http://kong:8001", | ||
"admin": true, | ||
"active" : true, | ||
"password": "somepassword" | ||
}, | ||
{ | ||
"username": "otheruser", | ||
"email": "otheruser@some.domain", | ||
"firstName": "Joe", | ||
"lastName": "Blogs", | ||
"node_id": "http://kong:8001", | ||
"admin": false, | ||
"active" : true, | ||
"password": "anotherpassword" | ||
} | ||
] | ||
```` | ||
|
||
To make Konga use this file instead of the hardcoded default users you should set the enviroment variable KONGA_SEED_USER_DATA_SOURCE_FILE to point to the files location: | ||
```` | ||
export KONGA_SEED_USER_DATA_SOURCE_FILE=~/userdb.data | ||
```` | ||
|
||
This is espically useful when running Konga in a container as part of a Docker swarm. The file can be setup as a Docker secret and supplied to the container. This can be done with an entry in a compose file simular to: | ||
|
||
```` | ||
version: "3.1" | ||
secrets: | ||
konga_user_seed: | ||
external: true | ||
services: | ||
konga: | ||
image: pantsel/konga | ||
secrets: | ||
- konga_user_seed | ||
environment: | ||
- KONGA_SEED_USER_DATA_SOURCE_FILE=/run/secrets/konga_user_seed | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
ports: | ||
- 1337:1337 | ||
```` | ||
|
||
(This will work if the swarm is setup with the konga_user_seed secret set with it's value as the contents of the user file.) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Created by rmetcalf9 on 5/2/2018. | ||
*/ | ||
'use strict'; | ||
var fs = require('fs'); | ||
|
||
/* | ||
Return the seed data to be used, either from a file or hardcoded depending | ||
on enviroment variable setting | ||
*/ | ||
function getseedData() { | ||
var readEnvVar = process.env.KONGA_SEED_USER_DATA_SOURCE_FILE; | ||
if (typeof(readEnvVar) == 'undefined') { | ||
readEnvVar = undefined; | ||
} else { | ||
readEnvVar = readEnvVar.trim(); | ||
if (readEnvVar.length == 0) { | ||
readEnvVar = undefined; | ||
} else { | ||
if (!fs.existsSync(readEnvVar)) { | ||
console.log('Could not find KONGA_SEED_USER_DATA_SOURCE_FILE'); | ||
readEnvVar = undefined; | ||
} | ||
try { | ||
var seedUserData = require(readEnvVar); | ||
if (typeof(seedUserData) != 'object') { | ||
readEnvVar = undefined; | ||
} else { | ||
// We may place other checks on file contents here if required | ||
console.log('Sucessfully read in user seed data file'); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
console.log('Failed to load KONGA_SEED_USER_DATA_SOURCE_FILE'); | ||
console.log('Reverting to default user seed'); | ||
readEnvVar = undefined; | ||
} | ||
} | ||
} | ||
if(typeof(readEnvVar) == 'undefined') { | ||
return [ | ||
{ | ||
"username": "admin", | ||
"email": "admin@some.domain", | ||
"firstName": "Arnold", | ||
"lastName": "Administrator", | ||
"node_id": "http://kong:8001", | ||
"admin": true, | ||
"active" : true, | ||
"password": "adminadminadmin" | ||
}, | ||
{ | ||
"username": "demo", | ||
"email": "demo@some.domain", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
"node_id": "http://kong:8001", | ||
"admin": false, | ||
"active" : true, | ||
"password": "demodemodemo" | ||
} | ||
]; | ||
}; | ||
return seedUserData | ||
} | ||
|
||
module.exports = { | ||
seedData: getseedData() | ||
} | ||
|