@@ -6,46 +6,51 @@ beta::[]
6
6
7
7
The {stack-security-features} provide _service accounts_ specifically for
8
8
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
10
10
until you create a service account token for them. Additionally, service
11
11
accounts are predefined in code, and are always enabled.
12
12
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.
19
17
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:
23
25
24
26
* Do not rely on the <<native-realm,internal `native` realm>>, and aren't
25
27
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
27
30
* Support multiple credentials through service account tokens
28
31
29
32
Service accounts are not included in the response of the
30
33
<<security-api-get-user,get users API>>. To retrieve a service account, use the
31
34
<<security-api-get-service-accounts,get service accounts API>>.
32
35
36
+ [discrete]
33
37
[[service-accounts-explanation]]
34
- ==== How service accounts work
38
+ === Service accounts usage
35
39
Service accounts have a
36
40
<<security-api-get-service-accounts-path-params,unique principal>> that takes
37
41
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.
39
44
40
- Currently, only one service account is available:
45
+ Service accounts are predefined in code. Currently, only one service account is available:
41
46
42
47
`elastic/fleet-server`:: The service account used by the {fleet} server to
43
48
communicate with {es}.
44
49
45
50
// 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.
49
54
// end::service-accounts-usage[]
50
55
51
56
// tag::service-accounts-tls[]
@@ -55,33 +60,41 @@ authenticating with a service account token unless TLS is enabled on the HTTP
55
60
interface. See <<encrypt-http-communication,encrypt HTTP client communications for {es}>>.
56
61
// end::service-accounts-tls[]
57
62
63
+ [discrete]
58
64
[[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
68
73
service account, which enables multiple instances of the same service to run
69
74
with different credentials.
70
75
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:
73
78
74
79
* 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
76
81
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
79
84
the bearer token in the HTTP response
80
85
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.
82
94
95
+ [discrete]
83
96
[[authenticate-with-service-account-token]]
84
- ==== Authenticate with service account tokens
97
+ === Authenticate with service tokens
85
98
86
99
NOTE: Service accounts currently do not support basic authentication.
87
100
@@ -95,7 +108,8 @@ curl -H "Authorization: Bearer AAEAAWVsYXN0aWM...vZmxlZXQtc2VydmVyL3Rva2VuMTo3TF
95
108
// NOTCONSOLE
96
109
97
110
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:
99
113
100
114
[source,js]
101
115
----
@@ -105,22 +119,26 @@ A successful authentication response includes a `token` field, which contains a
105
119
"full_name": "Service account - elastic/fleet-server",
106
120
"email": null,
107
121
"token": {
108
- "name": "token1" <1>
122
+ "name": "token1", <1>
123
+ "type": "_service_account_index" <2>
109
124
},
110
125
"metadata": {
111
126
"_elastic_service_account": true
112
127
},
113
128
"enabled": true,
114
129
"authentication_realm": {
115
- "name": "service_account ",
116
- "type": "service_account "
130
+ "name": "_service_account ",
131
+ "type": "_service_account "
117
132
},
118
133
"lookup_realm": {
119
- "name": "service_account ",
120
- "type": "service_account "
134
+ "name": "_service_account ",
135
+ "type": "_service_account "
121
136
},
122
137
"authentication_type": "token"
123
138
}
124
139
----
125
140
// 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