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

[8.14] [Roles] Support for remote_cluster field in ES role definition (#182377) #185919

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion docs/api/role-management/put.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To use the create or update role API, you must have the `manage_security` cluste

`elasticsearch`::
(Optional, object) {es} cluster and index privileges. Valid keys include
`cluster`, `indices`, `remote_indices`, and `run_as`. For more information, see
`cluster`, `indices`, `remote_indices`, `remote_cluster`, and `run_as`. For more information, see
{ref}/defining-roles.html[Defining roles].

`kibana`::
Expand Down Expand Up @@ -210,6 +210,12 @@ $ curl -X PUT api/security/role/my_kibana_role
"names": [ "remote_index1", "remote_index2" ],
"privileges": [ "all" ]
}
],
"remote_cluster": [
{
"clusters": [ "remote_cluster1" ],
"privileges": [ "monitor_enrich" ]
}
]
},
"kibana": [
Expand Down
1 change: 1 addition & 0 deletions x-pack/packages/security/plugin_types_common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type {
RoleIndexPrivilege,
RoleKibanaPrivilege,
RoleRemoteIndexPrivilege,
RoleRemoteClusterPrivilege,
FeaturesPrivileges,
} from './src/authorization';
export type { SecurityLicense, SecurityLicenseFeatures, LoginLayout } from './src/licensing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export type {
RoleKibanaPrivilege,
RoleIndexPrivilege,
RoleRemoteIndexPrivilege,
RoleRemoteClusterPrivilege,
} from './role';
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ export interface RoleKibanaPrivilege {
_reserved?: string[];
}

export interface RoleRemoteClusterPrivilege {
clusters: string[];
privileges: string[];
}

export interface Role {
name: string;
elasticsearch: {
cluster: string[];
remote_cluster?: RoleRemoteClusterPrivilege[];
indices: RoleIndexPrivilege[];
remote_indices?: RoleRemoteIndexPrivilege[];
run_as: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export interface SecurityLicenseFeatures {
*/
readonly allowRoleRemoteIndexPrivileges: boolean;

/**
* Indicates whether we allow users to define remote cluster privileges in roles.
*/
readonly allowRemoteClusterPrivileges: boolean;

/**
* Indicates whether we allow Role-based access control (RBAC).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ export const elasticsearchRoleSchema = schema.object({
*/
cluster: schema.maybe(schema.arrayOf(schema.string())),

/**
* An optional list of remote cluster privileges. These privileges define the remote cluster level actions that
* users with this role are able to execute
*/
remote_cluster: schema.maybe(
schema.arrayOf(
schema.object({
privileges: schema.arrayOf(schema.string(), { minSize: 1 }),
clusters: schema.arrayOf(schema.string(), { minSize: 1 }),
})
)
),

/**
* An optional list of indices permissions entries.
*/
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/security/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type {
RoleIndexPrivilege,
RoleKibanaPrivilege,
RoleRemoteIndexPrivilege,
RoleRemoteClusterPrivilege,
FeaturesPrivileges,
LoginLayout,
SecurityLicenseFeatures,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('license features', function () {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
layout: 'error-es-unavailable',
allowRbac: false,
allowSubFeaturePrivileges: false,
Expand All @@ -50,6 +51,7 @@ describe('license features', function () {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
layout: 'error-xpack-unavailable',
allowRbac: false,
allowSubFeaturePrivileges: false,
Expand Down Expand Up @@ -78,6 +80,7 @@ describe('license features', function () {
"allowAuditLogging": false,
"allowLogin": false,
"allowRbac": false,
"allowRemoteClusterPrivileges": false,
"allowRoleDocumentLevelSecurity": false,
"allowRoleFieldLevelSecurity": false,
"allowRoleRemoteIndexPrivileges": false,
Expand All @@ -101,6 +104,7 @@ describe('license features', function () {
"allowAuditLogging": true,
"allowLogin": true,
"allowRbac": true,
"allowRemoteClusterPrivileges": true,
"allowRoleDocumentLevelSecurity": true,
"allowRoleFieldLevelSecurity": true,
"allowRoleRemoteIndexPrivileges": true,
Expand Down Expand Up @@ -137,6 +141,7 @@ describe('license features', function () {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
allowRbac: true,
allowSubFeaturePrivileges: false,
allowAuditLogging: false,
Expand Down Expand Up @@ -164,6 +169,7 @@ describe('license features', function () {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
allowRbac: false,
allowSubFeaturePrivileges: false,
allowAuditLogging: false,
Expand All @@ -190,6 +196,7 @@ describe('license features', function () {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
allowRbac: true,
allowSubFeaturePrivileges: false,
allowAuditLogging: false,
Expand All @@ -216,6 +223,7 @@ describe('license features', function () {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
allowRbac: true,
allowSubFeaturePrivileges: true,
allowAuditLogging: true,
Expand All @@ -242,6 +250,7 @@ describe('license features', function () {
allowRoleDocumentLevelSecurity: true,
allowRoleFieldLevelSecurity: true,
allowRoleRemoteIndexPrivileges: true,
allowRemoteClusterPrivileges: true,
allowRbac: true,
allowSubFeaturePrivileges: true,
allowAuditLogging: true,
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/security/common/licensing/license_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class SecurityLicenseService {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
allowRbac: false,
allowSubFeaturePrivileges: false,
allowUserProfileCollaboration: false,
Expand All @@ -98,6 +99,7 @@ export class SecurityLicenseService {
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRemoteClusterPrivileges: false,
allowRbac: false,
allowSubFeaturePrivileges: false,
allowUserProfileCollaboration: false,
Expand All @@ -119,6 +121,7 @@ export class SecurityLicenseService {
allowRoleDocumentLevelSecurity: isLicensePlatinumOrBetter,
allowRoleFieldLevelSecurity: isLicensePlatinumOrBetter,
allowRoleRemoteIndexPrivileges: isLicensePlatinumOrBetter,
allowRemoteClusterPrivileges: isLicensePlatinumOrBetter,
allowRbac: true,
allowUserProfileCollaboration: isLicenseStandardOrBetter,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
export interface BuiltinESPrivileges {
cluster: string[];
index: string[];
remote_cluster: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface CheckRoleMappingFeaturesResponse {
canUseStoredScripts: boolean;
hasCompatibleRealms: boolean;
canUseRemoteIndices: boolean;
canUseRemoteClusters: boolean;
}

type DeleteRoleMappingsResponse = Array<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function useRole(
? rolesAPIClient.getRole(roleName)
: Promise.resolve({
name: '',
elasticsearch: { cluster: [], indices: [], run_as: [] },
elasticsearch: { cluster: [], indices: [], run_as: [], remote_cluster: [] },
kibana: [],
_unrecognized_applications: [],
} as Role);
Expand Down Expand Up @@ -533,6 +533,9 @@ export const EditRolePage: FunctionComponent<Props> = ({
canUseRemoteIndices={
buildFlavor === 'traditional' && featureCheckState.value?.canUseRemoteIndices
}
canUseRemoteClusters={
buildFlavor === 'traditional' && featureCheckState.value?.canUseRemoteClusters
}
isDarkMode={isDarkMode}
buildFlavor={buildFlavor}
/>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading