kibana/packages/kbn-hapi-mocks
Kibana Machine bb8a4a09e7
[8.10] [HTTP] Allow for internal requests to also specify special query param elasticInternalOrigin (#163796) (#164278)
# Backport

This will backport the following commits from `main` to `8.10`:
- [[HTTP] Allow for internal requests to also specify special query
param `elasticInternalOrigin`
(#163796)](https://github.com/elastic/kibana/pull/163796)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jean-Louis
Leysens","email":"jeanlouis.leysens@elastic.co"},"sourceCommit":{"committedDate":"2023-08-21T09:55:33Z","message":"[HTTP]
Allow for internal requests to also specify special query param
`elasticInternalOrigin` (#163796)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/163678\r\n\r\n* Raise the
notion of \"internal\" into `CoreKibanaRequest`. This enables\r\nus to
share this with lifecycle handlers and control validation of
query\r\nparams\r\n* Added new `isInternalRequest` alongside
`isSystemRequest` and\r\n`isFakeRequest`\r\n* Slight simplification to
existing internal restriction check\r\n* Some other chores and minor
fixes\r\n\r\n## Test\r\n\r\n* Start ES with `yarn es serverless` and
Kibana with `yarn start\r\n--serverless
--server.restrictInternalApis=true`\r\n* Add the service account token
to `kibana.dev.yml`:\r\n`elasticsearch.serviceAccountToken: <SAT>`\r\n*
Send a request to an internal endpoint like: `curl
-XPOST\r\n-uelastic:changeme
http://localhost:5601/<base-path>/api/files/find -H\r\n'kbn-xsrf: foo'
-H 'content-type: application/json' -d '{}'`\r\n * Should give you a 400
result\r\n* message like `{\"statusCode\":400,\"error\":\"Bad
Request\",\"message\":\"uri\r\n[http://localhost:5603/api/files/find]
with method [post] exists but is\r\nnot available with the current
configuration\"}`\r\n* Send the same request, but include the query
param:\r\n`elasticInternalOrigin=true`\r\n * Should give you a 200
result\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"23d39555e0d0fc36c760f0c148913db69749cb47","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:http","Team:Core","release_note:skip","v8.10.0","v8.11.0"],"number":163796,"url":"https://github.com/elastic/kibana/pull/163796","mergeCommit":{"message":"[HTTP]
Allow for internal requests to also specify special query param
`elasticInternalOrigin` (#163796)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/163678\r\n\r\n* Raise the
notion of \"internal\" into `CoreKibanaRequest`. This enables\r\nus to
share this with lifecycle handlers and control validation of
query\r\nparams\r\n* Added new `isInternalRequest` alongside
`isSystemRequest` and\r\n`isFakeRequest`\r\n* Slight simplification to
existing internal restriction check\r\n* Some other chores and minor
fixes\r\n\r\n## Test\r\n\r\n* Start ES with `yarn es serverless` and
Kibana with `yarn start\r\n--serverless
--server.restrictInternalApis=true`\r\n* Add the service account token
to `kibana.dev.yml`:\r\n`elasticsearch.serviceAccountToken: <SAT>`\r\n*
Send a request to an internal endpoint like: `curl
-XPOST\r\n-uelastic:changeme
http://localhost:5601/<base-path>/api/files/find -H\r\n'kbn-xsrf: foo'
-H 'content-type: application/json' -d '{}'`\r\n * Should give you a 400
result\r\n* message like `{\"statusCode\":400,\"error\":\"Bad
Request\",\"message\":\"uri\r\n[http://localhost:5603/api/files/find]
with method [post] exists but is\r\nnot available with the current
configuration\"}`\r\n* Send the same request, but include the query
param:\r\n`elasticInternalOrigin=true`\r\n * Should give you a 200
result\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"23d39555e0d0fc36c760f0c148913db69749cb47"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/163796","number":163796,"mergeCommit":{"message":"[HTTP]
Allow for internal requests to also specify special query param
`elasticInternalOrigin` (#163796)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/163678\r\n\r\n* Raise the
notion of \"internal\" into `CoreKibanaRequest`. This enables\r\nus to
share this with lifecycle handlers and control validation of
query\r\nparams\r\n* Added new `isInternalRequest` alongside
`isSystemRequest` and\r\n`isFakeRequest`\r\n* Slight simplification to
existing internal restriction check\r\n* Some other chores and minor
fixes\r\n\r\n## Test\r\n\r\n* Start ES with `yarn es serverless` and
Kibana with `yarn start\r\n--serverless
--server.restrictInternalApis=true`\r\n* Add the service account token
to `kibana.dev.yml`:\r\n`elasticsearch.serviceAccountToken: <SAT>`\r\n*
Send a request to an internal endpoint like: `curl
-XPOST\r\n-uelastic:changeme
http://localhost:5601/<base-path>/api/files/find -H\r\n'kbn-xsrf: foo'
-H 'content-type: application/json' -d '{}'`\r\n * Should give you a 400
result\r\n* message like `{\"statusCode\":400,\"error\":\"Bad
Request\",\"message\":\"uri\r\n[http://localhost:5603/api/files/find]
with method [post] exists but is\r\nnot available with the current
configuration\"}`\r\n* Send the same request, but include the query
param:\r\n`elasticInternalOrigin=true`\r\n * Should give you a 200
result\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"23d39555e0d0fc36c760f0c148913db69749cb47"}},{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jean-Louis Leysens <jeanlouis.leysens@elastic.co>
2023-08-21 10:01:39 +00:00
..
src [8.10] [HTTP] Allow for internal requests to also specify special query param elasticInternalOrigin (#163796) (#164278) 2023-08-21 10:01:39 +00:00
index.ts chore(NA): remove src folder requirement from packages (part 2) (#138476) 2022-08-30 15:57:35 +01:00
jest.config.js Migrate server-side http types to @kbn/core-http-server (#135808) 2022-07-11 13:28:39 +02:00
kibana.jsonc Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
package.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
README.md Migrate server-side http types to @kbn/core-http-server (#135808) 2022-07-11 13:28:39 +02:00
tsconfig.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00

@kbn/hapi-mocks

This package contains mocks for @hapi types