mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Authz] Added section for migration routes created by utility function (#198401)
## Summary - Added section for migrating routes created by utility function. - Added `patch` method to route methods in eslint rule. ### Checklist - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
This commit is contained in:
parent
3c5319f215
commit
71a298ef7b
2 changed files with 18 additions and 1 deletions
|
@ -313,6 +313,23 @@ Routes without a compelling reason to opt-out of authorization should plan to in
|
|||
MIGRATE_DISABLED_AUTHZ=true MIGRATE_ENABLED_AUTHZ=true npx eslint --ext .ts --fix path/to/your/folder
|
||||
```
|
||||
|
||||
**How to migrate if you have an utility function for route creation?**
|
||||
If you have utility function that creates routes, i.e `createApmServerRoute` or `createObservabilityOnboardingServerRoute`, you can easily modify the eslint rule to handle your case.
|
||||
For example, you register the route with `access` tags in your utility function:
|
||||
```ts
|
||||
createApmServerRoute({
|
||||
endpoint: 'GET /your/route/path',
|
||||
options: { tags: ['access:apm'] },
|
||||
handler: async (resources): => {
|
||||
// your handler logic
|
||||
},
|
||||
})
|
||||
```
|
||||
You can modify [the rule](https://github.com/elastic/kibana/blob/6a50066e00ae38a64c5365fd66b4dc32857ba1fc/packages/kbn-eslint-plugin-eslint/rules/no_deprecated_authz_config.js#L312-#L315) to handle your case by adding the following code:
|
||||
```ts
|
||||
callee.type === 'Identifier' && callee.name === 'createApmServerRoute'
|
||||
```
|
||||
|
||||
## Questions?
|
||||
If you have any questions or need help with API authorization, please reach out to the `@elastic/kibana-security` team.
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
const routeMethods = ['get', 'put', 'delete', 'post'];
|
||||
const routeMethods = ['get', 'put', 'delete', 'post', 'patch'];
|
||||
const ACCESS_TAG_PREFIX = 'access:';
|
||||
|
||||
const isStringLiteral = (el) => el.type === 'Literal' && typeof el.value === 'string';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue