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

[BeatsCM] Fixes and issue where if security is disabled, BeatsCM breaks Kibana #24249

Merged
merged 5 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
};

public render = (component: React.ReactElement<any>) => {
this.rootComponent = component;
if (this.hadValidLicense() && this.securityEnabled()) {
this.rootComponent = component;
}
};

public hadValidLicense() {
Expand All @@ -77,10 +79,10 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
}

public registerManagementSection(pluginId: string, displayName: string, basePath: string) {
this.register(this.uiModule);
if (this.hadValidLicense() && this.securityEnabled()) {
this.register(this.uiModule);

this.hookAngular(() => {
if (this.hadValidLicense() && this.securityEnabled()) {
this.hookAngular(() => {
const registerSection = () =>
this.management.register(pluginId, {
display: 'Beats', // TODO these need to be config options not hard coded in the adapter
Expand All @@ -97,13 +99,13 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
order: 30,
url: `#${basePath}`,
});
}

if (!this.securityEnabled()) {
this.notifier.error(this.xpackInfo.get(`features.beats_management.message`));
this.kbnUrlService.redirect('/management');
}
});
// if (!this.securityEnabled()) {
// this.notifier.error(this.xpackInfo.get(`features.beats_management.message`));
// this.kbnUrlService.redirect('/management');
// }
Copy link
Member

Choose a reason for hiding this comment

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

If you're not using this I would delete it.

});
}
}

private manageAngularLifecycle($scope: any, $route: any, elem: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export class KibanaBackendFrameworkAdapter implements BackendFrameworkAdapter {
}

public exposeStaticDir(urlPath: string, dir: string): void {
if (!this.isSecurityEnabled()) {
return;
}
this.server.route({
handler: {
directory: {
Expand All @@ -73,6 +76,9 @@ export class KibanaBackendFrameworkAdapter implements BackendFrameworkAdapter {
public registerRoute<RouteRequest extends FrameworkWrappableRequest, RouteResponse>(
route: FrameworkRouteOptions<RouteRequest, RouteResponse>
) {
if (!this.isSecurityEnabled()) {
return;
}
const wrappedHandler = (licenseRequired: boolean) => (request: any, reply: any) => {
const xpackMainPlugin = this.server.plugins.xpack_main;
const licenseCheckResults = xpackMainPlugin.info.feature(PLUGIN.ID).getLicenseCheckResults();
Expand All @@ -90,6 +96,13 @@ export class KibanaBackendFrameworkAdapter implements BackendFrameworkAdapter {
});
}

private isSecurityEnabled = () => {
return (
this.server.plugins.xpack_main.info.isAvailable() &&
this.server.plugins.xpack_main.info.feature('security').isEnabled()
);
};

private validateConfig() {
// @ts-ignore
const config = this.server.config();
Expand All @@ -111,7 +124,7 @@ export class KibanaBackendFrameworkAdapter implements BackendFrameworkAdapter {
securityEnabled: false,
licenseValid: false,
message:
'You cannot manage Beats centeral management because license information is not available at this time.',
'You cannot manage Beats central management because license information is not available at this time.',
};
}

Expand All @@ -127,7 +140,7 @@ export class KibanaBackendFrameworkAdapter implements BackendFrameworkAdapter {
return {
securityEnabled: true,
licenseValid: false,
message: `Your ${licenseType} license does not support Beats centeral management features. Please upgrade your license.`,
message: `Your ${licenseType} license does not support Beats central management features. Please upgrade your license.`,
};
}

Expand All @@ -136,14 +149,14 @@ export class KibanaBackendFrameworkAdapter implements BackendFrameworkAdapter {
return {
securityEnabled: true,
licenseValid: false,
message: `You cannot edit, create, or delete your Beats centeral management configurations because your ${licenseType} license has expired.`,
message: `You cannot edit, create, or delete your Beats central management configurations because your ${licenseType} license has expired.`,
};
}

// Security is not enabled in ES
if (!isSecurityEnabled) {
const message =
'Security must be enabled in order to use Beats centeral management features.' +
'Security must be enabled in order to use Beats central management features.' +
' Please set xpack.security.enabled: true in your elasticsearch.yml.';
return {
securityEnabled: false,
Expand Down