-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Kibana Security public types to separate packages (#171886)
## Summary In this PR, I'm relocating all Kibana Security types (along with a few schemas necessary for some of these types, unfortunately) that are part of public contracts to separate packages. This change will enable any plugin to utilize Security APIs via "static" or ["runtime"](#167113) dependencies, regardless of whether Kibana Security already relies on these plugins or not. __NOTE TO REVIEWERS:__ I tried to minimize changes as much as I could via moving only necessary types. I also didn't move deprecated parts of the Setup/Start contracts to these new packages. __Triggered by:__ #168910 --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
bfb450e
commit f7fa846
Showing
290 changed files
with
2,195 additions
and
1,298 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# @kbn/security-plugin-types-common | ||
|
||
Contains type definitions for the Kibana Security plugin (common). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export type { | ||
AuthenticatedUser, | ||
UserRealm, | ||
User, | ||
AuthenticationProvider, | ||
} from './src/authentication'; | ||
export type { | ||
Role, | ||
RoleIndexPrivilege, | ||
RoleKibanaPrivilege, | ||
RoleRemoteIndexPrivilege, | ||
FeaturesPrivileges, | ||
} from './src/authorization'; | ||
export type { SecurityLicense, SecurityLicenseFeatures, LoginLayout } from './src/licensing'; | ||
export type { | ||
UserProfileUserInfo, | ||
UserProfileData, | ||
UserProfileLabels, | ||
UserProfile, | ||
UserProfileWithSecurity, | ||
UserProfileUserInfoWithSecurity, | ||
} from './src/user_profile'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/security-plugin-types-common", | ||
"owner": "@elastic/kibana-security" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@kbn/security-plugin-types-common", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "Elastic License 2.0" | ||
} |
61 changes: 61 additions & 0 deletions
61
x-pack/packages/security/plugin_types_common/src/authentication/authenticated_user.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import type { AuthenticationProvider } from './authentication_provider'; | ||
import type { User } from './user'; | ||
|
||
/** | ||
* An Elasticsearch realm that was used to resolve and authenticate the user. | ||
*/ | ||
export interface UserRealm { | ||
/** | ||
* Arbitrary name of the security realm. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* Type of the security realm (file, native, saml etc.). | ||
*/ | ||
type: string; | ||
} | ||
|
||
/** | ||
* Represents the currently authenticated user. | ||
*/ | ||
export interface AuthenticatedUser extends User { | ||
/** | ||
* The name and type of the Realm that has authenticated the user. | ||
*/ | ||
authentication_realm: UserRealm; | ||
|
||
/** | ||
* The name and type of the Realm where the user information were retrieved from. | ||
*/ | ||
lookup_realm: UserRealm; | ||
|
||
/** | ||
* The authentication provider that used to authenticate user. | ||
*/ | ||
authentication_provider: AuthenticationProvider; | ||
|
||
/** | ||
* The AuthenticationType used by ES to authenticate the user. | ||
* | ||
* @example "realm" | "api_key" | "token" | "anonymous" | "internal" | ||
*/ | ||
authentication_type: string; | ||
|
||
/** | ||
* Indicates whether user is authenticated via Elastic Cloud built-in SAML realm. | ||
*/ | ||
elastic_cloud_user: boolean; | ||
|
||
/** | ||
* User profile ID of this user. | ||
*/ | ||
profile_uid?: string; | ||
} |
20 changes: 20 additions & 0 deletions
20
x-pack/packages/security/plugin_types_common/src/authentication/authentication_provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Type and name tuple to identify provider used to authenticate user. | ||
*/ | ||
export interface AuthenticationProvider { | ||
/** | ||
* Type of the Kibana authentication provider. | ||
*/ | ||
type: string; | ||
/** | ||
* Name of the Kibana authentication provider (arbitrary string). | ||
*/ | ||
name: string; | ||
} |
10 changes: 10 additions & 0 deletions
10
x-pack/packages/security/plugin_types_common/src/authentication/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export type { AuthenticatedUser, UserRealm } from './authenticated_user'; | ||
export type { User } from './user'; | ||
export type { AuthenticationProvider } from './authentication_provider'; |
22 changes: 22 additions & 0 deletions
22
x-pack/packages/security/plugin_types_common/src/authentication/user.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* A set of fields describing Kibana user. | ||
*/ | ||
export interface User { | ||
username: string; | ||
email?: string; | ||
full_name?: string; | ||
roles: readonly string[]; | ||
enabled: boolean; | ||
metadata?: { | ||
_reserved: boolean; | ||
_deprecated?: boolean; | ||
_deprecated_reason?: string; | ||
}; | ||
} |
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
x-pack/packages/security/plugin_types_common/src/authorization/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export type { FeaturesPrivileges } from './features_privileges'; | ||
export type { | ||
Role, | ||
RoleKibanaPrivilege, | ||
RoleIndexPrivilege, | ||
RoleRemoteIndexPrivilege, | ||
} from './role'; |
48 changes: 48 additions & 0 deletions
48
x-pack/packages/security/plugin_types_common/src/authorization/role.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import type { FeaturesPrivileges } from './features_privileges'; | ||
|
||
export interface RoleIndexPrivilege { | ||
names: string[]; | ||
privileges: string[]; | ||
field_security?: { | ||
grant?: string[]; | ||
except?: string[]; | ||
}; | ||
query?: string; | ||
} | ||
|
||
export interface RoleRemoteIndexPrivilege extends RoleIndexPrivilege { | ||
clusters: string[]; | ||
} | ||
|
||
export interface RoleKibanaPrivilege { | ||
spaces: string[]; | ||
base: string[]; | ||
feature: FeaturesPrivileges; | ||
_reserved?: string[]; | ||
} | ||
|
||
export interface Role { | ||
name: string; | ||
elasticsearch: { | ||
cluster: string[]; | ||
indices: RoleIndexPrivilege[]; | ||
remote_indices?: RoleRemoteIndexPrivilege[]; | ||
run_as: string[]; | ||
}; | ||
kibana: RoleKibanaPrivilege[]; | ||
metadata?: { | ||
[anyKey: string]: any; | ||
}; | ||
transient_metadata?: { | ||
[anyKey: string]: any; | ||
}; | ||
_transform_error?: string[]; | ||
_unrecognized_applications?: string[]; | ||
} |
9 changes: 9 additions & 0 deletions
9
x-pack/packages/security/plugin_types_common/src/licensing/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export type { SecurityLicense } from './license'; | ||
export type { LoginLayout, SecurityLicenseFeatures } from './license_features'; |
20 changes: 20 additions & 0 deletions
20
x-pack/packages/security/plugin_types_common/src/licensing/license.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import type { Observable } from 'rxjs'; | ||
|
||
import type { LicenseType } from '@kbn/licensing-plugin/common/types'; | ||
|
||
import type { SecurityLicenseFeatures } from './license_features'; | ||
|
||
export interface SecurityLicense { | ||
isLicenseAvailable(): boolean; | ||
isEnabled(): boolean; | ||
getFeatures(): SecurityLicenseFeatures; | ||
hasAtLeast(licenseType: LicenseType): boolean | undefined; | ||
features$: Observable<SecurityLicenseFeatures>; | ||
} |
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
x-pack/packages/security/plugin_types_common/src/user_profile/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export type { | ||
UserProfileUserInfo, | ||
UserProfileData, | ||
UserProfileLabels, | ||
UserProfileUserInfoWithSecurity, | ||
UserProfile, | ||
UserProfileWithSecurity, | ||
} from './user_profile'; |
Oops, something went wrong.