Skip to content

Commit

Permalink
update privileges key type
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Aug 8, 2019
1 parent 56c8167 commit 7b1d091
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/ml/public/privilege/check_privilege.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import { getPrivileges, getManageMlPrivileges } from './get_privileges';
import { ACCESS_DENIED_PATH } from '../management/management_urls';

let privileges: Privileges = getDefaultPrivileges();

type PrivilageKey = keyof typeof privileges;
// manage_ml requires all monitor and admin cluster privileges: https://github.com/elastic/elasticsearch/blob/664a29c8905d8ce9ba8c18aa1ed5c5de93a0eabc/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java#L53
export function canGetManagementMlJobs(kbnUrl: any) {
return new Promise((resolve, reject) => {
getManageMlPrivileges().then(({ capabilities, isPlatinumOrTrialLicense }) => {
privileges = capabilities;
// Loop through all privilages to ensure they are all set to true.
const isManageML = Object.keys(privileges).every(
privilegeType => privileges[privilegeType] === true
privilegeType => privileges[privilegeType as PrivilageKey] === true
);

if (isManageML === true && isPlatinumOrTrialLicense === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ declare interface Ml {
hasPrivileges(obj: object): Promise<any>;

checkMlPrivileges(): Promise<PrivilegesResponse>;
checkManageMLPrivileges(): Promise<PrivilegesResponse>;
getJobStats(obj: object): Promise<any>;
getDatafeedStats(obj: object): Promise<any>;
esSearch(obj: object): any;
Expand Down

0 comments on commit 7b1d091

Please sign in to comment.