Skip to content

Commit 09fa6fa

Browse files
Adam Lockeywangdelasticmachine
authored
[DOCS] Service account edits (#73732) (#74127)
* Put all service accounts information on one page * De-emphasize connection with built-in accounts + edits * Iterate on the docs: tweak, correction and more details. * fix test * Edits and minor text changes Co-authored-by: Yang Wang <yang.wang@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Yang Wang <yang.wang@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 917154b commit 09fa6fa

File tree

1 file changed

+58
-40
lines changed

1 file changed

+58
-40
lines changed

x-pack/docs/en/security/authentication/service-accounts.asciidoc

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,51 @@ beta::[]
66

77
The {stack-security-features} provide _service accounts_ specifically for
88
integration with external services that connect to {es}, such as {fleet} server.
9-
Service accounts have a fixed set of privileges and cannot be authenticated
9+
Service accounts have a fixed set of privileges and cannot authenticate
1010
until you create a service account token for them. Additionally, service
1111
accounts are predefined in code, and are always enabled.
1212

13-
With service accounts, services (such as {fleet} server) can create a
14-
service account token, authenticate with that token, and manage their own API keys.
15-
Multiple service account tokens can be created for the same service account.
16-
This prevents credential sharing between multiple instances of the same external service.
17-
That is, these instances can assume the same identity while having their own distinct
18-
service account tokens for authentication.
13+
A service account corresponds to a specific external service. You create service
14+
account tokens for a service account. The service can then authenticate with the
15+
token and perform relevant actions. For example, {fleet} server can use its
16+
service token to authenticate with {es} and then manage its own API keys.
1917

20-
=== Service accounts vs built-in users
21-
Service account is an evolution of the built-in users. It provides
22-
flexibility over built-in users because they:
18+
You can create multiple service tokens for the same service account, which
19+
prevents credential sharing between multiple instances of the same
20+
external service. Each instance can assume the same identity while using
21+
their own distinct service token for authentication.
22+
23+
Service accounts provide flexibility over <<built-in-users,built-in users>>
24+
because they:
2325

2426
* Do not rely on the <<native-realm,internal `native` realm>>, and aren't
2527
always required to rely on the `.security` index
26-
* Use a role descriptor named after the service account principal instead of traditional roles
28+
* Use a role descriptor named after the service account principal instead of
29+
traditional roles
2730
* Support multiple credentials through service account tokens
2831

2932
Service accounts are not included in the response of the
3033
<<security-api-get-user,get users API>>. To retrieve a service account, use the
3134
<<security-api-get-service-accounts,get service accounts API>>.
3235

36+
[discrete]
3337
[[service-accounts-explanation]]
34-
==== How service accounts work
38+
=== Service accounts usage
3539
Service accounts have a
3640
<<security-api-get-service-accounts-path-params,unique principal>> that takes
3741
the format of `<namespace>/<service>`, where the `namespace` is a top-level
38-
grouping of service accounts, and `service` is the name of the service.
42+
grouping of service accounts, and `service` is the name of the service and
43+
must be unique within its namespace.
3944

40-
Currently, only one service account is available:
45+
Service accounts are predefined in code. Currently, only one service account is available:
4146

4247
`elastic/fleet-server`:: The service account used by the {fleet} server to
4348
communicate with {es}.
4449

4550
// tag::service-accounts-usage[]
46-
IMPORTANT: The predefined service accounts are intended for external services
47-
connecting to {es}. Do not attempt to use service accounts for authenticating
48-
individual users.
51+
IMPORTANT: Do not attempt to use service accounts for authenticating individual
52+
users. Service accounts can only be authenticated with service tokens, which are
53+
not applicable to regular users.
4954
// end::service-accounts-usage[]
5055

5156
// tag::service-accounts-tls[]
@@ -55,33 +60,41 @@ authenticating with a service account token unless TLS is enabled on the HTTP
5560
interface. See <<encrypt-http-communication,encrypt HTTP client communications for {es}>>.
5661
// end::service-accounts-tls[]
5762

63+
[discrete]
5864
[[service-accounts-tokens]]
59-
==== How service account tokens work
60-
A service account token, or simply service token,
61-
is a unique string that a service uses to authenticate
62-
with {es}. For a given service account, each token must have a unique name.
63-
Because tokens include access credentials, they should always be kept secret
64-
by whichever client is using them.
65-
66-
Service account tokens can be backed by either the `service_tokens` file or the
67-
`.security` index. You can create multiple service account tokens for a single
65+
=== Service account tokens
66+
A service account token, or service token, is a unique string that a
67+
service uses to authenticate with {es}. For a given service account, each token
68+
must have a unique name. Because tokens include access credentials, they should
69+
always be kept secret by whichever client is using them.
70+
71+
Service tokens can be backed by either the `service_tokens` file or the
72+
`.security` index. You can create multiple service tokens for a single
6873
service account, which enables multiple instances of the same service to run
6974
with different credentials.
7075

71-
You must create a service account token to use a service account. You can
72-
create a service account token using either:
76+
You must create a service token to use a service account. You can
77+
create a service token using either:
7378

7479
* The <<service-tokens-command,elasticsearch-service-tokens>> CLI tool, which
75-
saves the new service account token in the `$ES_HOME/config/service_tokens` file
80+
saves the new service token in the `$ES_HOME/config/service_tokens` file
7681
and outputs the bearer token to your terminal
77-
* The <<security-api-create-service-token,create service account tokens API>>,
78-
which saves the new service account token in the `.security` index and returns
82+
* The <<security-api-create-service-token,create service account token API>>,
83+
which saves the new service token in the `.security` index and returns
7984
the bearer token in the HTTP response
8085

81-
Service account tokens never expire. You must actively <<security-api-delete-service-token,delete>> them if they are no longer needed.
86+
Both of these methods create a service token with a guaranteed secret string
87+
length of `22`. The minimal, acceptable length of a secret string for a service
88+
token is `10`. If the secret string doesn't meet this minimal length,
89+
authentication with {es} will fail without even checking the value of the
90+
service token.
91+
92+
Service tokens never expire. You must actively
93+
<<security-api-delete-service-token,delete>> them if they are no longer needed.
8294

95+
[discrete]
8396
[[authenticate-with-service-account-token]]
84-
==== Authenticate with service account tokens
97+
=== Authenticate with service tokens
8598

8699
NOTE: Service accounts currently do not support basic authentication.
87100

@@ -95,7 +108,8 @@ curl -H "Authorization: Bearer AAEAAWVsYXN0aWM...vZmxlZXQtc2VydmVyL3Rva2VuMTo3TF
95108
// NOTCONSOLE
96109

97110
A successful authentication response includes a `token` field, which contains a
98-
`name` for the name of the service account token:
111+
`name` field for the name of the service token and a `type` field for the
112+
type of the service token:
99113

100114
[source,js]
101115
----
@@ -105,22 +119,26 @@ A successful authentication response includes a `token` field, which contains a
105119
"full_name": "Service account - elastic/fleet-server",
106120
"email": null,
107121
"token": {
108-
"name": "token1" <1>
122+
"name": "token1", <1>
123+
"type": "_service_account_index" <2>
109124
},
110125
"metadata": {
111126
"_elastic_service_account": true
112127
},
113128
"enabled": true,
114129
"authentication_realm": {
115-
"name": "service_account",
116-
"type": "service_account"
130+
"name": "_service_account",
131+
"type": "_service_account"
117132
},
118133
"lookup_realm": {
119-
"name": "service_account",
120-
"type": "service_account"
134+
"name": "_service_account",
135+
"type": "_service_account"
121136
},
122137
"authentication_type": "token"
123138
}
124139
----
125140
// NOTCONSOLE
126-
<1> Name of the service account token
141+
<1> Name of the service account token.
142+
<2> Type of service account token. The value always begins with
143+
`_service_account_` and is followed by a string that indicates the service
144+
token backend in use (can be either `file` or `index`).

0 commit comments

Comments
 (0)