Skip to content

Commit 5caa385

Browse files
authored
Merge branch 'feature-make-it-ingest' into feature/fleet/agent-enrollment
2 parents fcd56d3 + fb77f20 commit 5caa385

17 files changed

Lines changed: 272 additions & 29 deletions

File tree

x-pack/legacy/plugins/fleet/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ export function fleet(kibana: any) {
6161
attributesToEncrypt: new Set(['token']),
6262
attributesToExcludeFromAAD: new Set(['enrollment_rules']),
6363
});
64+
server.plugins.xpack_main.registerFeature({
65+
id: 'fleet',
66+
name: 'Fleet',
67+
app: ['fleet', 'kibana'],
68+
excludeFromBasePrivileges: true,
69+
privileges: {
70+
all: {
71+
savedObject: {
72+
all: ['agents', 'events', 'tokens'],
73+
read: [],
74+
},
75+
ui: ['read', 'write'],
76+
api: ['fleet-read', 'fleet-all'],
77+
},
78+
read: {
79+
savedObject: {
80+
all: [],
81+
read: ['agents', 'events', 'tokens'],
82+
},
83+
ui: ['read'],
84+
api: ['fleet-read'],
85+
},
86+
},
87+
});
6488
initServerWithKibana(server);
6589
},
6690
});

x-pack/legacy/plugins/fleet/public/lib/adapters/framework/adapter_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface FrameworkAdapter {
1313
// Instance vars
1414
info: FrameworkInfo;
1515
version: string;
16+
capabilities: { read: boolean; write: boolean };
1617
currentUser: FrameworkUser;
1718
// Methods
1819
waitUntilFrameworkReady(): Promise<void>;

x-pack/legacy/plugins/fleet/public/lib/adapters/framework/kibana_framework_adapter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { isLeft } from 'fp-ts/lib/Either';
1111
import * as React from 'react';
1212
import * as ReactDOM from 'react-dom';
1313
import { UIRoutes } from 'ui/routes';
14+
import { capabilities } from 'ui/capabilities';
1415
import { BufferedKibanaServiceCall, KibanaAdapterServiceRefs, KibanaUIConfig } from '../../types';
1516
import {
1617
FrameworkAdapter,
@@ -36,6 +37,10 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
3637
public get currentUser() {
3738
return this.shieldUser!;
3839
}
40+
public get capabilities(): Readonly<{ read: boolean; write: boolean }> {
41+
return capabilities.get().fleet as { read: boolean; write: boolean };
42+
}
43+
3944
private xpackInfo: FrameworkInfo | null = null;
4045
private adapterService: KibanaAdapterServiceProvider;
4146
private shieldUser: FrameworkUser | null = null;

x-pack/legacy/plugins/fleet/public/lib/framework.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export class FrameworkLib {
2121
return this.adapter.currentUser;
2222
}
2323

24+
public get capabilities(): { read: boolean; write: boolean } {
25+
return this.adapter.capabilities;
26+
}
27+
2428
public get info() {
2529
return this.adapter.info;
2630
}

x-pack/legacy/plugins/fleet/public/pages/agent_list/index.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,16 @@ export const AgentListPage: React.SFC<RouterProps> = ({ libs }) => {
154154
</h2>
155155
}
156156
actions={
157-
<EuiButton fill iconType="plusInCircle" onClick={() => setIsEnrollmentFlyoutOpen(true)}>
158-
<FormattedMessage
159-
id="xpack.fleet.agentList.addButton"
160-
defaultMessage="Install new agent"
161-
/>
162-
</EuiButton>
157+
libs.framework.capabilities.write ? (
158+
<EuiButton fill iconType="plusInCircle" onClick={() => setIsEnrollmentFlyoutOpen(true)}>
159+
<FormattedMessage
160+
id="xpack.fleet.agentList.addButton"
161+
defaultMessage="Install new agent"
162+
/>
163+
</EuiButton>
164+
) : (
165+
null
166+
)
163167
}
164168
/>
165169
);
@@ -191,14 +195,16 @@ export const AgentListPage: React.SFC<RouterProps> = ({ libs }) => {
191195
<EuiFlexItem grow={4}>
192196
<SearchBar libs={libs} value={search} onChange={setSearch} fieldPrefix="agents" />
193197
</EuiFlexItem>
194-
<EuiFlexItem>
195-
<EuiButton fill iconType="plusInCircle" onClick={() => setIsEnrollmentFlyoutOpen(true)}>
196-
<FormattedMessage
197-
id="xpack.fleet.agentList.addButton"
198-
defaultMessage="Install new agent"
199-
/>
200-
</EuiButton>
201-
</EuiFlexItem>
198+
{libs.framework.capabilities.write && (
199+
<EuiFlexItem>
200+
<EuiButton fill iconType="plusInCircle" onClick={() => setIsEnrollmentFlyoutOpen(true)}>
201+
<FormattedMessage
202+
id="xpack.fleet.agentList.addButton"
203+
defaultMessage="Install new agent"
204+
/>
205+
</EuiButton>
206+
</EuiFlexItem>
207+
)}
202208
</EuiFlexGroup>
203209

204210
<EuiSpacer size="m" />

x-pack/legacy/plugins/fleet/public/pages/error/no_access.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const NoAccessPage = injectI18n(({ intl }) => (
2020
<FormattedMessage
2121
id="xpack.fleet.noAccess.accessDeniedDescription"
2222
defaultMessage="You are not authorized to access Elastic Fleet. To use Elastic Fleet,
23-
you need the privileges granted by the {elasticFleetRole} role."
23+
you need a user role that contains read or all permissions for this application."
2424
values={{ elasticFleetRole: '`elastic_admin`' }}
2525
/>
2626
</p>

x-pack/legacy/plugins/fleet/public/routes.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ export class AppRoutes extends Component<RouterProps, RouterState> {
6363
/>
6464
)}
6565

66+
{!this.props.libs.framework.capabilities.read && (
67+
<Route
68+
render={props =>
69+
!props.location.pathname.includes('/error') ? (
70+
<Redirect to="/error/no_access" />
71+
) : null
72+
}
73+
/>
74+
)}
75+
6676
{/* Ensure security is eanabled for elastic and kibana */}
6777
{/* TODO: Disabled for now as we don't have this info set up on backend yet */}
6878
{/* {!get(this.props.libs.framework.info, 'security.enabled', true) && (

x-pack/legacy/plugins/fleet/server/routes/agents/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import { AgentAction } from '../../../common/types/domain_data';
1717
export const createAgentsAddActionRoute = (libs: FleetServerLib) => ({
1818
method: 'POST',
1919
path: '/api/fleet/agents/{agentId}/actions',
20-
config: {
20+
options: {
21+
tags: ['access:fleet-all'],
2122
validate: {
2223
payload: Joi.object(),
2324
},

x-pack/legacy/plugins/fleet/server/routes/agents/delete.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import { FleetServerLib } from '../../libs/types';
1414

1515
export const createDeleteAgentsRoute = (libs: FleetServerLib) => ({
1616
method: 'DELETE',
17-
config: {},
1817
path: '/api/fleet/agents/{id}',
18+
options: {
19+
tags: ['access:fleet-all'],
20+
},
1921
handler: async (
2022
request: FrameworkRequest<{ params: { id: string } }>,
2123
h: FrameworkResponseToolkit

x-pack/legacy/plugins/fleet/server/routes/agents/enroll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Agent } from '../../../common/types/domain_data';
1313
export const createEnrollAgentsRoute = (libs: FleetServerLib) => ({
1414
method: 'POST',
1515
path: '/api/fleet/agents/enroll',
16-
config: {
16+
options: {
1717
auth: false,
1818
validate: {
1919
headers: Joi.object({

0 commit comments

Comments
 (0)