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

[7.x] [CCR] Allow user to use CCR when security is not enabled. (#35333) #35337

Merged
merged 1 commit into from
Apr 19, 2019
Merged
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions x-pack/plugins/cross_cluster_replication/server/routes/api/ccr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import Boom from 'boom';

import { callWithRequestFactory } from '../../lib/call_with_request_factory';
import { isEsErrorFactory } from '../../lib/is_es_error_factory';
import { wrapEsError, wrapUnknownError } from '../../lib/error_wrappers';
Expand Down Expand Up @@ -51,6 +54,24 @@ export const registerCcrRoutes = (server) => {
pre: [ licensePreRouting ]
},
handler: async (request) => {
const xpackMainPlugin = server.plugins.xpack_main;
const xpackInfo = (xpackMainPlugin && xpackMainPlugin.info);

if (!xpackInfo) {
// xpackInfo is updated via poll, so it may not be available until polling has begun.
// In this rare situation, tell the client the service is temporarily unavailable.
throw new Boom('Security info unavailable', { statusCode: 503 });
}

const securityInfo = (xpackInfo && xpackInfo.isAvailable() && xpackInfo.feature('security'));
if (!securityInfo || !securityInfo.isEnabled()) {
// If security isn't enabled, let the user use CCR.
return {
hasPermission: true,
missingClusterPrivileges: [],
};
}

const callWithRequest = callWithRequestFactory(server, request);

try {
Expand Down