Commit graph

212 commits

Author SHA1 Message Date
Aleh Zasypkin 9d3d3cdc67
Migrate Management views to Kibana Platform plugin (#53880) 2020-01-21 13:40:39 +01:00
Pierre Gayvallet 2d10350d77
Implements getStartServices on server-side (#55156)
* implements server-side getStartServices

* add unit test

* add integration test

* update generated doc

* improve test
2020-01-20 11:19:40 +01:00
Greg Thompson bd9d67ccc0
Upgrade EUI to v18.2.0 (#54786)
* 18.2.0

* ts update

* Updated `euiColorVis0`

* Update `euiColorVis1`

* Updating `euiColorVis2`

* Updated `euiColorVis3`

* Updated the rest

* Updated hard-coded viz palette hexes to latest

* src snapshot updates

* x-pack test updates

* mock jest fn

* Updated two vegalite visualization screenshots

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
2020-01-14 20:19:35 -06:00
Chandler Prall 6bed80bbd8
Upgraded EUI to 18.0.0 (#54042)
* Upgraded EUI to 18.0.0

* Fix breaks from `palette._.colors` changes

* snapshots

* Updated hard coded hex color codes in tests, fixed TS errors

* Updated a functional test's selector; added (BSD-3-Clause AND Apache-2.0) to license checker whitelist

* Functional test selector update

* Updated vega browser-ci tests for palette changes

* rebased on master

* One more location for EUI package number update and yarn lock

* Fixed lurking [but introduced] TypeScript logic bug

* Swap a prop definition for the same value but tied closer to its source

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-01-14 11:23:43 -07:00
Larry Gregory e6e1373db2
Security - Role Mappings UI (#53620)
* Initial role mappings UI

* apply design edits

* address PR feedback

* fix type cast for number field

* Update x-pack/legacy/plugins/security/public/views/management/role_mappings/edit_role_mapping/components/mapping_info_panel/mapping_info_panel.tsx

Co-Authored-By: Joe Portner <5295965+jportner@users.noreply.github.com>

* Cleanup FTR configuration, and handle role mapping 404 errors properly

* align naming of role mappings feature check

* Apply suggestions from code review

Co-Authored-By: Brandon Kobel <brandon.kobel@gmail.com>

* add missing test assertions

* inlining feature check logic

* switch to using snapshot

* use href instead of onClick

* adding delete unit test

* consolidate href building

* unify page load error handling

* simplify initial loading state

* documenting unconditional catch blocks

* use nodes.info instead of transport.request

* Apply suggestions from code review

Co-Authored-By: Brandon Kobel <brandon.kobel@gmail.com>

* move model out of LP into NP

* convert except_field_rule to except_any_rule

* docs, take 1

* update gif

Co-authored-by: Joe Portner <5295965+jportner@users.noreply.github.com>
Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-01-11 13:26:31 -05:00
Steph Milovic 303e4842ea
[SIEM] [Case] Case workflow api schema (#51535) 2020-01-08 14:28:29 -07:00
Mikhail Shustov 56041f03ad
Don't expose Elasticsearch client as Observable (#53824)
* expose ES clients without observables

* expose observable-less api to plugins

* update core api and mocks

* update plugins

* NP SO & legacy use updated API

* update SO tests

* update TSDocs

* update types

* update docs

* document createCluster analog in np

* typo
2020-01-08 12:01:47 +03:00
Aleh Zasypkin aa38fb68a7
Migrate config deprecations and ShieldUser functionality to the New Platform (#53768) 2020-01-06 11:43:15 +01:00
Mike Côté 8cc778a64a
Invalidate alert API Key when generating a new one (#53732)
* Initial work to auto cleanup old API keys

* Fix ESLint error

* Rename confusing variables

* Add test to ensure thrown errors are swallowed

* Add more tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-01-03 13:40:20 -05:00
Aleh Zasypkin 6cf7ece9df
Rename /api/security/oidc to /api/security/oidc/callback. (#53886) 2020-01-03 10:01:50 +01:00
Alejandro Fernández Haro 3bdbcd0d1a
[NP] Allow custom validations in HTTP Routes apart from @kbn/config-schema (#51919)
* [NP] Allow custom validations in HTTP Routes apart from @kbn/config-schema

* API docs

* Allow validate function in the route handler (run-code validation)

* Prefix RouteXXX + Params and Body Validation Aliases

* Fix test broken by lodash

* Update API docs

* Add default types for simpler manual declaration

* Add run-time validation of the RouteValidateSpec

* Expose RouteValidationError instead of SchemaTypeError

* RouteValidator as a class to match config-schema interface

* Test for not-inline handler (need to check IRouter for #47047)

* Add preValidation of the input for a safer custom validation

* Better types for RouteHandlers

* [NP] Move route validation to RouteValidator wrapper

* Use the class only internally but maintain the same API

* Fix types

* Ensure RouteValidator instance in KibanaRequest.from

* Fix validator.tests (Buffer.from instead of new Buffer)

* Default precheck should allow null values

* Also allow undefined in preChecks

* MR feedback fixes

* Provide RouteValidationResolver to the validation function

* Add functional tests

* Fix new functional tests

* Fix validator additional test

* Fix test with new resolver

* Remove unused import

* Rename ValidationResolver to ValidationResultFactory and change the interface to look more like the KibanaResponseFactory

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2019-12-20 17:53:08 +00:00
Aleh Zasypkin e5822771e3
Use savedObjects provided by the platform instead of legacy shim. (#53679) 2019-12-20 18:42:42 +01:00
Mikhail Shustov ba7589d603
Reduce license plugin api (#53489)
* inOneOf --> hasAtLeast. to follow to licensing hierarchical model

* adopt licensing tests

* add license mock and use it in the tests

* adopt security plugin to hasAtLeast and licensing mocks

* adopt uptime to hasAtLeast

* update readme

* add test for unknown license

* fix import in js test

* fix security plugin merge conflict

* Update x-pack/plugins/security/common/licensing/license_service.ts

Co-Authored-By: Larry Gregory <lgregorydev@gmail.com>

* Update x-pack/plugins/licensing/common/types.ts

Co-Authored-By: Josh Dover <me@joshdover.com>

* simplify tests

* remove unused import
2019-12-19 09:35:09 +01:00
Larry Gregory 3b647b1641
Security nav control => NP (#52386)
* migrating nav control to NP

* move licensing service to common

* only retrieve user when necessary

* don't block rendering on user promise

* testing nav control registration

* moving logic to nav_control_service

* register account management in a hack

* update import location

* updating license_service to manage its own subscription to the raw license

* updating mock

* update editProfileUrl to not require full page reload if already within the kibana app

* alternate security license proposal

* adds popover test.

* switchMap -> map

* additional test case.

* Apply suggestions from code review

Co-Authored-By: Aleh Zasypkin <aleh.zasypkin@gmail.com>

* additional testing

* fix merge from master

* fixing es availability check

* fix merge from master

* switch from deprecated route


Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2019-12-18 07:17:00 -05:00
Mikhail Shustov 74e1d17cf4
Support 'enterprise' license type (#52273)
* add enterprise license type to licensing plugin

* add enterprise license to x-pack plugins

* update uptime license list

* improve naming in security plugin

* update reporting licensing
2019-12-17 15:43:19 +01:00
Eli Perelman 614bde927e
Move CSP options to new platform (#52698)
* Move CSP options to new platform

* Expose SharedGlobalConfig from root

* Derive CSP options from config

* Consolidate CSP configuration with HTTP config

* Fix outstanding config renames

* Remove legacy CSP configuration calls, migrate to platform properties

* Revise docs

* Fix test from type change

* Expose ICspConfig, consolidate and simplify CSP defaults access

* Rebase and update docs

* Remove legacy API from route definition params, review nits

* Clean up config path usages for consistency

* Regenerate docs
2019-12-13 15:57:17 -06:00
Joe Portner 3e6270737a
Change session timeout values to use duration instead of number (#52520) 2019-12-13 13:58:40 -05:00
Josh Dover ec2134d221
Add lint rule to prevent server code being imported into client (#52447) 2019-12-13 12:26:04 -06:00
Aleh Zasypkin 2ec82d3dd9
Migrate the rest of the API endpoints to the New Platform plugin (#50695) 2019-12-11 18:35:49 +01:00
Josh Dover a91e53f18f
Add asResponse option to HttpService methods (#52434) 2019-12-11 10:53:17 -06:00
Aleh Zasypkin 7e27f0d35f
Decouple Authorization subsystem from Legacy API. (#52638) 2019-12-11 08:55:46 +01:00
Pierre Gayvallet c692689f21
fix import (#52555) 2019-12-09 22:18:57 +01:00
Mikhail Shustov dce893bb79
NP licensing plugin improvements (#51818)
* add onPreResponse interceptor

* use onPreResponse interceptor to add license sign

* expose registerPreResponse to plugins

* refresh for license update get the most fresh license

* license plugin injects own header for signature:  'kbn-license-sig'

* add integration tests for license type and license header

* switch config to duration

* don't run interceptor on anon paths. add tests

* add functional tests for licensing plugin

* regen docs

* fix test in security due to updated mocks;

* update snapshots accoring to new mock implementation

* migrate license expired banner to NP

* add readme for the licensing plugin

* remove outdated import. licensing has separate functional tests

* add tag for test to run on CI

* regen docs

* Update x-pack/plugins/licensing/README.md

Co-Authored-By: Josh Dover <me@joshdover.com>

* update tests
2019-12-09 10:40:18 +01:00
Thomas Watson 43b97d8a05
Clean up uses of deprecated API's in node core (#51431)
Ensure no deprecated Node.js core API's are used in Kibana. This is
achieved by throwing an error in either development mode or in CI if one
of the deprecated API's is called, and as such, new PR's should no
longer be able to be merged if they use deprecated API's.

Some of these API's (like the `Buffer` constructor`) is a security risk.
2019-12-04 16:17:19 +01:00
Pierre Gayvallet 99c6396fd5
Migrate Capabilities to new platform (#51438)
* create service skeleton

* move registerCapabilitiesModifier to capabilities service and rename to registerCapabilitiesSwitcher

* starts to move capabilities logic to CapabilitiesService

* move capabilities route to service

* add initial integration test for capabilities route

* capabilitiesMixin now delegates to capability service

* use server-side Capabilities import in server code

* update generated doc

* remove capabilities from injectedMetadatas

* use applications sent from client instead of server-registered navLinks

* disable authRequired for capabilities route

* (temp) exposes two endpoints for capabilities

* Add fetch-mock on capabilities call for karma tests

* adapt xpack Capabilities test - first attempt

* adapt x-pack ui_capabilities test

* add '/status' to the list of anonymous pages

* Add documentation on Capabilities APIs

* move Capabilities to core/types

* update generated docs

* add service tests

* protecting resolveCapabilities against added/removed capabilities

* update generated docs

* adapt mocks due to rebase

* add forgotten exports

* improve capabilities routes registering

* name capabilities registering methods

* resolve conflicts due to merge

* address review issues

* add comment about reason for exposing two routes

* extract createHttpServer test helper

* fix merge conflicts

* improve documentation

* remove `/status` anon registration as now done in NP status plugin

* fix merge conflicts
2019-12-03 09:34:49 +01:00
Alejandro Fernández Haro 066613e2a6
Allow routes to define some payload config values (#50783)
* Allow routes to define some payload config values

* Documentation typo

* Move hapi `payload` config under `body` + additional validations

* Update API docs

* Amend explanation in API docs

* Add stream and buffer types to @kbn/config-schema

* Fixes based on PR feedback:
- Add 'patch' and 'options' to valid RouteMethod
- Add tests for all the new flags
- Allow `stream` and `buffer` schema in the body validations (findings from tests)

* API documentation update

* Fix type definitions

* Fix the NITs in the PR comments + better typing inheritance

* API docs update

* Fix APM-legacy wrapper's types

* Fix KibanaRequest.from type exposure of hapi in API docs

* Move RouterRoute interface back to private + Expose some public docs

* Update @kbn/config-schema docs
2019-11-28 09:23:56 +00:00
Joe Portner 7830946f6a
Fix infinite redirect loop when multiple cookies are sent (#50452)
Cookies are now checked for attributes that match the current
Kibana configuration. Invalid cookies are cleared more reliably.
2019-11-27 09:26:21 -05:00
Joe Portner 38c17d6c7d
Improve session idle timeout, add session lifespan (#49855)
This adds an absolute session timeout (lifespan) to user sessions.
It also improves the existing session timeout toast and the overall
user experience in several ways.
2019-11-26 10:47:40 -05:00
Søren Louv-Jansen e8e517475a
[Security] Add message to login page (#51557)
* [Security] Add loginAssistanceMessage to login page

* Fix tests

* Fix login_page.test.tsx

* Fix defaultValue

* Render login assistance message independently of other messages and use EuiText instead of EuiCallOut

* Use small text

Co-Authored-By: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Flip order of message around
2019-11-26 13:19:11 +01:00
Larry Gregory 21b83a8470
Security - honor configured base path when logging out (#50946)
* honor configured base path

* updating tests

* auth providers should redirect to logged out page using server base path
2019-11-20 12:30:46 -05:00
Mikhail Shustov 643f15c5d9
Licensing plugin (#49345)
* Add x-pack plugin for new platform browser licensing information

* Address next round of reviews

* Remove poller functionality in favor of inline observables

* More observable changes from review comments

* Fix outstanding tests

* More changes from review, adding additional testing

* Add additional tests for license comparisons and sessions

* Update test snapshot due to sessionstorage mock

* Next round of review feedback from restrry

* Fix more review requests from restrry, add additional tests

* Pass correct sign mock to license info changed test

* Improve doc comments, switch to I-interface pattern

* Test error polling sanity, do not expose signature, do not poll on client

* Fix type check issues from rebase

* Fix build error from rebase

* minimize config

* move all types to server with consistency with other code

* implement License

* implement license update & refactor has License changed check

* update tests for licensing extending route handler context

* implement client side side license plugin

* implement server side licensing plugin

* remove old code

* update testing harness

* update types for license status

* remove jest-localstorage-mock

* fix tests

* update license in security

* address comments. first pass

* error is a part of signature. pass error message to License

* move common license types under common folder

* rename feature props for BWC and unify name with ILicense

* test should work in any timezone

* make prettier happy

* remove obsolete comment

* address Pierre comments

* use sha256 for security reasons

* use stable stringify to avoid churn
2019-11-19 13:35:27 +01:00
Pierre Gayvallet e04adbe34b
Remove react references from core Notifications apis (#49573)
* add reactMount util to kibana_react

(kibana-react) properly export reactMount

* add MountPoint types and utility

* adapt toast API to no longer accept react elements

(toast API) properly export new Toast type

* adapt calls by using reactMount

createNotifications: do not wrap if text

* update generated doc

* add custom snapshot serializer for reactMount

* fix unit tests

fix xpack unit tests

* adapt non-ts calls

* do not add __reactMount__ property in production

* remove string check on createNotifications

* fix typo and small fix using obj spread

* improve react mount snapshot serializer

* simplify convertToEui

* rename reactMount to toMountPoint

* adapt newly added calls

* move mount types to proper file

* use new Mount types for OverlayBanner apis

* fixing typo

* adapt new calls

* use destructured imports
2019-11-14 08:40:14 +01:00
Tim Roes fce52133d8
Upgrade Prettier 1.19 (#50487)
* Upgrade Prettier to 1.19

* Fix new prettier style
2019-11-13 17:00:02 +01:00
Aleh Zasypkin ad356f5c11
Migrate authorization subsystem to the new platform. (#46145) 2019-11-12 11:31:46 +01:00
Brandon Kobel a149497b73
NP Security HTTP Interceptors (#39477)
* We have a NP plugin! :celebration:

* Redirecting to login on all 401s

* Adding commented out code for when credentials are omitted

* Fixing types

* Respond 403 when user changes password with incorrect current password

* Adding AnonymousPaths where we ignore all 401s

* Adding anonymous path tests

* Extracted a dedicated SessionExpires class and added tests

* Fixing plugin after refactoring to add SessionExpired

* Beginning to work on the session timeout interceptor

* Fixing UnauthorizedResponseInterceptor anonymous path test

* Removing test anonymous path

* Trying to improve readability

* Displaying session logout warning

* Mocking out the base path

* Revert "Mocking out the base path"

This reverts commit 824086c168.

* Changing coreMock to use a concrete instance of BasePath

* Adding session timeout interceptor tests

* Adding session timeout tests

* Adding more tests for short session timeouts

* Moving some files to a session folder

* More thrashing around: renaming and reorganizing

* Renaming Interceptor to HttpInterceptor

* Fixing some type errors

* Fixing legacy chrome API tests

* Fixing other tests to use the concrete instance of BasePath

* Adjusting some types

* Putting DeeplyMocked back, I don't get how DeeplyMockedKeys works

* Moving anonymousPaths to public core http

* Reading sessionTimeout from injected vars and supporting null timeout

* Doesn't extend session when there is no response

* Updating docs and snapshots

* Casting sessionTimeout injectedVar to "number | null"

* Fixing i18n issues

* Update x-pack/plugins/security/public/plugin.ts

Co-Authored-By: Larry Gregory <lgregorydev@gmail.com>

* Adding milliseconds postfix to SessionTimeout private fields

* Even better anonymous paths, with some validation

* Adjusting public method docs for IAnonymousPaths

* Adjusting spelling of base-path to basePath

* Update x-pack/plugins/security/public/session/session_timeout.tsx

Co-Authored-By: Larry Gregory <lgregorydev@gmail.com>

* Update src/core/public/http/anonymous_paths.ts

Co-Authored-By: Josh Dover <me@joshdover.com>

* Update src/core/public/http/anonymous_paths.ts

Co-Authored-By: Josh Dover <me@joshdover.com>

* AnonymousPaths implements IAnonymousPaths and uses IBasePath

* Removing DeeplyMocked

* Removing TODOs

* Fixing types...

* Now, ever more normal
2019-10-24 08:59:45 -07:00
Aleh Zasypkin f2ea5f96b9
Drop /api/security/v1/saml route in favour of /api/security/saml/callback. (#47929) 2019-10-14 12:47:02 +02:00
Aleh Zasypkin 0210ce47b6
Preserve URL fragment during SAML handshake. (#44513) 2019-10-09 18:12:14 +02:00
Josh Dover d6410b5580
Add types to Elasticsearch API calls (#46668) 2019-10-07 13:11:30 -05:00
Aleh Zasypkin 15b272a87a
Provide realm name for OIDC/SAML authenticate requests. (#44984) 2019-09-16 10:32:58 +02:00
Aleh Zasypkin 727859c554
Downgrade log level from info to debug for cases when we cannot handle authentication attempt. (#44933) 2019-09-05 23:07:39 +02:00
Aleh Zasypkin 17106e8a78
Introduce PKI authentication provider. (#42606) 2019-08-27 18:28:54 +02:00
Mike Côté 0f2324e445
Add invalidateAPIKey support to security plugin (#43707)
* Initial work

* Fix failing jest test

* Use APIKeys class

* Only use id to invalidate

* Log all errors in invalidate function

* Cleanup

* Apply PR feedback
2019-08-27 10:21:27 -04:00
Mikhail Shustov 9a732014cb Response factory parameters as named arguments (#43248)
* pass body as response parameter. use attributes for error responses

* update core

* update tests

* update x-pack code

* update x-pack tests

* regen docs

* update comment

* Review feedback and fixes after master merge

* Eslint fixes
2019-08-23 19:31:17 +02:00
Mike Côté 5734f1c1be
Add security support for alerts and actions (#41389)
* Initial work

* Cleanup add createAPIKey fn pt1

* Change getServices function to take request as parameter

* Use API key when executing alerts

* Revert task manager using encrypted saved objects

* Store fired actions within a saved object to encrypt API keys

* Fix fireActionId

* Cleanup code, fix type check error

* Add a type for getScopedSavedObjectsClient

* Fix getBasePath and spaceIdToNamespace functions

* Add safety check for API key and action

* Fix integration tests

* Fix broken jest tests

* Cleanup

* Rename generatedApiKey to apiKeyValue

* Ensure access to action record

* Cleanup

* Add unit tests

* Fix variable conflict

* Revert task manager specific code (no longer needed)

* Remove fire terminology

* Move tests to spaces and security folder

* Use ES Archiver to remove spaces (empty_kibana)

* Fix missing pieces

* Convert action tests to run per user

* Convert alerting tests to run per user

* Fix type check issue

* Fix failing test

* Add callCluster and savedObjectsClient authorization tests

* Make savedObjectsClient return 403 for authorization tests

* Cleanup

* Fix test failure

* Common function to get data from test index

* Create ObjectRemover

* Cleanup

* useApiKey now provided to functions instead of relying on condition of two strings

* Fix typo

* Make tests it(...) start with should

* Rename useApiKey to isSecurityEnabled

* Merge apiKeyId and apiKeyValue into one

* Update docs

* Use feature controls for list alert / action types API

* Remove need to add ! in TypeScript for required plugins

* Fix ESLint issue

* Include actions and alertTypeParams into AAD and genereate new API key on update

* Generate random id for API key name attribute

* Include interval in AAD

* Send pre-encoded string

* Fix ExecutorError

* Fix apiKey snapshot

* Fix 'default' typo

* De-compose apiKey

* Refresh API key when enabling / disabling an alert

* Add updatedBy

* Make unauthorized APIs return 404
2019-08-20 11:42:15 -04:00
Aleh Zasypkin 36b1760481
Properly validate current user password during password change. (#43447) 2019-08-16 20:58:55 +02:00
Aleh Zasypkin 0d31f52bb8
Add support for OpenID Connect implicit authentication flow. (#42069) 2019-08-08 15:39:15 +02:00
Mikhail Shustov 06adc737d9
Unify response interface in handler and request interceptors (#42442)
* add response factory to the interceptors

* adopt x-pack code to the changes

* Add a separate response factory for lifecycles.

Only route handler can respond with 2xx response.
Interceptors may redirect or reject an incoming request.

* re-generate docs

* response.internal --> response.internalError

* use internalError for exceptions in authenticator

* before Security plugin proxied ES error status code. now sets explicitly.

* provide error via message field of error response for BWC

* update docs

* add customError response

* restore integration test and update unit tests

* update docs

* support Hapi error format for BWC

* add a couple of tests
2019-08-08 12:07:43 +02:00
Mike Côté 011c04f9ca
Add createApiKey support to security plugin (#42146)
* Add createApiKey support to security plugin

* Expiration is optional

* Start moving code to new platform

* Add unit tests

* Fix jest test

* Apply PR feedback

* Apply PR feedback

* Apply PR feedback pt2
2019-07-31 14:41:31 -04:00
Aleh Zasypkin 0454c5ba97
Add support for Kerberos output/response tokens. (#41861) 2019-07-25 21:00:35 +02:00
Mikhail Shustov 3f728334d0
AuthResultData configures response headers (#41775)
* extend AuthResultData with response headers

* add tests

* update docs

* rename headers --> requestHeaders to clarify intention

* update docs

* address comments
2019-07-25 07:40:59 +02:00