Skip to content

Commit dc51be5

Browse files
add support for embeddable action
1 parent e0fbcc5 commit dc51be5

File tree

3 files changed

+96
-17
lines changed

3 files changed

+96
-17
lines changed

src/plugins/deprecations/server/types.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ export interface DeprecationDependencies {
1818
esClient: IScopedClusterClient;
1919
savedObjectsClient: SavedObjectsClientContract;
2020
}
21-
2221
export interface DeprecationInfo {
2322
message: string;
2423
level: 'warning' | 'critical';
2524
documentationUrl?: string;
26-
correctionAction?: () => void;
25+
correctionActions: {
26+
api?: {
27+
path: string;
28+
method: 'POST' | 'PUT';
29+
body?: {
30+
[key: string]: any;
31+
};
32+
};
33+
manualSteps?: string[];
34+
};
2735
}
2836
export interface DeprecationContext {
2937
pluginId: string;

src/plugins/timelion/server/deprecations.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ export const getDeprecations = async ({ savedObjectsClient }: DeprecationDepende
2727
documentationUrl:
2828
'https://www.elastic.co/guide/en/kibana/master/dashboard.html#timelion-deprecation',
2929
level: 'warning',
30+
correctiveActions: {
31+
manualSteps: [
32+
'Navigate to the Kibana Dashboard and click "Create dashboard".',
33+
'Select Timelion from the "New Visualization" window.',
34+
'Open a new tab, open the Timelion app, select the chart you want to copy, then copy the chart expression.',
35+
'Go to Timelion, paste the chart expression in the Timelion expression field, then click Update.',
36+
'In the toolbar, click Save.',
37+
'On the Save visualization window, enter the visualization Title, then click Save and return.',
38+
],
39+
},
3040
});
3141
}
3242

x-pack/plugins/security/server/deprecations/deprecations.ts

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,71 @@ interface UserInfo {
1818
enabled: boolean;
1919
}
2020

21-
const isUsingDeprecatedRole = (users: Record<string, UserInfo>, role: string) => {
21+
const getRoleDeprecations = ({
22+
users,
23+
deprecatedRole,
24+
manualSteps,
25+
apiInfo,
26+
}: {
27+
users: Record<string, UserInfo>;
28+
deprecatedRole: string;
29+
manualSteps?: string[];
30+
apiInfo?: {
31+
newRole: string;
32+
};
33+
}) => {
2234
const usersWithDeprecatedRoles = Object.keys(users).filter((user) => {
23-
return users[user].roles.includes(role);
35+
return users[user].roles.includes(deprecatedRole);
2436
});
2537

2638
return usersWithDeprecatedRoles.map((user) => {
2739
const userInfo = users[user];
40+
const filteredRoles = userInfo.roles.filter((userInfoRole) => userInfoRole !== deprecatedRole);
41+
2842
return {
29-
message: `User '${userInfo.username}' is using a deprecated role: '${role}'`,
30-
correctiveAction: '',
31-
documentationUrl: '',
43+
message: `User '${userInfo.username}' is using a deprecated role: '${deprecatedRole}'`,
44+
correctiveActions: {
45+
api: apiInfo
46+
? {
47+
path: `/internal/security/users/${userInfo.username}`,
48+
method: 'POST',
49+
body: {
50+
...userInfo,
51+
roles: [...filteredRoles, apiInfo.newRole],
52+
},
53+
}
54+
: undefined,
55+
manualSteps,
56+
},
57+
documentationUrl:
58+
'https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html',
3259
level: 'critical',
3360
};
3461
});
3562
};
3663

37-
const isUsingDeprecatedUser = (users: Record<string, UserInfo>, username: string) => {
64+
const getUserDeprecations = ({
65+
users,
66+
deprecatedUser,
67+
manualSteps,
68+
}: {
69+
users: Record<string, UserInfo>;
70+
deprecatedUser: string;
71+
manualSteps: string[];
72+
}) => {
3873
const deprecatedUsers = Object.keys(users).filter((user) => {
39-
return users[user].username === username;
74+
return users[user].username === deprecatedUser;
4075
});
4176

4277
return deprecatedUsers.map((user) => {
4378
const userInfo = users[user];
4479
return {
4580
message: `User '${userInfo.username}' has been deprecated.`,
46-
correctiveAction: '',
47-
documentationUrl: '',
81+
correctiveActions: {
82+
manualSteps,
83+
},
84+
documentationUrl:
85+
'https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html',
4886
level: 'critical',
4987
};
5088
});
@@ -56,13 +94,36 @@ export const getDeprecations = async ({ esClient }: DeprecationDependencies) =>
5694
Record<string, UserInfo>
5795
>();
5896

59-
const usersWithDeprecatedKibanaUserRole = isUsingDeprecatedRole(usersResponse, 'kibana_user');
60-
const usersWithDeprecatedDashboardRole = isUsingDeprecatedRole(
61-
usersResponse,
62-
'kibana_dashboard_only_user'
63-
);
97+
const usersWithDeprecatedKibanaUserRole = getRoleDeprecations({
98+
users: usersResponse,
99+
deprecatedRole: 'kibana_user',
100+
apiInfo: {
101+
newRole: 'kibana_admin',
102+
},
103+
manualSteps: [
104+
'Using Kibana user management, change all users using the kibana_user role to the kibana_admin role.',
105+
'Using Kibana role-mapping management, change all role-mappings which assing the kibana_user role to the kibana_admin role.',
106+
],
107+
});
108+
109+
const usersWithDeprecatedDashboardRole = getRoleDeprecations({
110+
users: usersResponse,
111+
deprecatedRole: 'kibana_dashboard_only_user',
112+
manualSteps: [
113+
'Using Kibana role management, create a new custom role.',
114+
'Assign read-only access to the Dashboard feature.',
115+
'Assign this role in place of the dashboard_only role.',
116+
],
117+
});
64118

65-
const deprecatedUsers = isUsingDeprecatedUser(usersResponse, 'kibana');
119+
const deprecatedUsers = getUserDeprecations({
120+
users: usersResponse,
121+
deprecatedUser: 'kibana',
122+
manualSteps: [
123+
'Using Kibana user management, set the password for the kibana_system user',
124+
'Update all kibana.yml files to use this username and password for elasticsearch.username and elasticsearch.password',
125+
],
126+
});
66127

67128
const deprecations = [
68129
...usersWithDeprecatedKibanaUserRole,

0 commit comments

Comments
 (0)