Skip to content

Commit

Permalink
Cleanup authorization for updateApiKey
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Jan 7, 2021
1 parent 4b3c3ed commit aedd620
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
5 changes: 1 addition & 4 deletions x-pack/plugins/alerts/server/alerts_client/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,10 +818,7 @@ export class AlertsClient {
attributes.consumer,
WriteOperations.UpdateApiKey
);
if (
attributes.actions.length &&
!this.authorization.shouldUseLegacyAuthorization(attributes)
) {
if (attributes.actions.length) {
await this.actionsAuthorization.ensureAuthorized('execute');
}
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const createAlertsAuthorizationMock = () => {
ensureAuthorized: jest.fn(),
filterByAlertTypeAuthorization: jest.fn(),
getFindAuthorizationFilter: jest.fn(),
shouldUseLegacyAuthorization: jest.fn(),
};
return mocked;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import Boom from '@hapi/boom';
import { map, mapValues, fromPairs, has } from 'lodash';
import { KibanaRequest } from 'src/core/server';
import { ALERTS_FEATURE_ID } from '../../common';
import { AlertTypeRegistry, RawAlert } from '../types';
import { AlertTypeRegistry } from '../types';
import { SecurityPluginSetup } from '../../../security/server';
import { RegistryAlertType } from '../alert_type_registry';
import { PluginStartContract as FeaturesPluginStart } from '../../../features/server';
import { AlertsAuthorizationAuditLogger, ScopeType } from './audit_logger';
import { Space } from '../../../spaces/server';
import { LEGACY_LAST_MODIFIED_VERSION } from '../saved_objects/migrations';
import { asFiltersByAlertTypeAndConsumer } from './alerts_authorization_kuery';
import { KueryNode } from '../../../../../src/plugins/data/server';

Expand Down Expand Up @@ -112,10 +111,6 @@ export class AlertsAuthorization {
);
}

public shouldUseLegacyAuthorization(alert: RawAlert): boolean {
return alert.meta?.versionApiKeyLastmodified === LEGACY_LAST_MODIFIED_VERSION;
}

private shouldCheckAuthorization(): boolean {
return this.authorization?.mode?.useRbacForRequest(this.request) ?? false;
}
Expand Down

0 comments on commit aedd620

Please sign in to comment.