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

[Cases] RBAC #95058

Merged
merged 111 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
7f1a7dd
Adding feature flag for auth
jonathan-buttner Mar 9, 2021
164582d
Hiding SOs and adding consumer field
jonathan-buttner Mar 9, 2021
7eaf41e
First pass at adding security changes
jonathan-buttner Mar 9, 2021
f8e62c6
Consumer as the app's plugin ID
cnasikas Mar 10, 2021
09589c3
Create addConsumerToSO migration helper
cnasikas Mar 10, 2021
eb75eb0
Fix mapping's SO consumer
cnasikas Mar 10, 2021
a930f03
Add test for CasesActions
cnasikas Mar 10, 2021
d6f3b09
Declare hidden types on SO client
cnasikas Mar 10, 2021
b82e686
Restructure integration tests
cnasikas Mar 10, 2021
4d05175
Init spaces_only integration tests
cnasikas Mar 10, 2021
75d72ae
Implementing the cases security string
jonathan-buttner Mar 10, 2021
e65838b
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Mar 10, 2021
1fd66af
Adding security plugin tests for cases
jonathan-buttner Mar 10, 2021
4560d42
Rough concept for authorization class
jonathan-buttner Mar 10, 2021
ef9b3b2
Adding comments
jonathan-buttner Mar 10, 2021
b22a032
Fix merge
cnasikas Mar 11, 2021
ddc2280
Get requiredPrivileges for classes
cnasikas Mar 11, 2021
9d008d8
Check privillages
cnasikas Mar 11, 2021
7bb23dd
Ensure that all classes are available
cnasikas Mar 11, 2021
65d4c6b
Success if hasAllRequested is true
cnasikas Mar 11, 2021
59e4045
Failure if hasAllRequested is false
cnasikas Mar 11, 2021
4092733
Adding schema updates for feature plugin
jonathan-buttner Mar 11, 2021
311e3f4
Seperate basic from trial
cnasikas Mar 16, 2021
f2a50d3
Enable SIR on integration tests
cnasikas Mar 16, 2021
00d89ca
Starting the plumbing for authorization in plugin
jonathan-buttner Mar 16, 2021
40cfcce
Merge branch 'master' into cases-rbac-poc
cnasikas Mar 17, 2021
644a7ac
Unit tests working
jonathan-buttner Mar 17, 2021
9bb1b86
Merge branch 'cases-rbac-poc-plugin-changes' into cases-rbac-poc
jonathan-buttner Mar 17, 2021
12d6e2e
Move find route logic to case client
cnasikas Mar 17, 2021
84d9167
Create integration test helper functions
cnasikas Mar 17, 2021
4bed458
Adding auth to create call
jonathan-buttner Mar 17, 2021
ecb3135
Create getClassFilter helper
cnasikas Mar 18, 2021
fe1d8c8
Add class attribute to find request
cnasikas Mar 18, 2021
22e7752
Create getFindAuthorizationFilter
cnasikas Mar 18, 2021
96f81a4
Ensure savedObject is authorized in find method
cnasikas Mar 18, 2021
e3ae097
Merge branch 'master' into cases-rbac-poc
cnasikas Mar 22, 2021
06d7c64
Include fields for authorization
cnasikas Mar 22, 2021
2ca4134
Combine authorization filter with cases & subcases filter
cnasikas Mar 22, 2021
17110b1
Fix isAuthorized flag
cnasikas Mar 22, 2021
bc06264
Fix merge issue
cnasikas Mar 22, 2021
a04e0d7
Create/delete spaces & users before and after tests
cnasikas Mar 22, 2021
7fe4e40
Add more user and roles
cnasikas Mar 22, 2021
2847861
[Cases] Convert filters from strings to KueryNode (#95288)
cnasikas Mar 24, 2021
a2e1da8
[Cases] RBAC: Rename class to scope (#95535)
cnasikas Mar 26, 2021
9263d7d
Merge branch 'master' into cases-rbac-poc
cnasikas Mar 26, 2021
afff0cc
Merge branch 'master' into cases-rbac-poc
cnasikas Apr 1, 2021
7cf9172
[Cases][RBAC] Rename scope to owner (#96035)
cnasikas Apr 1, 2021
0a95e55
[Cases] RBAC: Create & Find integration tests (#95511)
cnasikas Apr 2, 2021
1a895e5
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Apr 5, 2021
9ffc3db
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Apr 6, 2021
4f3c37e
[Cases] Cases client enchantment (#95923)
cnasikas Apr 6, 2021
36781db
[Cases] Authorization and Client Audit Logger (#95477)
jonathan-buttner Apr 6, 2021
73a4bfc
[Cases] Migrate sub cases routes to a client (#96461)
jonathan-buttner Apr 8, 2021
ae918cc
Merge branch 'master' into cases-rbac-poc
cnasikas Apr 12, 2021
e59602c
Merge branch 'cases-rbac-poc' of github.com:elastic/kibana into cases…
cnasikas Apr 12, 2021
34f2d86
[Cases] RBAC: Migrate routes' unit tests to integration tests (#96374)
cnasikas Apr 14, 2021
613e859
[Cases] Move remaining HTTP functionality to client (#96507)
jonathan-buttner Apr 14, 2021
676173e
[Cases] Refactoring authorization (#97483)
jonathan-buttner Apr 20, 2021
6cdfa84
[Cases] Add authorization to configuration & cases routes (#97228)
cnasikas Apr 26, 2021
7b21b7a
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Apr 27, 2021
103388e
[Cases] Attachments RBAC (#97756)
jonathan-buttner Apr 30, 2021
18e75d9
[Cases] Add RBAC to remaining Cases APIs (#98762)
jonathan-buttner May 4, 2021
d99d9f8
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 4, 2021
b121662
Fixing some type errors
jonathan-buttner May 4, 2021
42162e3
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 6, 2021
298ba34
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 6, 2021
c0fb868
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 7, 2021
21d173d
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 10, 2021
b910889
[Cases] Add space only tests (#99409)
jonathan-buttner May 10, 2021
78dfac4
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 10, 2021
bf583a8
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 11, 2021
3fd893f
[Cases] Add security only tests (#99679)
jonathan-buttner May 11, 2021
86568ed
Adding sub feature
jonathan-buttner May 12, 2021
952e2a3
[Cases] Cleaning up the services and TODOs (#99723)
jonathan-buttner May 14, 2021
e26de43
Integration tests for cases privs and fixes (#100038)
jonathan-buttner May 14, 2021
2d8601b
[Cases] RBAC on UI (#99478)
cnasikas May 14, 2021
570cddb
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 14, 2021
3c7670b
Fixing case ids by alert id route call
jonathan-buttner May 14, 2021
dafb4fe
[Cases] Fixing UI feature permissions and adding UI tests (#100074)
jonathan-buttner May 14, 2021
b7c5ebd
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 14, 2021
698e8e2
Fixing type error
jonathan-buttner May 14, 2021
22abf1f
Merge branch 'master' into cases-rbac-poc
kibanamachine May 17, 2021
71225eb
Adding some comments
jonathan-buttner May 17, 2021
f7a816b
Validate cases features
cnasikas May 18, 2021
2ed0a99
Merge branch 'master' into cases-rbac-poc
cnasikas May 18, 2021
fd39b25
Fix new schema
cnasikas May 18, 2021
a193138
Merge branch 'master' into cases-rbac-poc
kibanamachine May 18, 2021
1f9059c
Merge branch 'master' into cases-rbac-poc
kibanamachine May 20, 2021
2085a3b
Merge branch 'master' into cases-rbac-poc
kibanamachine May 24, 2021
66c1d43
Adding owner param for the status stats
jonathan-buttner May 24, 2021
018dcb5
Merge branch 'master' into cases-rbac-poc
kibanamachine May 24, 2021
34b16c5
Fix get case status tests
cnasikas May 25, 2021
9ba1243
Adjusting permissions text and fixing status
jonathan-buttner May 25, 2021
315a6e4
Address PR feedback
jonathan-buttner May 26, 2021
02ad6a4
Adding top level feature back
jonathan-buttner May 26, 2021
e8c3532
Merge branch 'master' into cases-rbac-poc
kibanamachine May 26, 2021
8881899
Fixing feature privileges
jonathan-buttner May 27, 2021
dd62656
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner May 27, 2021
acf550b
Renaming
jonathan-buttner May 27, 2021
148623e
Removing uneeded else
jonathan-buttner May 27, 2021
7acf83a
Fixing tests and adding cases merge tests
jonathan-buttner May 27, 2021
b03fa4c
Merge branch 'master' into cases-rbac-poc
kibanamachine May 28, 2021
445c846
[Cases][Security Solution] Basic license security solution API tests …
jonathan-buttner Jun 1, 2021
c08ac43
Merge branch 'master' of github.com:elastic/kibana into cases-rbac-poc
jonathan-buttner Jun 1, 2021
373cd68
Merge branch 'master' into cases-rbac-poc
kibanamachine Jun 2, 2021
d59dbad
renaming to unsecuredSavedObjectsClient (#101215)
jonathan-buttner Jun 3, 2021
7ef02f4
Merge branch 'master' into cases-rbac-poc
kibanamachine Jun 3, 2021
739fd6f
[Cases] RBAC Refactoring audit logging (#100952)
jonathan-buttner Jun 3, 2021
e66eb40
[Cases] Cleaning up RBAC integration tests (#101324)
jonathan-buttner Jun 4, 2021
5bd080b
Merge branch 'master' into cases-rbac-poc
kibanamachine Jun 4, 2021
56e0f0d
Merge branch 'master' into cases-rbac-poc
kibanamachine Jun 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion x-pack/plugins/cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ Case management in Kibana
## Table of Contents

- [Cases API](#cases-api)
- [Cases Client API](#cases-client-api)
- [Cases UI](#cases-ui)
- [Case Action Type](#case-action-type) _feature in development, disabled by default_


## Cases API
[**Explore the API docs »**](https://www.elastic.co/guide/en/security/current/cases-api-overview.html)

## Cases Client API
[**Cases Client API docs**][cases-client-api-docs]

## Cases UI

#### Embed Cases UI components in any Kibana plugin
Expand Down Expand Up @@ -263,4 +267,4 @@ For IBM Resilient connectors:
[all-cases-modal-img]: images/all_cases_selector_modal.png
[recent-cases-img]: images/recent_cases.png
[case-view-img]: images/case_view.png

[cases-client-api-docs]: docs/cases_client/cases_client_api.md
121 changes: 119 additions & 2 deletions x-pack/plugins/cases/common/api/cases/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,38 @@ const SettingsRt = rt.type({
});

const CaseBasicRt = rt.type({
/**
* The description of the case
*/
description: rt.string,
/**
* The current status of the case (open, closed, in-progress)
*/
status: CaseStatusRt,
/**
* The identifying strings for filter a case
*/
tags: rt.array(rt.string),
/**
* The title of a case
*/
title: rt.string,
/**
* The type of a case (individual or collection)
*/
[caseTypeField]: CaseTypeRt,
/**
* The external system that the case can be synced with
*/
connector: CaseConnectorRt,
/**
* The alert sync settings
*/
settings: SettingsRt,
/**
* The plugin owner of the case
*/
owner: rt.string,
});

const CaseExternalServiceBasicRt = rt.type({
Expand Down Expand Up @@ -73,11 +98,31 @@ export const CaseAttributesRt = rt.intersection([
]);

const CasePostRequestNoTypeRt = rt.type({
/**
* Description of the case
*/
description: rt.string,
/**
* Identifiers for the case.
*/
tags: rt.array(rt.string),
/**
* Title of the case
*/
title: rt.string,
/**
* The external configuration for the case
*/
connector: CaseConnectorRt,
/**
* Sync settings for alerts
*/
settings: SettingsRt,
/**
* The owner here must match the string used when a plugin registers a feature with access to the cases plugin. The user
* creating this case must also be granted access to that plugin's feature.
*/
owner: rt.string,
});

/**
Expand All @@ -95,23 +140,78 @@ export const CasesClientPostRequestRt = rt.type({
* has all the necessary fields. CasesClientPostRequestRt is used for validation.
*/
export const CasePostRequestRt = rt.intersection([
rt.partial({ type: CaseTypeRt }),
/**
* The case type: an individual case (one without children) or a collection case (one with children)
*/
rt.partial({ [caseTypeField]: CaseTypeRt }),
CasePostRequestNoTypeRt,
]);

export const CasesFindRequestRt = rt.partial({
/**
* Type of a case (individual, or collection)
*/
type: CaseTypeRt,
/**
* Tags to filter by
*/
tags: rt.union([rt.array(rt.string), rt.string]),
/**
* The status of the case (open, closed, in-progress)
*/
status: CaseStatusRt,
/**
* The reporters to filter by
*/
reporters: rt.union([rt.array(rt.string), rt.string]),
/**
* Operator to use for the `search` field
*/
defaultSearchOperator: rt.union([rt.literal('AND'), rt.literal('OR')]),
/**
* The fields in the entity to return in the response
*/
fields: rt.array(rt.string),
/**
* The page of objects to return
*/
page: NumberFromString,
/**
* The number of objects to include in each page
*/
perPage: NumberFromString,
/**
* An Elasticsearch simple_query_string
*/
search: rt.string,
searchFields: rt.array(rt.string),
/**
* The fields to perform the simple_query_string parsed query against
*/
searchFields: rt.union([rt.array(rt.string), rt.string]),
/**
* The field to use for sorting the found objects.
*
* This only supports, `create_at`, `closed_at`, and `status`
*/
sortField: rt.string,
/**
* The order to sort by
*/
sortOrder: rt.union([rt.literal('desc'), rt.literal('asc')]),
/**
* The owner(s) to filter by. The user making the request must have privileges to retrieve cases of that
* ownership or they will be ignored. If no owner is included, then all ownership types will be included in the response
* that the user has access to.
*/
owner: rt.union([rt.array(rt.string), rt.string]),
});

export const CasesByAlertIDRequestRt = rt.partial({
/**
* The type of cases to retrieve given an alert ID. If no owner is provided, all cases
* that the user has access to will be returned.
*/
owner: rt.union([rt.array(rt.string), rt.string]),
});

export const CaseResponseRt = rt.intersection([
Expand Down Expand Up @@ -141,6 +241,9 @@ export const CasesFindResponseRt = rt.intersection([

export const CasePatchRequestRt = rt.intersection([
rt.partial(CaseBasicRt.props),
/**
* The saved object ID and version
*/
rt.type({ id: rt.string, version: rt.string }),
]);

Expand Down Expand Up @@ -172,6 +275,16 @@ export const ExternalServiceResponseRt = rt.intersection([
}),
]);

export const AllTagsFindRequestRt = rt.partial({
/**
* The owner of the cases to retrieve the tags from. If no owner is provided the tags from all cases
* that the user has access to will be returned.
*/
owner: rt.union([rt.array(rt.string), rt.string]),
});

export const AllReportersFindRequestRt = AllTagsFindRequestRt;

export type CaseAttributes = rt.TypeOf<typeof CaseAttributesRt>;
/**
* This field differs from the CasePostRequest in that the post request's type field can be optional. This type requires
Expand All @@ -183,6 +296,7 @@ export type CasePostRequest = rt.TypeOf<typeof CasePostRequestRt>;
export type CaseResponse = rt.TypeOf<typeof CaseResponseRt>;
export type CasesResponse = rt.TypeOf<typeof CasesResponseRt>;
export type CasesFindRequest = rt.TypeOf<typeof CasesFindRequestRt>;
export type CasesByAlertIDRequest = rt.TypeOf<typeof CasesByAlertIDRequestRt>;
export type CasesFindResponse = rt.TypeOf<typeof CasesFindResponseRt>;
export type CasePatchRequest = rt.TypeOf<typeof CasePatchRequestRt>;
export type CasesPatchRequest = rt.TypeOf<typeof CasesPatchRequestRt>;
Expand All @@ -194,3 +308,6 @@ export type ESCaseAttributes = Omit<CaseAttributes, 'connector'> & { connector:
export type ESCasePatchRequest = Omit<CasePatchRequest, 'connector'> & {
connector?: ESCaseConnector;
};

export type AllTagsFindRequest = rt.TypeOf<typeof AllTagsFindRequestRt>;
export type AllReportersFindRequest = AllTagsFindRequest;
14 changes: 14 additions & 0 deletions x-pack/plugins/cases/common/api/cases/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import * as rt from 'io-ts';
import { SavedObjectFindOptionsRt } from '../saved_object';

import { UserRT } from '../user';

Expand Down Expand Up @@ -42,6 +43,7 @@ export const CommentAttributesBasicRt = rt.type({
]),
created_at: rt.string,
created_by: UserRT,
owner: rt.string,
pushed_at: rt.union([rt.string, rt.null]),
pushed_by: rt.union([UserRT, rt.null]),
updated_at: rt.union([rt.string, rt.null]),
Expand All @@ -57,6 +59,7 @@ export enum CommentType {
export const ContextTypeUserRt = rt.type({
comment: rt.string,
type: rt.literal(CommentType.user),
owner: rt.string,
});

/**
Expand All @@ -72,6 +75,7 @@ export const AlertCommentRequestRt = rt.type({
id: rt.union([rt.string, rt.null]),
name: rt.union([rt.string, rt.null]),
}),
owner: rt.string,
});

const AttributesTypeUserRt = rt.intersection([ContextTypeUserRt, CommentAttributesBasicRt]);
Expand Down Expand Up @@ -127,7 +131,17 @@ export const CommentsResponseRt = rt.type({

export const AllCommentsResponseRt = rt.array(CommentResponseRt);

export const FindQueryParamsRt = rt.partial({
...SavedObjectFindOptionsRt.props,
/**
* If specified the attachments found will be associated to a sub case instead of a case object
*/
subCaseId: rt.string,
});

export type FindQueryParams = rt.TypeOf<typeof FindQueryParamsRt>;
export type AttributesTypeAlerts = rt.TypeOf<typeof AttributesTypeAlertsRt>;
export type AttributesTypeUser = rt.TypeOf<typeof AttributesTypeUserRt>;
export type CommentAttributes = rt.TypeOf<typeof CommentAttributesRt>;
export type CommentRequest = rt.TypeOf<typeof CommentRequestRt>;
export type CommentResponse = rt.TypeOf<typeof CommentResponseRt>;
Expand Down
37 changes: 36 additions & 1 deletion x-pack/plugins/cases/common/api/cases/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,34 @@ import * as rt from 'io-ts';

import { UserRT } from '../user';
import { CaseConnectorRt, ConnectorMappingsRt, ESCaseConnector } from '../connectors';
import { OmitProp } from '../runtime_types';
import { OWNER_FIELD } from './constants';

// TODO: we will need to add this type rt.literal('close-by-third-party')
const ClosureTypeRT = rt.union([rt.literal('close-by-user'), rt.literal('close-by-pushing')]);

const CasesConfigureBasicRt = rt.type({
/**
* The external connector
*/
connector: CaseConnectorRt,
/**
* Whether to close the case after it has been synced with the external system
*/
closure_type: ClosureTypeRT,
/**
* The plugin owner that manages this configuration
*/
owner: rt.string,
cnasikas marked this conversation as resolved.
Show resolved Hide resolved
});

const CasesConfigureBasicWithoutOwnerRt = rt.type(
OmitProp(CasesConfigureBasicRt.props, OWNER_FIELD)
);

export const CasesConfigureRequestRt = CasesConfigureBasicRt;
export const CasesConfigurePatchRt = rt.intersection([
rt.partial(CasesConfigureBasicRt.props),
rt.partial(CasesConfigureBasicWithoutOwnerRt.props),
rt.type({ version: rt.string }),
]);

Expand All @@ -38,18 +54,37 @@ export const CaseConfigureResponseRt = rt.intersection([
CaseConfigureAttributesRt,
ConnectorMappingsRt,
rt.type({
id: rt.string,
version: rt.string,
error: rt.union([rt.string, rt.null]),
owner: rt.string,
}),
]);

export const GetConfigureFindRequestRt = rt.partial({
/**
* The configuration plugin owner to filter the search by. If this is left empty the results will include all configurations
* that the user has permissions to access
*/
owner: rt.union([rt.array(rt.string), rt.string]),
});

export const CaseConfigureRequestParamsRt = rt.type({
configuration_id: rt.string,
});

export const CaseConfigurationsResponseRt = rt.array(CaseConfigureResponseRt);

export type ClosureType = rt.TypeOf<typeof ClosureTypeRT>;
export type CasesConfigure = rt.TypeOf<typeof CasesConfigureBasicRt>;
export type CasesConfigureRequest = rt.TypeOf<typeof CasesConfigureRequestRt>;
export type CasesConfigurePatch = rt.TypeOf<typeof CasesConfigurePatchRt>;
export type CasesConfigureAttributes = rt.TypeOf<typeof CaseConfigureAttributesRt>;
export type CasesConfigureResponse = rt.TypeOf<typeof CaseConfigureResponseRt>;
export type CasesConfigurationsResponse = rt.TypeOf<typeof CaseConfigurationsResponseRt>;

export type ESCasesConfigureAttributes = Omit<CasesConfigureAttributes, 'connector'> & {
connector: ESCaseConnector;
};

export type GetConfigureFindRequest = rt.TypeOf<typeof GetConfigureFindRequestRt>;
36 changes: 36 additions & 0 deletions x-pack/plugins/cases/common/api/cases/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

/**
* This field is used for authorization of the entities within the cases plugin. Each entity within Cases will have the owner field
* set to a string that represents the plugin that "owns" (i.e. the plugin that originally issued the POST request to
* create the entity) the entity.
*
* The Authorization class constructs a string composed of the operation being performed (createCase, getComment, etc),
* and the owner of the entity being acted upon or created. This string is then given to the Security plugin which
* checks to see if the user making the request has that particular string stored within it's privileges. If it does,
* then the operation succeeds, otherwise the operation fails.
*
* APIs that create/update an entity require that the owner field be passed in the body of the request.
* APIs that search for entities typically require that the owner be passed as a query parameter.
* APIs that specify an ID of an entity directly generally don't need to specify the owner field.
*
* For APIs that create/update an entity, the RBAC implementation checks to see if the user making the request has the
* correct privileges for performing that action (a create/update) for the specified owner.
* This check is done through the Security plugin's API.
*
* For APIs that search for entities, the RBAC implementation creates a filter for the saved objects query that limits
* the search to only owners that the user has access to. We also check that the objects returned by the saved objects
* API have the limited owner scope. If we find one that the user does not have permissions for, we throw a 403 error.
* The owner field that is passed in as a query parameter can be used to further limit the results. If a user attempts
* to pass an owner that they do not have access to, the owner is ignored.
*
* For APIs that retrieve/delete entities directly using their ID, the RBAC implementation requests the object first,
* and then checks to see if the user making the request has access to that operation and owner. If the user does, the
* operation continues, otherwise we throw a 403.
*/
export const OWNER_FIELD = 'owner';
1 change: 1 addition & 0 deletions x-pack/plugins/cases/common/api/cases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './comment';
export * from './status';
export * from './user_actions';
export * from './sub_case';
export * from './constants';
9 changes: 9 additions & 0 deletions x-pack/plugins/cases/common/api/cases/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ export const CasesStatusResponseRt = rt.type({
count_closed_cases: rt.number,
});

export const CasesStatusRequestRt = rt.partial({
/**
* The owner of the cases to retrieve the status stats from. If no owner is provided the stats for all cases
* that the user has access to will be returned.
*/
owner: rt.union([rt.array(rt.string), rt.string]),
});

export type CasesStatusResponse = rt.TypeOf<typeof CasesStatusResponseRt>;
export type CasesStatusRequest = rt.TypeOf<typeof CasesStatusRequestRt>;
Loading