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

[Roles] Use Query Roles API for Role Management grid screen #194630

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
559acad
[Roles] Use Query Roles API for Role Management grid screen
SiddharthMantri Oct 1, 2024
af5f44e
remove unused function
SiddharthMantri Oct 1, 2024
5c4b894
clean up roles grid page, remove useAsyncFn and use regular react hoo…
SiddharthMantri Oct 2, 2024
73aad8e
Add option for filtering by space id
SiddharthMantri Oct 9, 2024
5f864f7
replicate TS expect error
SiddharthMantri Oct 9, 2024
c761885
Merge branch 'main' into roles-management-use-query-roles
SiddharthMantri Dec 10, 2024
87f299d
remove TS expect error and add todo
SiddharthMantri Dec 10, 2024
4af8c05
update get all by space to use query roles api
SiddharthMantri Dec 10, 2024
ff02d56
Merge branch 'main' into roles-management-use-query-roles
elasticmachine Dec 18, 2024
f3df93f
update query endpoint to use metadata reserved roles correctly
SiddharthMantri Dec 18, 2024
09251e2
update must to should
SiddharthMantri Dec 18, 2024
012deae
fix tests and query dsl
SiddharthMantri Dec 21, 2024
3dd451e
update tests, add check for max items
SiddharthMantri Dec 23, 2024
7a4bbc0
Merge branch 'main' into roles-management-use-query-roles
elasticmachine Dec 23, 2024
d921b6e
remove console log
SiddharthMantri Dec 23, 2024
607aa75
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Dec 23, 2024
b1a3e8d
use fallback for no roles
SiddharthMantri Dec 23, 2024
95653e7
remove logs
SiddharthMantri Dec 23, 2024
a528369
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Dec 23, 2024
2b42662
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Dec 23, 2024
2edd7f2
update Ui unit test
SiddharthMantri Dec 23, 2024
9e59c12
fix tests for get all roles by space
SiddharthMantri Dec 23, 2024
f5f39b5
add integration tests
SiddharthMantri Dec 23, 2024
6edcbbf
remove exclusive test
SiddharthMantri Dec 23, 2024
d10984a
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Dec 23, 2024
4171bef
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Dec 23, 2024
312f160
fix types
SiddharthMantri Dec 23, 2024
60d77fa
use string instead of query container
SiddharthMantri Dec 23, 2024
2333a1e
fix jest test
SiddharthMantri Dec 24, 2024
b599bc1
remove unneeded test
SiddharthMantri Dec 24, 2024
b3db552
remove imports
SiddharthMantri Dec 24, 2024
45259e5
add test subject
SiddharthMantri Dec 27, 2024
ead1937
remove console log
SiddharthMantri Dec 27, 2024
38f499b
Merge branch 'main' into roles-management-use-query-roles
elasticmachine Dec 27, 2024
bfff37d
add esJavaOpts
SiddharthMantri Dec 30, 2024
eb79bbb
fix comment
SiddharthMantri Dec 30, 2024
a949981
Merge branch 'main' into roles-management-use-query-roles
elasticmachine Dec 30, 2024
1595736
fix usage of esTestCluster config
SiddharthMantri Dec 30, 2024
c95ad24
fix spaces tes{
SiddharthMantri Dec 31, 2024
af84349
update page size to 1000
SiddharthMantri Jan 2, 2025
3710780
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Jan 2, 2025
0b5f795
fix tests, update authz
SiddharthMantri Jan 9, 2025
1c542ce
updat config
SiddharthMantri Jan 10, 2025
bb26a0f
fix two files in merge
SiddharthMantri Jan 10, 2025
399b4d5
remove unused term query
SiddharthMantri Jan 10, 2025
6300b66
update test
SiddharthMantri Jan 14, 2025
bbab456
Merge branch 'main' into roles-management-use-query-roles
elasticmachine Jan 14, 2025
989120f
use versioned router, update tests and api client
SiddharthMantri Jan 14, 2025
eb736df
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Jan 14, 2025
39e51d1
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Jan 14, 2025
31cf053
remove sortable status column
SiddharthMantri Jan 15, 2025
d3c7687
change wildcard to case insensitive
SiddharthMantri Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions oas_docs/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -39185,6 +39185,76 @@
]
}
},
"/api/security/role/_query": {
"post": {
"operationId": "post-security-role-query",
"parameters": [
{
"description": "A required header to protect against CSRF attacks",
"in": "header",
"name": "kbn-xsrf",
"required": true,
"schema": {
"example": "true",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"filters": {
"additionalProperties": false,
"properties": {
"showReservedRoles": {
"type": "boolean"
}
},
"type": "object"
},
"from": {
"type": "number"
},
"query": {
"type": "string"
},
"size": {
"type": "number"
},
"sort": {
"additionalProperties": false,
"properties": {
"direction": {
"enum": [
"asc",
"desc"
],
"type": "string"
},
"field": {
"type": "string"
}
},
"required": [
"field",
"direction"
],
"type": "object"
}
},
"type": "object"
}
}
}
},
"responses": {},
"summary": "Query roles",
"tags": []
}
},
"/api/security/role/{name}": {
"delete": {
"operationId": "delete-security-role-name",
Expand Down
70 changes: 70 additions & 0 deletions oas_docs/bundle.serverless.json
Original file line number Diff line number Diff line change
Expand Up @@ -39185,6 +39185,76 @@
]
}
},
"/api/security/role/_query": {
"post": {
"operationId": "post-security-role-query",
"parameters": [
{
"description": "A required header to protect against CSRF attacks",
"in": "header",
"name": "kbn-xsrf",
"required": true,
"schema": {
"example": "true",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"filters": {
"additionalProperties": false,
"properties": {
"showReservedRoles": {
"type": "boolean"
}
},
"type": "object"
},
"from": {
"type": "number"
},
"query": {
"type": "string"
},
"size": {
"type": "number"
},
"sort": {
"additionalProperties": false,
"properties": {
"direction": {
"enum": [
"asc",
"desc"
],
"type": "string"
},
"field": {
"type": "string"
}
},
"required": [
"field",
"direction"
],
"type": "object"
}
},
"type": "object"
}
}
}
},
"responses": {},
"summary": "Query roles",
"tags": []
}
},
"/api/security/role/{name}": {
"delete": {
"operationId": "delete-security-role-name",
Expand Down
48 changes: 48 additions & 0 deletions oas_docs/output/kibana.serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34431,6 +34431,54 @@ paths:
tags:
- roles
x-beta: true
/api/security/role/_query:
post:
operationId: post-security-role-query
parameters:
- description: A required header to protect against CSRF attacks
in: header
name: kbn-xsrf
required: true
schema:
example: 'true'
type: string
requestBody:
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
additionalProperties: false
type: object
properties:
filters:
additionalProperties: false
type: object
properties:
showReservedRoles:
type: boolean
from:
type: number
query:
type: string
size:
type: number
sort:
additionalProperties: false
type: object
properties:
direction:
enum:
- asc
- desc
type: string
field:
type: string
required:
- field
- direction
responses: {}
summary: Query roles
tags: []
x-beta: true
/api/security/role/{name}:
delete:
operationId: delete-security-role-name
Expand Down
47 changes: 47 additions & 0 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36992,6 +36992,53 @@ paths:
summary: Get all roles
tags:
- roles
/api/security/role/_query:
post:
operationId: post-security-role-query
parameters:
- description: A required header to protect against CSRF attacks
in: header
name: kbn-xsrf
required: true
schema:
example: 'true'
type: string
requestBody:
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
additionalProperties: false
type: object
properties:
filters:
additionalProperties: false
type: object
properties:
showReservedRoles:
type: boolean
from:
type: number
query:
type: string
size:
type: number
sort:
additionalProperties: false
type: object
properties:
direction:
enum:
- asc
- desc
type: string
field:
type: string
required:
- field
- direction
responses: {}
summary: Query roles
tags: []
/api/security/role/{name}:
delete:
operationId: delete-security-role-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type {
AuthenticationProvider,
} from './src/authentication';
export type {
QueryRolesRole,
QueryRolesResult,
Role,
RoleIndexPrivilege,
RoleKibanaPrivilege,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
export type { FeaturesPrivileges } from './features_privileges';
export type { RawKibanaFeaturePrivileges, RawKibanaPrivileges } from './raw_kibana_privileges';
export type {
QueryRolesRole,
QueryRolesResult,
Role,
RoleKibanaPrivilege,
RoleIndexPrivilege,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { estypes } from '@elastic/elasticsearch';

import type { FeaturesPrivileges } from './features_privileges';

export interface RoleIndexPrivilege {
Expand Down Expand Up @@ -53,3 +55,11 @@ export interface Role {
_transform_error?: string[];
_unrecognized_applications?: string[];
}

export type QueryRolesRole = estypes.SecurityQueryRoleQueryRole;

export interface QueryRolesResult {
roles: Role[];
count: number;
total: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export const rolesAPIClientMock = {
deleteRole: jest.fn(),
saveRole: jest.fn(),
bulkUpdateRoles: jest.fn(),
queryRoles: jest.fn(),
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@
* 2.0.
*/

import type { Criteria } from '@elastic/eui';

import type { HttpStart } from '@kbn/core/public';
import type { QueryRolesResult } from '@kbn/security-plugin-types-common';
import type { BulkUpdatePayload, BulkUpdateRoleResponse } from '@kbn/security-plugin-types-public';

import type { Role, RoleIndexPrivilege, RoleRemoteIndexPrivilege } from '../../../common';
import { API_VERSIONS } from '../../../common/constants';
import { copyRole } from '../../../common/model';

export interface QueryRoleParams {
query: string;
from: number;
size: number;
filters?: {
showReservedRoles?: boolean;
};
sort: Criteria<Role>['sort'];
}

const version = API_VERSIONS.roles.public.v1;

export class RolesAPIClient {
Expand All @@ -24,6 +37,12 @@ export class RolesAPIClient {
});
};

public queryRoles = async (params?: QueryRoleParams) => {
return await this.http.post<QueryRolesResult>(`/api/security/role/_query`, {
body: JSON.stringify(params || {}),
});
};

public getRole = async (roleName: string) => {
return await this.http.get<Role>(`/api/security/role/${encodeURIComponent(roleName)}`, {
version,
Expand Down
Loading