forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] use defaultFleetErrorHandler in all fleet routes (elastic#200741
- Loading branch information
1 parent
be1f69e
commit 2a0edf3
Showing
34 changed files
with
1,624 additions
and
1,891 deletions.
There are no files selected for viewing
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,33 @@ | ||
# Fleet router | ||
|
||
All the fleet API routes are wrapped with a custom handler see [fleet_router](../server/services/security/fleet_router.ts) that provides error handling and security. | ||
|
||
## Error handling | ||
|
||
All non catched errors in Fleet API will go throuh a default error handler, that will allow to transform known error in response with predefined status code. | ||
|
||
## Security | ||
|
||
Fleet router also provide an easy way to declare authorization rules for Fleet routes. This can be done via the `fleetAuthz` property via a function or an object with required roles. | ||
|
||
Examples: | ||
|
||
```typescript | ||
router.versioned.get({ | ||
path: OUTPUT_API_ROUTES.LIST_PATTERN, | ||
fleetAuthz: (authz) => { | ||
return authz.fleet.readSettings || authz.fleet.readAgentPolicies; | ||
}, | ||
summary: 'Get outputs', | ||
}); | ||
``` | ||
|
||
```typescript | ||
router.versioned.post({ | ||
path: OUTPUT_API_ROUTES.CREATE_PATTERN, | ||
fleetAuthz: { | ||
fleet: { allSettings: true }, | ||
}, | ||
summary: 'Create output', | ||
}); | ||
``` |
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
Oops, something went wrong.