Skip to content

Commit

Permalink
Merge branch 'master' into bug-fix-58710
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 4, 2020
2 parents cd3fa15 + 2361fe6 commit 51f63b6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 31 deletions.
4 changes: 1 addition & 3 deletions test/functional/apps/dashboard/full_screen_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ export default function({ getService, getPageObjects }) {
});

it('exits when the text button is clicked on', async () => {
const logoButton = await PageObjects.dashboard.getExitFullScreenLogoButton();
await logoButton.moveMouseTo();
await PageObjects.dashboard.clickExitFullScreenTextButton();
await PageObjects.dashboard.exitFullScreenMode();
await retry.try(async () => {
const isChromeVisible = await PageObjects.common.isChromeVisible();
expect(isChromeVisible).to.be(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function exposeClient({ elasticsearchConfig, events, log, elasticsearchPl
events.on('stop', bindKey(cluster, 'close'));
const configSource = isMonitoringCluster ? 'monitoring' : 'production';
log([LOGGING_TAG, 'es-client'], `config sourced from: ${configSource} cluster`);
return cluster;
}

export function hasMonitoringCluster(config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@
import { checkLicenseGenerator } from './cluster_alerts/check_license';
import { hasMonitoringCluster } from './es_client/instantiate_client';
import { LOGGING_TAG } from '../common/constants';
import { XPackInfo } from '../../xpack_main/server/lib/xpack_info';

/*
* Expose xpackInfo for the Monitoring cluster as server.plugins.monitoring.info
*/
export const initMonitoringXpackInfo = async ({ config, xpackMainPlugin, expose, log }) => {
export const initMonitoringXpackInfo = async ({
config,
server,
client,
xpackMainPlugin,
licensing,
expose,
log,
}) => {
const xpackInfo = hasMonitoringCluster(config)
? xpackMainPlugin.createXPackInfo({
clusterSource: 'monitoring',
pollFrequencyInMillis: config.get('monitoring.xpack_api_polling_frequency_millis'),
? new XPackInfo(server, {
licensing: licensing.createLicensePoller(
client,
config.get('monitoring.xpack_api_polling_frequency_millis')
),
})
: xpackMainPlugin.info;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,29 @@ export async function verifyMonitoringAuth(req) {
async function verifyHasPrivileges(req) {
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring');

const response = await callWithRequest(req, 'transport.request', {
method: 'POST',
path: '/_security/user/_has_privileges',
body: {
index: [
{
names: [INDEX_PATTERN], // uses wildcard
privileges: ['read'],
},
],
},
ignoreUnavailable: true, // we allow 404 incase the user shutdown security in-between the check and now
});
let response;
try {
response = await callWithRequest(req, 'transport.request', {
method: 'POST',
path: '/_security/user/_has_privileges',
body: {
index: [
{
names: [INDEX_PATTERN], // uses wildcard
privileges: ['read'],
},
],
},
ignoreUnavailable: true, // we allow 404 incase the user shutdown security in-between the check and now
});
} catch (err) {
if (
err.message === 'no handler found for uri [/_security/user/_has_privileges] and method [POST]'
) {
return;
}
throw err;
}

// we assume true because, if the response 404ed, then it will not exist but we should try to continue
const hasAllRequestedPrivileges = get(response, 'has_all_requested', true);
Expand Down
4 changes: 3 additions & 1 deletion x-pack/legacy/plugins/monitoring/server/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Plugin {
const elasticsearchConfig = parseElasticsearchConfig(config);

// Create the dedicated client
await instantiateClient({
const client = await instantiateClient({
log,
events,
elasticsearchConfig,
Expand All @@ -77,6 +77,8 @@ export class Plugin {
if (uiEnabled) {
await initMonitoringXpackInfo({
config,
server: hapiServer,
client,
log,
xpackMainPlugin: plugins.xpack_main,
expose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ export function setupXPackMain(server) {
const info = new XPackInfo(server, { licensing: server.newPlatform.setup.plugins.licensing });

server.expose('info', info);
server.expose('createXPackInfo', options => {
const client = server.newPlatform.setup.core.elasticsearch.createClient(options.clusterSource);
const monitoringLicensing = server.newPlatform.setup.plugins.licensing.createLicensePoller(
client,
options.pollFrequencyInMillis
);

return new XPackInfo(server, { licensing: monitoringLicensing });
});

server.ext('onPreResponse', (request, h) => injectXPackInfoSignature(info, request, h));

Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/xpack_main/server/xpack_main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export { XPackFeature } from './lib/xpack_info';

export interface XPackMainPlugin {
info: XPackInfo;
createXPackInfo(options: XPackInfoOptions): XPackInfo;
getFeatures(): Feature[];
registerFeature(feature: FeatureWithAllOrReadPrivileges): void;
}

0 comments on commit 51f63b6

Please sign in to comment.