-
Notifications
You must be signed in to change notification settings - Fork 865
#38044 API design: Create API-only users that only have access to Customer-defined Fleet API endpoints #42352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2300a17
a150b60
6b4716e
e2e0041
92230bb
62369aa
27fc20d
734a5ea
30d4501
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12962,6 +12962,8 @@ Transforms a host name into a host id. For example, the Fleet UI uses this endpo | |
| - [Delete invite](#delete-invite) | ||
| - [Verify invite](#verify-invite) | ||
| - [Update invite](#update-invite) | ||
| - [Create API-only user](#create-api-only-user) | ||
| - [List API endpoints for API-only user permissions](#list-api-endpoints-for-api-only-user-permissions) | ||
|
|
||
| The Fleet server exposes API endpoints that handles common user management operations, including managing emailed invites to new users. All of these endpoints require prior authentication, so you'll need to log in before calling any of the endpoints documented below. | ||
|
|
||
|
|
@@ -13824,6 +13826,128 @@ Verify the specified invite. | |
| } | ||
| ``` | ||
|
|
||
| ### Create API-only user | ||
|
|
||
| Creates an API-only user that does not have access to the UI. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe worth documenting that this is a global/team admin only endpoint. |
||
|
|
||
| `POST /api/v1/fleet/users/api_only` | ||
|
|
||
| | Name | Type | In | Description | | ||
| | :---------------------- | :------ | :---- | :---------- | | ||
|
rachaelshaw marked this conversation as resolved.
|
||
| | name | string | body | The display name for the API-only user. | | ||
| | global_role | string | body | The role assigned to the user. If `global_role` is specified, `fleets` cannot be specified. For more information, see [manage access](https://fleetdm.com/docs/using-fleet/manage-access). | | ||
| | fleets | array | body | _Available in Fleet Premium_. The fleets and respective roles assigned to the user. Should contain an array of objects in which each object includes the fleet's `id` and the user's `role` on each fleet. If `fleets` is specified, `global_role` cannot be specified. For more information, see [manage access](https://fleetdm.com/docs/using-fleet/manage-access). | | ||
| | api_endpoints | array | body | _Available in Fleet Premium_. A list of `id`s of API endpoints this user will have access to. For available endpoints, see [List API endpoints for API-only user permissions](#list-api-endpoints-for-api-only-user-permissions). | | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rachaelshaw And on the UI we probably want to disable the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cood catch 👍 We should make the user select at least one endpoint or "All" before saving
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| If `api_endpoints` is specified, these do not grant additional permissions otherwise forbidden by the user's `role`. | ||
|
|
||
|
|
||
| #### Example | ||
|
|
||
| `POST /api/v1/fleet/users/api_only` | ||
|
|
||
| ##### Request body | ||
|
|
||
| ```json | ||
| { | ||
| "name": "Jane Doe", | ||
| "fleets": [ | ||
| { | ||
| "id": 2, | ||
| "role": "observer" | ||
| }, | ||
| { | ||
| "id": 3, | ||
| "role": "maintainer" | ||
| } | ||
| ], | ||
| "api_endpoints": [1,5,7,32] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rachaelshaw |
||
| } | ||
| ``` | ||
|
|
||
| ##### Default response | ||
|
|
||
| `Status: 200` | ||
|
|
||
| ```json | ||
| { | ||
| "user": { | ||
| "created_at": "0001-01-01T00:00:00Z", | ||
| "updated_at": "0001-01-01T00:00:00Z", | ||
| "id": 5, | ||
| "name": "Jane Doe", | ||
| "email": "janedoe+randomlygeneratedstring@example.com", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just double checking,
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that's the admin's email |
||
| "enabled": true, | ||
| "force_password_reset": false, | ||
| "gravatar_url": "", | ||
| "sso_enabled": false, | ||
| "mfa_enabled": false, | ||
| "api_only": true, | ||
| "global_role": null, | ||
| "fleets": [ | ||
| { | ||
| "id": 2, | ||
| "role": "observer" | ||
| }, | ||
| { | ||
| "id": 3, | ||
| "role": "maintainer" | ||
| } | ||
| ], | ||
| "api_endpoints": [1,5,7,32] | ||
| }, | ||
| "token": "{API key}" | ||
| } | ||
| ``` | ||
|
|
||
|
|
||
| ### List API endpoints for API-only user permissions | ||
|
rachaelshaw marked this conversation as resolved.
|
||
|
|
||
| _Available in Fleet Premium._ | ||
|
|
||
| Lists Fleet REST API endpoints that an API-only user can be granted access to. | ||
|
rachaelshaw marked this conversation as resolved.
|
||
|
|
||
| `GET /api/v1/fleet/rest_api` | ||
|
|
||
| | Name | Type | In | Description | | ||
| | :---------------------- | :------ | :---- | :---------- | | ||
| | query | string | query | Search query keywords. Searchable fields include `display_name` and `path`. | | ||
|
|
||
| Searching by path ignores the naming of path parameters that are specified with `:` , e.g. `:id`. So searching `/hosts/:id/report` is the same as searching `/hosts/:host_id/report`. | ||
|
|
||
| Experimental endpoints are excluded from the results, since they are not for use in automated workflows. | ||
|
|
||
| #### Example | ||
|
|
||
| `GET /api/v1/fleet/rest_api?query=get%20host%20by%20identifier` | ||
|
rachaelshaw marked this conversation as resolved.
|
||
| or | ||
| `GET /api/v1/fleet/rest_api?query=%2Fapi%2Fv1%2Ffleet%2Fhosts%2Fidentifier%2F%3Ahost_identifier` | ||
|
|
||
| ##### Default response | ||
|
|
||
| `Status: 200` | ||
|
|
||
| ```json | ||
| { | ||
| "api_endpoints": [ | ||
| { | ||
| "id": 123, | ||
| "display_name": "Get host by identifier", | ||
| "method": "GET", | ||
| "path": "/api/v1/fleet/hosts/identifier/:identifier", | ||
| "deprecated": false | ||
| } | ||
| ], | ||
| "meta": { | ||
| "has_next_results": true, | ||
| "has_previous_results": false | ||
| }, | ||
| "count": 1 | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Debug | ||
|
|
||
| - [Get errors](#get-errors) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.