Skip to content

Commit f5d73c0

Browse files
author
Robin Duda
committed
Added an utility to add users to json/mongodb.
1 parent d2ced3c commit f5d73c0

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ To install the plugin use the kibana-plugin utility, example:
3838
./kibana-plugin install 'file:///C:/users/downloads/kbn-authentication-plugin.zip'
3939
```
4040

41-
Default username and password is: 'username' and 'password'.
41+
Default username and password is: 'username' and 'password' for the file storage.
42+
43+
To add a new user run the adduser utility, not supported in LDAP mode.
44+
```
45+
node adduser.js USERNAME PASSWORD
46+
```
4247

4348
Make sure to set the correct version in json.config. The version must match the version of Kibana being used.
4449

adduser.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const Authentication = require('./src/authentication/auth');
2+
const Config = require('./src/config').get();
3+
4+
5+
Authentication.setStorage(Config.storage);
6+
7+
if (process.argv.length === 4) {
8+
let user = process.argv[2];
9+
let password = process.argv[3];
10+
11+
Authentication.create(user, password, done => {
12+
console.log('user ' + user + ' was added to storage (' + Config.storage + ')');
13+
});
14+
} else {
15+
console.log('This utility adds a new user to the configured storage (' + Config.storage + ').');
16+
console.log('Usage: node adduser.js <username> <password>');
17+
}

users.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
{"username":{"uid":"username","password":"$argon2i$v=19$m=16384,t=4,p=2$36gjjn3tLa3wcH/WbHLOX0zfnNewcfgy6vTVvQnizPE$501y7uNomMDNBsYeN47JSpi73wyuxS536u6MXfylAc8qoRdyZWHTWfvEakO1DFQgj8GkrdzTzBCyUPAwEPqtCA","groups":["default"],"secret":{"verified":false}},"test-username":{"secret":{"key":"IVHGIYL5EF3TSRJGJV3UYR3UHE","verified":false}}}
1+
{
2+
"username": {
3+
"uid": "username",
4+
"password": "$argon2i$v=19$m=16384,t=4,p=2$36gjjn3tLa3wcH/WbHLOX0zfnNewcfgy6vTVvQnizPE$501y7uNomMDNBsYeN47JSpi73wyuxS536u6MXfylAc8qoRdyZWHTWfvEakO1DFQgj8GkrdzTzBCyUPAwEPqtCA",
5+
"groups": [
6+
"default"
7+
],
8+
"secret": {
9+
"verified": false
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)