Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move kibana-keystore from data/ to config/ #57856

Merged
merged 28 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9443a0a
Move kibana-keystore from data/ to config/
jbudz Feb 18, 2020
f7c5772
Merge branch 'master' into mv/kibana-keystore
jbudz Feb 20, 2020
4255fc3
Merge branch 'master' into mv/kibana-keystore
elasticmachine Mar 19, 2020
f327c59
Merge branch 'mv/kibana-keystore' of github.com:jbudz/kibana into mv/…
jbudz Mar 19, 2020
909eaa5
add breaking changes
jbudz Mar 19, 2020
625b9c3
Merge branch 'master' into mv/kibana-keystore
elasticmachine Mar 19, 2020
fc13d8f
Merge branch 'master' into mv/kibana-keystore
jbudz Mar 30, 2020
f6c5439
update comment
jbudz Mar 30, 2020
2991ba2
Merge branch 'mv/kibana-keystore' of github.com:jbudz/kibana into mv/…
jbudz Mar 30, 2020
cd18ed8
Merge branch 'master' into mv/kibana-keystore
jbudz May 4, 2020
02d35c3
Merge branch 'master' into mv/kibana-keystore
elasticmachine May 14, 2020
027bda7
Merge branch 'master' into mv/kibana-keystore
elasticmachine May 15, 2020
e5f2190
Merge branch 'master' into mv/kibana-keystore
elasticmachine May 20, 2020
105d100
Merge branch 'master' into mv/kibana-keystore
jbudz May 26, 2020
ba87e36
wip
jbudz May 26, 2020
d0ecba2
Merge branch 'master' into mv/kibana-keystore
jbudz Jun 8, 2020
bb887e9
fix docs
jbudz Jun 8, 2020
dd27fab
read from both keystore locations, write priority to non-deprecated
jbudz Jun 8, 2020
beee61f
Merge branch 'master' into mv/kibana-keystore
elasticmachine Jun 12, 2020
6f7621e
Merge branch 'master' into mv/kibana-keystore
elasticmachine Jun 23, 2020
30abff0
Merge branch 'master' into mv/kibana-keystore
elasticmachine Jun 29, 2020
7edcc9d
Merge branch 'master' into mv/kibana-keystore
jbudz Jul 7, 2020
e6fb8e1
note data directory fallback
jbudz Jul 7, 2020
3c36f55
add tests for get_keystore
jbudz Jul 7, 2020
ad92279
Merge branch 'mv/kibana-keystore' of github.com:jbudz/kibana into mv/…
jbudz Jul 7, 2020
5dfce32
Merge branch 'master' into mv/kibana-keystore
jbudz Jul 7, 2020
bb6bc84
Merge branch 'master' into mv/kibana-keystore
elasticmachine Jul 9, 2020
74ab52a
Merge branch 'master' into mv/kibana-keystore
elasticmachine Jul 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/migration/migrate_8_0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,17 @@ URL that it derived from the actual server address and `xpack.security.public` s

*Impact:* Any workflow that involved manually clearing generated bundles will have to be updated with the new path.

[float]]
=== kibana.keystore has moved from the `data` folder to the `config` folder
*Details:* By default, kibana.keystore has moved from the configured `path.data` folder to `<root>/config` for archive distributions
tylersmalley marked this conversation as resolved.
Show resolved Hide resolved
and `/etc/kibana` for package distributions.

[float]
[[breaking_80_user_role_changes]]
=== User role changes

[float]
==== `kibana_user` role has been removed and `kibana_admin` has been added.
=== `kibana_user` role has been removed and `kibana_admin` has been added.

*Details:* The `kibana_user` role has been removed and `kibana_admin` has been added to better
reflect its intended use. This role continues to grant all access to every
Expand Down
22 changes: 18 additions & 4 deletions src/cli_keystore/cli_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@

import _ from 'lodash';
import { join } from 'path';
import { existsSync } from 'fs';

import Logger from '../cli_plugin/lib/logger';
import { pkg } from '../core/server/utils';
import Command from '../cli/command';
import { getDataPath } from '../core/server/path';
import { getConfigDirectory, getDataPath } from '../core/server/path';
import { Keystore } from '../legacy/server/keystore';

const path = join(getDataPath(), 'kibana.keystore');
const keystore = new Keystore(path);

import { createCli } from './create';
import { listCli } from './list';
import { addCli } from './add';
Expand All @@ -42,6 +41,21 @@ program
.version(pkg.version)
.description('A tool for managing settings stored in the Kibana keystore');

function getKeystore() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is pretty important - can we add test coverage there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3c36f55

const configKeystore = join(getConfigDirectory(), 'kibana.keystore');
const dataKeystore = join(getDataPath(), 'kibana.keystore');

if (existsSync(dataKeystore)) {
const logger = new Logger();
logger.log(
`kibana.keystore path at ${dataKeystore} is deprecated. Future versions will read from ${configKeystore}.`
);
}
return [configKeystore, dataKeystore].filter((p) => existsSync(p)).shift();
}

const keystore = new Keystore(getKeystore());

createCli(program, keystore);
listCli(program, keystore);
addCli(program, keystore);
Expand Down
7 changes: 6 additions & 1 deletion src/core/server/path/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { accessSync, constants } from 'fs';
import { getConfigPath, getDataPath } from './';
import { getConfigPath, getDataPath, getConfigDirectory } from './';

describe('Default path finder', () => {
it('should find a kibana.yml', () => {
Expand All @@ -30,4 +30,9 @@ describe('Default path finder', () => {
const dataPath = getDataPath();
expect(() => accessSync(dataPath, constants.R_OK)).not.toThrow();
});

it('should find a config directory', () => {
const configDirectory = getConfigDirectory();
expect(() => accessSync(configDirectory, constants.R_OK)).not.toThrow();
});
});
15 changes: 13 additions & 2 deletions src/core/server/path/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const CONFIG_PATHS = [
fromRoot('config/kibana.yml'),
].filter(isString);

const CONFIG_DIRECTORIES = [process.env.KIBANA_PATH_CONF, fromRoot('config'), '/etc/kibana'].filter(
isString
);

const DATA_PATHS = [
process.env.DATA_PATH, // deprecated
fromRoot('data'),
Expand All @@ -49,12 +53,19 @@ function findFile(paths: string[]) {
}

/**
* Get the path where the config files are stored
* Get the path of kibana.yml
* @internal
*/
export const getConfigPath = () => findFile(CONFIG_PATHS);

/**
* Get the directory containing configuration files
* @internal
*/
export const getConfigDirectory = () => findFile(CONFIG_DIRECTORIES);

/**
* Get the path where the data can be stored
* Get the directory containing runtime data
* @internal
*/
export const getDataPath = () => findFile(DATA_PATHS);
Expand Down