Repository navigation
Document user-managed service accounts and workflow execution #8921
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
Open
eedugon
wants to merge
48
commits into
main
Choose a base branch
from
service_accounts_user_managed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+598
−78
Open
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
bcaf604
Document user-managed service accounts and workflow execution
eedugon d227313
Preserve service account focus in Serverless FAQ
eedugon a681fa5
Clarify service account API authentication in Kibana
eedugon 58e17e5
Clarify service account implications of workflow editing
eedugon 104d7e3
Clarify workflow execution identity and service account guidance
eedugon 0979876
Clarify authorization for alert-triggered workflows
eedugon 4b46564
Align authorization guidance across workflow triggers
eedugon 13a55c7
Apply suggestions from code review
eedugon 45001bc
Address service account documentation feedback
eedugon 5258ada
Clarify service account token behavior
eedugon 3268f7c
Clarify service account assignments and namespaces
eedugon e8adeeb
Refine service account authentication overview
eedugon 9d0af12
Document workflow run_as in settings example
eedugon 4c805a2
comment removed
eedugon e3afa7e
Clarify workflow service account assignment
eedugon 04fee15
Integrate workflow testing with identity verification
eedugon 0532394
Clarify removing workflow service account assignment
eedugon 251e3ca
Clarify workflow authorization introduction
eedugon eb0c056
Standardize workflow service account terminology
eedugon 4dfbd76
Align workflow trigger authorization guidance
eedugon c688d2f
Clarify authorization for alert and event-driven triggers
eedugon d5aca8e
Place service account assignment link in access table
eedugon 38a29aa
Clarify child workflow identity by service account assignment
eedugon f503b77
Simplify child workflow authorization explanation
eedugon eaf701e
Improve introduction to running workflows as service accounts
eedugon 84e94fa
Simplify service account authentication overview
eedugon 2343ddb
service token update
eedugon 76523f9
Clarify execution identity in workflow trigger monitoring
eedugon 89a31e4
manage SA in kibana intro updated
eedugon ce9e38e
Merge remote-tracking branch 'origin/main' into service_accounts_user…
eedugon 5bba3b4
Make workflow authorization conditions explicit
eedugon 8e3bbca
Clarify Triggered by identity and execution context fields
eedugon 71d9060
Clarify workflow service account update requirements
eedugon 863a1c8
Merge branch 'main' into service_accounts_user_managed
eedugon 8660753
Document Serverless support for user-managed service accounts
eedugon 96a51b9
Clarify service account deployment differences and navigation
eedugon 58c3ef4
Inherit Serverless scope for the service token note
eedugon 1f69b55
Inherit Stack version scope for the service account API link
eedugon 376e51f
Clarify service tokens and Serverless API authentication
eedugon 2417918
Remove redundant API caveat from the workflow service account guide
eedugon 1a5dba7
Link Serverless service account FAQ to project API keys
eedugon 2bb79f0
Merge main into service_accounts_user_managed
eedugon 71ec621
Apply suggestions from code review
eedugon 3177cfc
reviewing progress
eedugon 37039bc
Consolidate Serverless service account guidance
eedugon 613d0b3
Clarify service account token credentials and authentication
eedugon 2e6baec
Refine service token API authentication and secrecy guidance
eedugon 679a6b6
Clarify Kibana account creation and Fleet service token generation
eedugon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
72 changes: 72 additions & 0 deletions
72
...oles/cluster-or-deployment-auth/authenticate-kibana-api-with-service-account.md
This file contains hidden or 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,72 @@ | ||
| --- | ||
| navigation_title: Authenticate to Kibana APIs | ||
| applies_to: | ||
| stack: ga 9.6+ | ||
| serverless: unavailable | ||
| description: Create a service token and use a user-managed service account to authenticate to Kibana APIs. | ||
| products: | ||
| - id: kibana | ||
| - id: elasticsearch | ||
| - id: cloud-hosted | ||
| - id: cloud-enterprise | ||
| - id: cloud-kubernetes | ||
| - id: elastic-stack | ||
| --- | ||
|
|
||
| # Authenticate to the {{kib}} API with a service account [authenticate-kibana-api-service-account] | ||
|
|
||
| Use a service token to authenticate programmatic requests to {{kib}} as a user-managed service account. The account provides a non-human identity whose privileges come from its assigned roles. | ||
|
|
||
| Service accounts can't be used with external applications on {{serverless-full}}. For programmatic access from external applications, use [API keys](/deploy-manage/api-keys.md). | ||
|
|
||
| ## Before you begin [authenticate-kibana-api-service-account-prerequisites] | ||
|
|
||
| Before you create a service token, make sure you have the following: | ||
|
|
||
| - You need an existing user-managed service account. If you don't have one, [create a service account in {{kib}}](manage-service-accounts-in-kibana.md#create-service-account-kibana). | ||
| - You need the `manage_security` cluster privilege to create a service token for a user-managed account. The `manage_service_account` privilege permits token management only for built-in accounts in the `elastic` namespace. | ||
|
|
||
| ## Create a service token for your application [create-service-account-api-token] | ||
|
|
||
| {{kib}} creates and stores a credential when you create an account in the UI. That credential is used for workload integrations and isn't displayed. For your application, create an additional service token. The following example uses an existing account with the principal `kibana/automation-client`: | ||
|
|
||
| 1. Use the [create service account token API]({{es-apis}}operation/operation-security-create-service-token) to create a token for the account: | ||
|
|
||
| ```console | ||
| POST /_security/service/kibana/automation-client/credential/token/production | ||
| ``` | ||
|
|
||
| 2. Copy the `token.value` from the response and store it securely, such as in a secrets manager. Service tokens don't expire, and you can't retrieve this value again. | ||
|
|
||
| ## Call a {{kib}} API [call-kibana-api-service-account] | ||
|
|
||
| To call the {{kib}} API using the service account identity, send the token with the `Bearer` authentication scheme: | ||
|
|
||
| ```shell | ||
| curl --request GET "$KIBANA_URL/api/spaces/space" \ | ||
| --header "Authorization: Bearer $SERVICE_ACCOUNT_TOKEN" | ||
| ``` | ||
|
|
||
|
|
||
| For requests that change data, also include the headers required by that API, such as `kbn-xsrf`. | ||
|
|
||
| ## Call an {{es}} API [call-elasticsearch-api-service-account] | ||
|
|
||
| You can use the same token to authenticate to {{es}}. For example, verify the account's identity with the authenticate API: | ||
|
|
||
| ```shell | ||
| curl --request GET "$ELASTICSEARCH_URL/_security/_authenticate" \ | ||
| --header "Authorization: Bearer $SERVICE_ACCOUNT_TOKEN" | ||
| ``` | ||
|
|
||
| ## Remove access [remove-service-account-api-access] | ||
|
|
||
| Service tokens don't expire. When an application no longer needs access, use the [delete service account token API]({{es-apis}}operation/operation-security-delete-service-token) to delete only its token: | ||
|
|
||
| ```console | ||
| DELETE /_security/service/kibana/automation-client/credential/token/production | ||
| ``` | ||
|
|
||
| Deleting the token stops requests that use it without affecting the account or its other service tokens. | ||
|
|
||
| To prevent new authentications with any of the account's service tokens, [deactivate the account](manage-service-accounts-in-kibana.md#disable-service-account). To permanently remove the identity and its associated credentials, [delete the account in {{kib}}](manage-service-accounts-in-kibana.md#delete-service-account-kibana). | ||
This file contains hidden or 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
This file contains hidden or 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
142 changes: 142 additions & 0 deletions
142
...age/users-roles/cluster-or-deployment-auth/manage-service-accounts-in-kibana.md
This file contains hidden or 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,142 @@ | ||
| --- | ||
| navigation_title: Manage service accounts | ||
| applies_to: | ||
| stack: ga 9.6+ | ||
| serverless: ga | ||
| description: Create, review, take out of service, and delete user-managed service accounts for Kibana workloads. | ||
| products: | ||
| - id: kibana | ||
| - id: elasticsearch | ||
| - id: cloud-serverless | ||
| - id: cloud-hosted | ||
| - id: cloud-enterprise | ||
| - id: cloud-kubernetes | ||
| - id: elastic-stack | ||
| --- | ||
|
|
||
| # Create and manage service accounts in {{kib}} [manage-service-accounts-kibana] | ||
|
|
||
| Create user-managed service accounts and assign roles to control programmatic access to {{es}} and {{kib}} APIs. Accounts created in {{kib}} are ready to use with {{kib}} applications such as [Workflows](/explore-analyze/workflows.md). On {{stack}} deployments, you can also use them with your own applications by [creating a service token](authenticate-kibana-api-with-service-account.md#create-service-account-api-token). | ||
|
|
||
| :::{note} | ||
| :applies_to: serverless: ga | ||
| On {{serverless-short}}, user-managed service accounts can only be used within {{kib}} applications. For programmatic access from external applications, use [API keys](/deploy-manage/api-keys.md). | ||
| ::: | ||
|
|
||
| {applies_to}`serverless: unavailable` You can also create service accounts for external applications through the [{{es}} API]({{es-apis}}operation/operation-security-put-user-managed-service-account), although accounts created this way can't be assigned to workloads in {{kib}} applications. | ||
|
|
||
| ## Before you begin [manage-service-accounts-before-you-begin] | ||
|
|
||
| Before you create or manage service accounts, check these requirements: | ||
|
|
||
| - Sign in to {{kib}} as a user with the `manage_security` cluster privilege. Without it, the **Service accounts** page isn't available. | ||
| - {applies_to}`self: ga` Set [`xpack.encryptedSavedObjects.encryptionKey`](kibana://reference/configuration-reference/security-settings.md#xpack-encryptedsavedobjects-encryptionkey) in `kibana.yml`. {{kib}} uses this key to encrypt the stored credential. | ||
| - On {{stack}} deployments, service accounts must be enabled in {{kib}}. This is the default. If your deployment turns them off, set [`xpack.security.serviceAccounts.enabled`](kibana://reference/configuration-reference/security-settings.md#service-account-settings) to `true` to re-enable them. | ||
|
|
||
| ## Create a service account [create-service-account-kibana] | ||
|
eedugon marked this conversation as resolved.
Resolved
eedugon marked this conversation as resolved.
Resolved
|
||
|
|
||
| Create a service account with the roles your workloads need: | ||
|
|
||
| 1. Find **Service accounts** in the navigation menu or use the [global search field](/explore-analyze/find-and-organize/find-apps-and-objects.md). | ||
| 2. Click **Create account**. | ||
| 3. In the **Name** field, enter a unique name of up to 128 characters. The name must start with a letter or number and can contain letters, numbers, hyphens, and underscores. | ||
| 4. Optional: In the **Description** field, describe what the account is used for. | ||
| 5. Under **Set privileges**, select one or more predefined or custom roles that grant the privileges the account needs. To create a role, click **Create new role**. | ||
|
|
||
| For details on predefined roles and how to create custom roles, refer to: | ||
|
|
||
| - {{stack}} deployments: [Built-in roles](elasticsearch://reference/elasticsearch/roles.md) and [role management in {{kib}}](kibana-role-management.md). | ||
| - {{serverless-short}} projects: [Predefined roles](/deploy-manage/users-roles/cloud-organization/user-roles.md#general-assign-user-roles-table) and [custom roles](/deploy-manage/users-roles/serverless-custom-roles.md). Before you assign roles, review the [role limits in {{serverless-short}}](#service-account-serverless-roles). | ||
|
|
||
| 6. Review the selected roles, and click **Create account**. | ||
| 7. Confirm that the account appears in the **Service accounts** table with the roles you selected. On {{stack}} deployments, the account uses the principal `kibana/<name>`. | ||
|
|
||
| Your service account is now ready to use in {{kib}} applications such as [Workflows](/explore-analyze/workflows.md). {{kib}} manages the credential for you. You don't need to copy a secret, and no token is displayed. | ||
|
|
||
| {applies_to}`serverless: unavailable` To use the account from an external API client, [create a separate named service token](authenticate-kibana-api-with-service-account.md#create-service-account-api-token). | ||
|
|
||
| ### Roles and privileges in {{serverless-short}} [service-account-serverless-roles] | ||
|
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. could bump this to an h2 as it's important context not limited to the creation flow |
||
| ```{applies_to} | ||
| serverless: ga | ||
| ``` | ||
|
|
||
| A service account can have up to 50 roles. Its privileges come from its assigned roles and cannot exceed the access its creator had when the account was created. | ||
|
|
||
| When a workload uses [cross-project search](/explore-analyze/cross-project-search.md), its service account's predefined roles apply across linked projects. For a custom role to grant access to a linked project, that project must define a role with the same name. Custom roles aren't copied between projects. | ||
|
|
||
|
|
||
| ## Review service accounts [review-service-accounts-kibana] | ||
|
|
||
| The **Service accounts** table shows each account's name, description, roles, creator, and number of bound workloads. A **Disabled** badge identifies accounts that can't authenticate. Use the **Role** filter to find accounts assigned to specific roles. | ||
|
|
||
| When an account has bound workloads, click **View** in the **Workloads** column to review them. | ||
|
|
||
| ## Update a service account [update-service-account-kibana] | ||
|
|
||
| You can't update service accounts in the {{kib}} UI. On {{serverless-short}}, to change an account's assigned roles or description, [delete the account](#delete-service-account-kibana) and [create a new one](#create-service-account-kibana). On {{stack}} deployments, you can update accounts through the {{es}} API. | ||
|
|
||
| :::{tip} | ||
| To change a service account's privileges, you can edit a role already assigned to it without changing the account's role assignments. Changes to a role also affect other users and service accounts assigned that role. | ||
| ::: | ||
|
|
||
| ### Update or deactivate an account through the {{es}} API [disable-service-account] | ||
| ```{applies_to} | ||
| serverless: unavailable | ||
| ``` | ||
|
|
||
| Use the [create or replace user-managed service account API]({{es-apis}}operation/operation-security-put-user-managed-service-account) to update an account's roles or description, or to deactivate it by setting `enabled` to `false`. | ||
|
|
||
| The PUT request replaces the complete account definition. Send the full definition, including every role, the description, and the `enabled` value you want to preserve. A role left out of the `roles` list is no longer assigned, and an omitted `description` is cleared. If you omit `enabled`, it defaults to `true`. The `roles` field itself is required. | ||
|
|
||
| For example, this request deactivates an account by sending its full definition with `enabled` set to `false`: | ||
|
|
||
| ```console | ||
| PUT /_security/service/kibana/workflow-runner | ||
| { | ||
| "roles": [ "workflow_runner" ], | ||
| "description": "Runs incident response workflows", | ||
| "enabled": false | ||
| } | ||
| ``` | ||
|
|
||
| Setting `enabled: false` prevents authentication with the account's service tokens without deleting the account. It doesn't invalidate [short-lived access tokens](token-based-authentication-services.md#token-authentication-access-token) already issued to run workloads as the account. API keys already issued to the account also remain valid. | ||
|
|
||
| To reactivate the account, send the complete definition again with `enabled` set to `true`. | ||
|
|
||
| [Workflows assigned to an account](/explore-analyze/workflows/authoring-techniques/run-workflow-as-service-account.md#assign-workflow-service-account) that has `enabled: false` fail the next time they run. They don't fall back to the user who starts or edits the workflow. | ||
|
|
||
| ## Delete a service account [delete-service-account-kibana] | ||
|
|
||
| Deleting a service account is permanent. On {{stack}} deployments, if you only need to temporarily prevent the account from authenticating, [deactivate it](#disable-service-account) instead. | ||
|
|
||
| To delete a service account: | ||
|
|
||
| 1. On the **Service accounts** page, find the account. | ||
| 2. From the **Actions** column, click **Delete**. | ||
| 3. Review the confirmation: | ||
| - If no workloads are bound, click **Delete account**. | ||
| - If workloads are bound, review the list. To delete the account without removing the bindings, click **Force delete account**. | ||
|
|
||
| If you force delete an account, workloads assigned to it fail on their next run. To restore access, assign each affected workload a valid service account. This reassignment is required even if you recreate the deleted account with the same name. For Workflows, [assign a service account to each affected workflow](/explore-analyze/workflows/authoring-techniques/run-workflow-as-service-account.md#assign-workflow-service-account). | ||
|
|
||
|
|
||
| ### Credentials after deletion in {{stack}} deployments [delete-service-account-stack-credentials] | ||
| ```{applies_to} | ||
| serverless: unavailable | ||
| ``` | ||
|
|
||
| Deleting an account through {{kib}} attempts to remove every service token, including the credential it stores for workloads and tokens created outside {{kib}}. It also attempts to invalidate any short-lived access tokens used to run workloads as the account. If any credential cleanup fails, {{kib}} completes the deletion and reports a warning. | ||
|
|
||
| A service token left behind after deletion can't authenticate, but it prevents you from creating another account with the same name until you delete the token. | ||
|
|
||
| :::{important} | ||
| API keys owned by the account aren't invalidated when you delete the account. {{rules-ui}} and tasks that obtained an API key while authenticated as the account can continue to run with that key. To revoke this access, [invalidate the API keys]({{es-apis}}operation/operation-security-invalidate-api-key) explicitly. | ||
| ::: | ||
|
|
||
| ## Next steps [manage-service-accounts-next-steps] | ||
|
|
||
| Use these guides to work with service accounts and learn more about their credentials: | ||
|
|
||
| - [Run a workflow as a service account](/explore-analyze/workflows/authoring-techniques/run-workflow-as-service-account.md). | ||
| - {applies_to}`serverless: unavailable` [Authenticate to the {{kib}} API with a service account](authenticate-kibana-api-with-service-account.md). | ||
| - Learn more about [service account types and credentials](service-accounts.md). | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.